private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { this.Close(); } //Press escape to quit if (e.KeyCode == Keys.F1) //Reload the game { ball.Top = 50; ball.Left = 50; speed_left = 4; speed_top = 4; point = 0; points.Text = "0"; timer1.Enabled = true; gameOver_label.Visible = false; //Hides the game over text label playground.BackColor = Color.White; //reassigns the background color plays++; //increments the number of games played Player turn = new Player(); //instantiate a new Player class turnCount.Text = turn.ComputeTurns(plays); //send the updated turns to ComputeTurns method turnCount.Visible = false; //Hides the turn count highestScore_label.Visible = false; //Hides the high score user_label.Visible = false; //Hides the player name user_label this.racket.Size = new System.Drawing.Size(200, 20); //reset racket size this.ball.Image = global::PongGame.Properties.Resources.ball1; //reset ball image this.pictureBox1.Visible = false; //Hides picturebox fakeButton.Visible = false; //HidesFake botton } }
private int plays; //Number of turns #endregion Fields #region Constructors public Form1() { InitializeComponent(); timer1.Enabled = true; Cursor.Hide(); //Hides the cursor plays = 1; Player turn = new Player(); turnCount.Text = turn.ComputeTurns(plays); this.FormBorderStyle = FormBorderStyle.None; //removes any border this.TopMost = true; //Brings the form to the front this.Bounds = Screen.PrimaryScreen.Bounds; //Makes it fullscreen racket.Top = playground.Bottom - (playground.Bottom / 10); //set the position of the racket gameOver_label.Left = (playground.Width / 2) - (gameOver_label.Width / 2); //Centers the label gameOver_label.Top = (playground.Height / 2) - (gameOver_label.Height / 2); gameOver_label.Visible = false; //Hides the game over highestScore_label.Visible = false; turnCount.Visible = false; //Hides the turn count }