public void checkIfHit(Player p, Form f) //collision detection method { if (p.GetPictureBox().Bounds.IntersectsWith(inv.Bounds) && p.GetPictureBox().Visible) { inv.Visible = false; p.GetPictureBox().Visible = false; Game_Over frm1 = new Game_Over(); frm1.Show(); } } // end of checkIfHit method
private void timer1_Tick(object sender, EventArgs e) { swa.move(); //this allows the swarm to move bul.move(); //this allows the bulelt to move swa.checkIfHit(bul, this); //this checks is the bullet hits the swarm swa.checkIfHit(p, this); // this checks if teh swarm hits the player shotsLbl.Text = ("You've fired " + firedcount); //this tracks the shots fired scoreLbl.Text = ("Your score " + score); //this checks the score based on the aliens defeated if (InvadersC == 0) //if all on screen invaders are now invisible and none are left, press space to progress to the next sceen (game over screen) { label1.Visible = false; timer1.Stop(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"Scores.txt", true)) { file.WriteLine(("\n") + Score); //this writes the game score to Scores.txt } this.Hide(); Game_Over frm1 = new Game_Over(); //this hides the current form and allows the next form to show the game over screen frm1.Show(); } }