private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Graphics g = e.Graphics; for (int i = 0; i < kNumberOfShields; i++) { Shields[i].Draw(g); } // g.FillRectangle(Brushes.Black, 0, 0, ClientRectangle.Width, ClientRectangle.Height); TheMan.Draw(g); TheScore.Draw(g); TheHighScore.Draw(g); displayLives.Draw(g); if (ActiveBullet) { TheBullet.Draw(g); } if (SaucerStart) { CurrentSaucer.Draw(g); } for (int i = 0; i < kNumberOfRows; i++) { TheInvaders = InvaderRows[i]; TheInvaders.Draw(g); } }
/// <summary> /// Draw the whole game /// </summary> /// <param name="g">Graphics to draw in</param> public void Draw(Graphics g) { if (currentState == GameState.Intro) { intro.Draw(g); } else if (currentState == GameState.Menu) { mainMenu.Draw(g); playerScore = new Score(); } else if (currentState == GameState.Play) { if (playerShip != null) { playerShip.Draw(g); playerScore.Draw(g); g.DrawString("Lives : " + playerShip.Lives, ethnocentric15, blackBrush, 2, 2); if (playerBonus != null) { playerBonus.Draw(g, gameSize.Height - 20, gameSize.Width - 20); } } if (playerMissile != null) { playerMissile.Draw(g); } if (bunkers != null) { foreach (Bunker b in bunkers) { b.Draw(g); } } if (enemyBlock != null) { enemyBlock.Draw(g); foreach (Missile m in missiles) { m.Draw(g); } } if (bonus.Count != 0) { foreach (Bonus b in bonus) { b.Draw(g); } } } else if (currentState == GameState.Pause) { g.DrawImage(space_invaders.Properties.Resources.pause, gameSize.Width / 2 - space_invaders.Properties.Resources.pause.Width / 2, gameSize.Height / 2 - space_invaders.Properties.Resources.pause.Height / 2); } else if (currentState == GameState.Lost) { if (lostScreen == null) { lostScreen = new Lost(); lostScreen.Draw(g); } else { lostScreen.Draw(g); if ((lostScreen.Position.y + lostScreen.imageHeight / 2) > gameSize.Height / 2) { playerScore.DisplayScore(lostScreen, g); lostScreen.Blink(); lostScreen.DisplayWinMenu(g); } } } else if (currentState == GameState.Win) { if (winScreen == null) { winScreen = new Win(); winScreen.Draw(g); } else { winScreen.Draw(g); if ((winScreen.Position.y + winScreen.imageHeight / 2) > Game.game.gameSize.Height / 2) { playerScore.DisplayScore(winScreen, g); winScreen.Blink(); winScreen.DisplayWinMenu(g); } } } }