/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { _gameState = gameStates.game; var viewPortHeight = GraphicsDevice.Viewport.Height; var viewPortWidth = GraphicsDevice.Viewport.Width; SpawnBall(); //_ninjaStar = new NinjaStar(new Vector2(viewPortWidth / 2f, viewPortHeight / 2f)); _paddleOne = new Paddle(20, viewPortHeight / 2f, 0); _paddleOne.SetScreenSize(viewPortWidth, viewPortHeight); _paddleOne.AddUpKeys(Keys.W); _paddleOne.AddUpKeys(Keys.OemComma); _paddleOne.AddDownKeys(Keys.O); _paddleOne.AddDownKeys(Keys.S); _paddleOne.AddBoostKeys(Keys.D); _paddleOne.AddBoostKeys(Keys.E); //_paddleOne.AddRotateKeys(Keys.Right); _paddleOne.Initialize(); _paddleTwo = new Paddle(viewPortWidth - 20, viewPortHeight / 2f, 180); _paddleTwo.SetScreenSize(viewPortWidth, viewPortHeight); _paddleTwo.AddUpKeys(Keys.Up); _paddleTwo.AddDownKeys(Keys.Down); _paddleTwo.AddBoostKeys(Keys.Left); //_paddleTwo.AddRotateKeys(Keys.Right); _paddleTwo.Initialize(); _boost1Texture = new Texture2D(GraphicsDevice, _boost1Width, _boost1Height); Color[] boost1ColorData = new Color[_boost1Width * _boost1Height]; for (int i = 0; i < _boost1Width * _boost1Height; i++) { boost1ColorData[i] = Color.Blue; } _boost1Texture.SetData(boost1ColorData); _boost2Texture = new Texture2D(GraphicsDevice, _boost2Width, _boost2Height); Color[] boost2ColorData = new Color[_boost2Width * _boost2Height]; for (int i = 0; i < _boost2Width * _boost2Height; i++) { boost2ColorData[i] = Color.CornflowerBlue; } _boost2Texture.SetData(boost2ColorData); base.Initialize(); UpdateGameSpeed(_gameSpeed); }