public static void update(Leoni game)
        {
            //Update Keyboard and Mouse states
            game.KeyboardState = Keyboard.GetState();
            game.MouseState = Mouse.GetState();

            //SHOOTING BLOCKS
            /*if (game.MouseState.LeftButton == ButtonState.Pressed)
            {
                //If the user is clicking, start firing some boxes.
                //First, create a new dynamic box at the camera's location.
                Box toAdd = new Box(game.Camera.Position, 1, 1, 1, 1);
                //Set the velocity of the new box to fly in the direction the camera is pointing.
                //Entities have a whole bunch of properties that can be read from and written to.
                //Try looking around in the entity's available properties to get an idea of what is available.
                toAdd.LinearVelocity = game.Camera.WorldMatrix.Forward * 10;
                //Add the new box to the simulation.
                game.space.Add(toAdd);

                //Add a graphical representation of the box to the drawable game components.
                EntityModel model = new EntityModel(toAdd, CubeModel, Matrix.Identity, this);
                game.Components.Add(model);
                toAdd.Tag = model;  //set the object tag of this entity to the model so that it's easy to delete the graphics component later if the entity is removed.
            }*/

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || game.KeyboardState.IsKeyDown(Keys.Escape))
                game.Exit();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructs a new camera.
 /// </summary>
 /// <param name="game">Game that this camera belongs to.</param>
 /// <param name="position">Initial position of the camera.</param>
 /// <param name="speed">Initial movement speed of the camera.</param>
 public Camera(Leoni game, Vector3 position, float speed)
 {
     Game = game;
     Position = position;
     Speed = speed;
     ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 4f / 3f, .1f, 10000.0f);
     Mouse.SetPosition(200, 200);
 }
        public static void load(Leoni game)
        {
            //Effects
            game.simpleEffect = game.Content.Load<Effect>("Effects\\PreEffects\\SimpleEffect");
            game.textureEffect = game.Content.Load<Effect>("Effects\\PreEffects\\TexturingEffect");
            game.shadowEffect = game.Content.Load<Effect>("Effects\\PreEffects\\DirectionalLighting");
            game.postEffect = game.Content.Load<Effect>("Effects\\PostEffects\\PostEffect");

            //Fonts
            game.fogFont = game.Content.Load<SpriteFont>("Font\\foglihten_48");
        }
        //Update physics
        public static void update(Leoni leoni, GameTime gameTime)
        {
            //updates game camera
            UpdateCamera.update(leoni, gameTime);

            //Update light data
            leoni.lightPos = new Vector3(5, 5, 5);
            leoni.lightsView = Matrix.CreateLookAt(leoni.lightPos, new Vector3(0, 0, 0), new Vector3(0, 1, 0));
            leoni.lightProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, 1f, 0.1f, 100f);
            leoni.lightProjectionMatrix = leoni.lightsView * leoni.lightProjection;

            //Steps the simulation forward one time step.
            leoni.space.Update();
        }
Exemplo n.º 5
0
        public static void draw(Leoni game, Texture2D map)
        {
            //Draw Post processing
            game.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, game.postEffect);

            //Draw rendered frame
            game.spriteBatch.Draw(map, new Rectangle(0, 0, game.screenSizeWidth, game.screenSizeHeight), Color.White);
            game.spriteBatch.Draw(game.depthMap, new Rectangle(0, game.screenSizeHeight-200, 200, 200), Color.White);

            //Allow for text background to be clear instead of black
            game.GraphicsDevice.BlendState = BlendState.AlphaBlend;
            //Text
            game.spriteBatch.DrawString(game.fogFont, "Sample String", new Vector2(5, 5), Color.White, 0, new Vector2(0), 0.4f, SpriteEffects.None, 0);

            game.spriteBatch.End();
        }
        public void add(String file, Leoni game, AffineTransform pos)
        {
            //Load Model
            Model model = game.Content.Load<Model>(file);

            //change the model to a mesh to create vertici collision
            Vector3[] vertices;
            int[] indices;
            TriangleMesh.GetVerticesAndIndicesFromModel(model, out vertices, out indices);
            var mesh = new StaticMesh(vertices, indices, pos);

            //Add it to the space!
            game.space.Add(mesh);

            //Make it visible too.
            StaticModel tmpModel = new StaticModel(model, mesh.WorldTransform.Matrix, game);

            game.Components.Add(tmpModel);
        }
        public static void setup(Leoni game)
        {
            //initClasses
            InitializeEntityModel eModels = new InitializeEntityModel();
            InitializeStaticModel sModels = new InitializeStaticModel();

            /** Static Models **/
            sModels.add("Terrain//floor1", game, new AffineTransform(new Vector3(0)));
            sModels.add("Models//test", game, new AffineTransform(new Vector3(0)));

            /** Entity Models **/
            Model CubeModel = game.Content.Load<Model>("Models//Cube");
            Model plantPot1 = game.Content.Load<Model>("Terrain//plantpot1");

            eModels.add(new Box(new Vector3(3, 2, 3), 1, 1, 1, 1), plantPot1, game);

            //Cube Demo
            eModels.add(new Box(new Vector3(0, 2, 0), 1, 1, 1, 1), CubeModel, game);
            eModels.add(new Box(new Vector3(0, 4, 0), 1, 1, 1, 1), CubeModel, game);
            eModels.add(new Box(new Vector3(0, 6, 0), 1, 1, 1, 1), CubeModel, game);
        }
        public void add(Entity e, Model model, Leoni game)
        {
            //Add collisions
            game.space.Add(e);

            //Get the eneity now in space
            Entity _e = game.space.Entities[game.space.Entities.Count - 1];
            Box _box = _e as Box;
            if (_box != null)
            {
                //Setup Entity Model
                Matrix scaling = Matrix.CreateScale(_box.Width, _box.Height, _box.Length);
                EntityModel eModel = new EntityModel(_e, model, scaling, game, game.textureEffect);

                //Add the new model to the world
                game.Components.Add(eModel);

                //Tag the model to the collision box
                _e.Tag = eModel;
            }
        }
Exemplo n.º 9
0
 //Save the current Render Target information in a Texture2D format
 public static Texture2D save(Leoni leoni, RenderTarget2D target)
 {
     //Set the render target to none and save the image
     leoni.graphics.GraphicsDevice.SetRenderTarget(null);
     return (Texture2D)target;
 }
 //Constructor
 public InitializeEntityModel(Entity e, Model model, Leoni game)
 {
     add(e, model, game);
 }
 //Constructor
 public InitializeStaticModel(String file, Leoni game, AffineTransform pos)
 {
     add(file, game, pos);
 }
Exemplo n.º 12
0
 public static void update(Leoni game)
 {
     UpdateKeyboardInput.update(game);
 }