Esempio n. 1
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (world == null)
            {
                world = new WorldBase(0);
            }

            world.update(gameTime);

            Vector2 playerMoveDir = new Vector2();

            if (Keyboard.GetState().IsKeyDown(Keys.A))
            {
                playerMoveDir += new Vector2(-1, 0);
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.D))
            {
                playerMoveDir += new Vector2(1, 0);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.W))
            {
                playerMoveDir += new Vector2(0, -1);
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.S))
            {
                playerMoveDir += new Vector2(0, 1);
            }

            world.playerLoc += playerMoveDir * 5;

            base.Update(gameTime);
        }