} // end method gameTimer_Tick /*This method draws everything on the screen through the game's * draw method, and if the game's over, display the game * over screen.*/ private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; game.Draw(g, animationCounter); if (gameOver) { DrawGameOver(g); } // end if } // end method Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; if (gameOver) { using (Font font = new Font("Arial", 32, FontStyle.Bold)) { g.FillRectangle(Brushes.Black, ClientRectangle); var clientRectangleMiddle = new Point(ClientRectangle.Width / 2, ClientRectangle.Height / 2); g.DrawString(HeaderText, font, Brushes.Yellow, 20, clientRectangleMiddle.Y - 50); g.DrawString("Press S to start a new game or Q to quit", font, Brushes.White, 20, clientRectangleMiddle.Y + 50); } } else { game.Draw(g, animationCell); } }
} // end method gameTimer_Tick private void Form1_Paint(object sender, PaintEventArgs e) { // check gameover at some point. Graphics g = e.Graphics; game.Draw(g, animationCounter); if (gameOver) { string playAgain = "Press S to start a new game or Q to quit"; Font playAgainFont = new Font("Arial", 12); Font gameOverTopFont = new Font("Arial", 30, FontStyle.Bold); Point gameOverPoint = new Point((ClientRectangle.Width / 3), (ClientRectangle.Height / 2)); Point playAgainPoint = new Point(ClientRectangle.Width / 2, (int)((double)(ClientRectangle.Height * .9))); g.DrawString("GAME OVER!", gameOverTopFont, Brushes.Yellow, gameOverPoint); g.DrawString(playAgain, playAgainFont, Brushes.Yellow, playAgainPoint); } } // end method Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e) { Graphics graphics = e.Graphics; game.Draw(graphics, Frame, gameOver); }
private void Form1_Paint(object sender, PaintEventArgs e) { game.Draw(e.Graphics, cell); }