protected override void Initialize() { height = graphics.GraphicsDevice.Viewport; height.Height = 800; graphics.GraphicsDevice.Viewport = height; this.graphics.PreferredBackBufferHeight = 800; this.graphics.ApplyChanges(); ball_1 = new Ball(new Vector2(400, 400), // init Position 2, // Speed multi, multiplies final speed vector // after all other modifications in the game lifetime new Vector2(1, 1)); // init Direction ball_2 = new Ball(new Vector2(400, 400), 2, new Vector2(1, 1)); paddle = new Paddle(this.graphics); theBrick_Manager = new Brick_Manager(this.graphics); theScore_Manager = new Score_Manager(this.graphics); theMenu_Manager = new Menu_Manager(this.graphics); // Initializing audio objects theAudioEngine = new AudioEngine("Content\\Audio\\Breakout_Audio.xgs"); theWaveBank = new WaveBank(theAudioEngine, "Content\\Audio\\Wave Bank.xwb"); theSoundBank = new SoundBank(theAudioEngine, "Content\\Audio\\Sound Bank.xsb"); theMusic_Manager = new Music_Manager(); gameover = false; base.Initialize(); }
/// <summary> /// Determines if ball hit top wall and shrinks the paddle by 1/3. /// </summary> /// <param name="graphics"></param> /// <param name="ball"></param> /// <param name="paddle"></param> public static void upperWallHit_shrink(GraphicsDeviceManager graphics, Ball ball, Paddle paddle) { if (paddle.isNotShrunk) { if (ball.Prev_Pos_min.Y < 0) // Top border check { paddle.set_Scale(new Vector2(paddle.get_Scale().X * 0.333f, 1)); // 0.333f = 1/3 scale paddle.isNotShrunk = false; // Shrinking only happens once, subsequent top wall colisions will no shrink it further } } }