Beispiel #1
0
        protected override void Initialize()
        {
            const float secondsInMinutes = 60f;
            const float rateOfFire       = 200f;

            _inputListner = new InputListener();

            /*
             * if (_currentKeyboardState.IsKeyDown(Keys.Space) || _currentGamePadState.Buttons.X == ButtonState.Pressed)
             *  FireLaser(gameTime);
             *
             */
            _inputListner.OnKeyDown        += InputListenerOnOnKeyDown;
            _inputListner.OnGamePadPressed += InputListenerOnOnGamePadPressed;

            _inputListner.SupportKey(Keys.Space);
            _inputListner.SupportButton(Buttons.X);

            _score                  = 0;
            _player                 = new Player();
            _playerMoveSpeed        = 8.0f;
            _bgLayer1               = new ParallaxingBackground();
            _bgLayer2               = new ParallaxingBackground();
            _enemies                = new List <Enemy>();
            _previousSpawnTime      = TimeSpan.Zero;
            _enemySpawnTime         = TimeSpan.FromSeconds(1.0f);
            _random                 = new Random();
            _laserBeams             = new List <Laser>();
            _laserSpawnTime         = TimeSpan.FromSeconds(secondsInMinutes / rateOfFire);
            _previousLaserSpawnTime = TimeSpan.Zero;
            _explosions             = new List <Explosion>();

            base.Initialize();
        }