public Form1() { InitializeComponent(); for (int i = 0; i < 5; i++) // for each of the 5 seagulls (array used because it is more efficient than coding each one individually) { int y = 10 + (i * 165); // for the spacing between the seagulls we use an array to multiply the i integer for each seagull by 165 and add 10 to it so that then becomes their y coordinate on the panel seagull[i] = new Seagull(y); // for each seagull create and set the y coordiante just calculated } for (int i = 0; i < 6; i++) // for each of the 6 pieces of poo (array used because it is more efficient than coding 6 pieces of poo individually) { int x = 5 + (i * 270);; // for the spacing between the poo we use an array to multiply the i integer for each poo by 270 and add 5 to it so that then becomes their x coordinate on the panel poo[i] = new Poo(x); // for each poo create and set the x coordiante just calculated } for (int i = 0; i < 2; i++) // for each of the 2 planes (array used because it is more efficient than coding each one individually) { int y = (i * 380) + 90;; // for the spacing vertically between the plane we use an array to multiply the i integer for each plane by 380 and add 90 to it so that then becomes their y coordinate on the panel int x = (i * 2035) + 2040;; // for the spacing horizontally between the spacing we use an array to multiply the i integer for each seagull by 2035 and add 2040 to it so that then becomes their x coordinate on the panel plane[i] = new Plane(x, y); // for each plane create and set the y and x coordiante just calculated } typeof(Panel).InvokeMember("DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, pnlBruuva, new object[] { true });// this code is to stop the panel and everything in it from flickering creating a solid image for the user }
int score, lives, highscore, newhighscore; // create new integers called score, lives and highscore private void checkLives() { if (lives == 0)// if the lives are equal to 0 (all lives have been used up) { btnHighScores.Enabled = true; score = int.Parse(lblScore.Text); // score is eqaul to the number in the score label tmrDonkey.Enabled = false; // turn off donkey timer (stop donkey from moving) tmrSeagull.Enabled = false; // turn off seagull timer (stop seagulls from moving) tmrSeagull.Interval = 130; // set interval of seagull timer back to orginal value txtLives.Text = null; // clear lives textbox so user can re enter lives and play again tmrPoo.Enabled = false; // turn off poo timer (stop poo from moving) tmrPlane.Enabled = false; // turn off plane timer (stop planes from moving) txtLives.Enabled = true; // allow access to lives textbox so user can re enter lives and play again without having to re enter the game txtLives.Focus(); //direct user focus to the lives textbox mnuStart.Enabled = false; // don't allow user to play game when no lives are left Cursor.Show(); // show the mouse cursor whether mouse is moved or not if (score > highscore) // if the current score is greater than the high score { highscore = int.Parse(lblHighScore.Text); // display the high score in the high score textbox } MessageBox.Show("You died!\nReset your lives and click to start to play again", "Game Over!"); // show message to user alerting them that they have run out of lives and to play again, reset their lives for (int i = 0; i < 5; i++) // for each of the 5 seagulls (array used because it is more efficient than coding each one individually) { int y = 10 + (i * 165); // for the spacing between the seagulls we use an array to multiply the i integer for each seagull by 165 and add 10 to it so that then becomes their y coordinate on the panel seagull[i] = new Seagull(y); // for each seagull create and set the y coordiante just calculated } for (int i = 0; i < 6; i++) // for each of the 6 pieces of poo (array used because it is more efficient than coding 6 pieces of poo individually) { int x = 5 + (i * 270);; // for the spacing between the poo we use an array to multiply the i integer for each poo by 270 and add 5 to it so that then becomes their x coordinate on the panel poo[i] = new Poo(x); // for each poo create and set the x coordiante just calculated } for (int i = 0; i < 2; i++) // for each of the 2 planes (array used because it is more efficient than coding each one individually) { int y = (i * 380) + 90;; // for the spacing vertically between the plane we use an array to multiply the i integer for each plane by 380 and add 90 to it so that then becomes their y coordinate on the panel int x = (i * 2035) + 2040;; // for the spacing horizontally between the spacing we use an array to multiply the i integer for each seagull by 2035 and add 2040 to it so that then becomes their x coordinate on the panel plane[i] = new Plane(x, y); // for each plane create and set the y and x coordiante just calculated } } }