Exemplo n.º 1
0
 private void HandleStart(GameTime gameTime)
 {
     if (_controls.ReadFlap())
     {
         _viewer.Reset(gameTime);
         _bird.Reset(gameTime);
         _pipeCollection.Reset();
         _state = _alive;
     }
 }
Exemplo n.º 2
0
        public void AliveUpdate(GameTime gameTime)
        {
            if (_controls.ReadFlap())
            {
                _body.ChangeVelocity(gameTime, new Vector2(300.0f, -400.0f));
            }

            _sprite.Position = _body.Position(gameTime);
            var velocity = _body.Velocity(gameTime);

            _sprite.Rotation = (float)Math.Atan2(velocity.Y, velocity.X);
            int frame = gameTime.TotalGameTime.Milliseconds / 250;

            _sprite.ImageIndex = frame > 2 ? 1 : frame;
        }