//Function to paint on the FORM (repaint also) private void Form1_Paint(object sender, PaintEventArgs e) { // Clear the screen e.Graphics.Clear(Color.White); // Set the Background BG.Draw(e.Graphics); // Set the upper Background BG1.Draw(e.Graphics); //Draw clouds foreach (cloud t in clouds) { t.Draw(e.Graphics); } //Draw the player Rockets for (int i = 0; i < playerPlane.getFiredRocekts().Count; i++) { playerPlane.getFiredRocekts()[i].Draw(e.Graphics); } //Draw Bullets for (int i = 0; i < playerPlane.getFiredBullets().Count; i++) { playerPlane.getFiredBullets()[i].Draw(e.Graphics); } //Check if the Boss Fight is taking place if (!BosFight) { //Draw enemy plain at last possition for (int i = 0; i < Planes.Count; i++) { Planes[i].Draw(e.Graphics); } //Draw "Bam picture" if a enemy plane has been destroyed if (Blast) { Blast = false; e.Graphics.DrawImage(Images.getWinImg(), xBam, yBam); } } //Draw the Boss and his Rockets else { boss.Draw(e.Graphics); foreach (Rocket r in bossRockets) { r.Draw(e.Graphics); } } //Check if the player is dead to draw the last image if (playerPlane.getPlayerLife() == 0) { e.Graphics.DrawImage(Images.getLoseImg(), playerPlane.getX(), playerPlane.getY()); } // Draw the player plane else { playerPlane.Draw(e.Graphics); } }
//Function to re-load the scene if we want to play again. public void Run() { // Get max Width and max height of the Form maxWidth = this.ClientSize.Width; maxHeight = this.ClientSize.Height; // Make the players playerPlane = new PlayerPlane(maxWidth, maxHeight); //Make enemy planes and fill the list Planes = new List <EnemyPlane>(); fillList(); //Make the Boss and his Rocket boss = new Boss(300, 20, this.ClientSize.Width); bossRockets = new List <Rocket>(); //Check if there is a boss on the screen BosFight = false; // Set the Backgounds [2 Backgrounds repeteng them selfs] BG = new BackGround(-764); BG1 = new BackGround(0); //Make Clouds on the screen clouds = new List <cloud>(); fillClouds(); // Set the buffer this.DoubleBuffered = true; // Set the Blast Image, Scores, Remaining lifes, Time left, and Boss HP bar Blast = false; Images = new BlastImages(); scoore = new HighScore(); ScoreLabel.Text = string.Format("High Score: {0}", scoore.getScore()); RemainingLifes.Text = string.Format("Player Lifes: {0}", playerPlane.getPlayerLife()); TimeLeft = 180; BosLife.Visible = false; BosLife.Value = boss.getLife(); //Set the sounds sounds = new Sounds(); sounds.playMainMusic(); //Get the timers Ready GameTimer.Enabled = true; PlayerTime.Enabled = true; }
//Function to re-load the scene if we want to play again. public void Run() { // Get max Width and max height of the Form maxWidth = this.ClientSize.Width; maxHeight = this.ClientSize.Height; // Make the players playerPlane = new PlayerPlane(maxWidth, maxHeight); //Make enemy planes and fill the list Planes = new List<EnemyPlane>(); fillList(); //Make the Boss and his Rocket boss = new Boss(300, 20, this.ClientSize.Width); bossRockets = new List<Rocket>(); //Check if there is a boss on the screen BosFight = false; // Set the Backgounds [2 Backgrounds repeteng them selfs] BG = new BackGround(-764); BG1 = new BackGround(0); //Make Clouds on the screen clouds = new List<cloud>(); fillClouds(); // Set the buffer this.DoubleBuffered = true; // Set the Blast Image, Scores, Remaining lifes, Time left, and Boss HP bar Blast = false; Images = new BlastImages(); scoore = new HighScore(); ScoreLabel.Text =string.Format("High Score: {0}",scoore.getScore()); RemainingLifes.Text =string.Format("Player Lifes: {0}",playerPlane.getPlayerLife()); TimeLeft = 180; BosLife.Visible = false; BosLife.Value = boss.getLife(); //Set the sounds sounds = new Sounds(); sounds.playMainMusic(); //Get the timers Ready GameTimer.Enabled = true; PlayerTime.Enabled = true; }