Esempio n. 1
0
        protected override void Update(GameTime gameTime)
        {
            var deltaSeconds  = (float)gameTime.ElapsedGameTime.TotalSeconds;
            var keyboardState = Keyboard.GetState();
            var mouseState    = Mouse.GetState();

            //_mousePoint = _camera.ScreenToWorld(new Vector2(mouseState.X, mouseState.Y)).ToPoint();

            // camera
            if (keyboardState.IsKeyDown(Keys.R))
            {
                _camera.ZoomIn(deltaSeconds);
            }

            if (keyboardState.IsKeyDown(Keys.F))
            {
                _camera.ZoomOut(deltaSeconds);
            }

            // zombie
            if (keyboardState.IsKeyDown(Keys.Left))
            {
                _zombie.Walk(-1.0f);
            }

            if (keyboardState.IsKeyDown(Keys.Right))
            {
                _zombie.Walk(1.0f);
            }

            if (keyboardState.IsKeyDown(Keys.Space))
            {
                _zombie.Attack();
            }

            if (keyboardState.IsKeyDown(Keys.Up))
            {
                _zombie.Jump();
            }

            if (keyboardState.IsKeyDown(Keys.Enter))
            {
                _zombie.Die();
            }

            // update must be called before collision detection
            _zombie.Update(gameTime);
            _world.Update(gameTime);
            _camera.LookAt(_zombie.Position);

            base.Update(gameTime);
        }
Esempio n. 2
0
        protected override void Update(GameTime gameTime)
        {
            var deltaSeconds  = (float)gameTime.ElapsedGameTime.TotalSeconds;
            var keyboardState = Keyboard.GetState();

            // motw
            if (keyboardState.IsKeyDown(Keys.W))
            {
                _motwSprite.Play("walkNorth");
            }

            if (keyboardState.IsKeyDown(Keys.A))
            {
                _motwSprite.Play("walkWest");
            }

            if (keyboardState.IsKeyDown(Keys.S))
            {
                _motwSprite.Play("walkSouth");
            }

            if (keyboardState.IsKeyDown(Keys.D))
            {
                _motwSprite.Play("walkEast");
            }

            // camera
            if (keyboardState.IsKeyDown(Keys.R))
            {
                _camera.ZoomIn(deltaSeconds);
            }

            if (keyboardState.IsKeyDown(Keys.F))
            {
                _camera.ZoomOut(deltaSeconds);
            }

            // zombie
            if (keyboardState.IsKeyDown(Keys.Left))
            {
                _zombie.Walk(-1.0f);
            }

            if (keyboardState.IsKeyDown(Keys.Right))
            {
                _zombie.Walk(1.0f);
            }

            if (keyboardState.IsKeyDown(Keys.Space))
            {
                _zombie.Attack();
            }

            //if (keyboardState.IsKeyDown(Keys.Up))
            //    _zombie.Jump();

            if (keyboardState.IsKeyDown(Keys.Enter))
            {
                _zombie.Die();
            }

            // update must be called before collision detection
            _zombie.Update(gameTime);
            //_world.Update(gameTime);
            _camera.LookAt(_zombie.Position);

            _animation.Update(deltaSeconds);
            _fireballSprite.TextureRegion = _animation.CurrentFrame;

            _motwSprite.Update(deltaSeconds);

            base.Update(gameTime);
        }