/// <summary> /// Draws the gameplay screen. /// </summary> public override void Draw(GameTime gameTime) { // draw the background as blakc ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 0, 0); SpriteBatch spriteBatch = ScreenManager.SpriteBatch; spriteBatch.Begin(); //draws each brick foreach (Bricks brick in bricks) { brick.Draw(spriteBatch); } //draw the players lives and scores at the top of the screen spriteBatch.DrawString(gameFont, "Player 1 Lives: " + p1lives.ToString(), new Vector2(10, 0), Color.Blue); spriteBatch.DrawString(gameFont, "Player 1 Score: " + p1score.ToString(), new Vector2(350, 0), Color.Blue); spriteBatch.DrawString(gameFont, "Player 2 Lives: " + p2lives.ToString(), new Vector2(700, 0), Color.Pink); spriteBatch.DrawString(gameFont, "Player 2 Score: " + p2score.ToString(), new Vector2(1050, 0), Color.Pink); //checks which player has one the game if its p2 display p2 score and that p2 has one if (p1lives == 0 || p2lives == 0 && p2score > p1score) { spriteBatch.DrawString(gameFont, "GAME OVER P2 Wins", new Vector2(255, 300), Color.HotPink, MathHelper.ToRadians(0), new Vector2(0, 0), 3.5f, SpriteEffects.None, 0); spriteBatch.DrawString(gameFont, "Score: " + p2score, new Vector2(255, 400), Color.HotPink, MathHelper.ToRadians(0), new Vector2(0, 0), 3.5f, SpriteEffects.None, 0); } if (p1lives == 0 || p2lives == 0 && p1score > p2score) { spriteBatch.DrawString(gameFont, "GAME OVER P1 Wins", new Vector2(255, 300), Color.HotPink, MathHelper.ToRadians(0), new Vector2(0, 0), 3.5f, SpriteEffects.None, 0); spriteBatch.DrawString(gameFont, "Score: " + p1score, new Vector2(255, 400), Color.HotPink, MathHelper.ToRadians(0), new Vector2(0, 0), 3.5f, SpriteEffects.None, 0); } //draw the bats and ball P1bat.Draw(spriteBatch, Color.Red); P2bat.Draw(spriteBatch, Color.Blue); ball.Draw(spriteBatch); spriteBatch.End(); // If the game is transitioning on or off, fade it out to black. if (TransitionPosition > 0 || pauseAlpha > 0) { float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2); ScreenManager.FadeBackBufferToBlack(alpha); } }
/// <summary> /// Draws the gameplay screen. /// </summary> public override void Draw(GameTime gameTime) { //draws a white background ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 0, 0); SpriteBatch spriteBatch = ScreenManager.SpriteBatch; spriteBatch.Begin(); //draw each brick foreach (Bricks brick in bricks) { brick.Draw(spriteBatch); } //draw the lives and score at the top of the screen spriteBatch.DrawString(gameFont, "Lives: " + lives.ToString(), new Vector2(10, 0), Color.Blue); spriteBatch.DrawString(gameFont, "Score: " + score.ToString(), new Vector2(170, 0), Color.Blue); // if the lives are =0 then draw gamemover and tell teh user their score if (lives == 0) { spriteBatch.DrawString(gameFont, "GAME OVER", new Vector2(255, 300), Color.HotPink, MathHelper.ToRadians(0), new Vector2(0, 0), 3.5f, SpriteEffects.None, 0); spriteBatch.DrawString(gameFont, "Score: " + score, new Vector2(255, 400), Color.HotPink, MathHelper.ToRadians(0), new Vector2(0, 0), 3.5f, SpriteEffects.None, 0); } //draw the bats and ball P1bat.Draw(spriteBatch, Color.Red); P2bat.Draw(spriteBatch, Color.Blue); ball.Draw(spriteBatch); spriteBatch.End(); // If the game is transitioning on or off, fade it out to black. if (TransitionPosition > 0 || pauseAlpha > 0) { float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2); ScreenManager.FadeBackBufferToBlack(alpha); } }