private void CharacterSelect_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Right) { if (index < characters.Count - 1) { index++; } else { index = 0; } } if (e.KeyCode == Keys.Left) { if (index > 0) { index--; } else { index = 2; } } if (e.KeyCode == Keys.Space) { // Create an instance of the SecondScreen InstructionScreen cs = new InstructionScreen(); cs.Location = new Point(this.Left, this.Top); // Add the User Control to the Form Form f = this.FindForm(); f.Controls.Remove(this); f.Controls.Add(cs); cs.Focus(); } if (e.KeyCode == Keys.Escape) { // Create an instance of the SecondScreen MainScreen ms = new MainScreen(); ms.Location = new Point(this.Left, this.Top); // Add the User Control to the Form Form f = this.FindForm(); f.Controls.Remove(this); f.Controls.Add(ms); ms.Focus(); } if (e.KeyCode == Keys.M) { HighScoreScreen ms = new HighScoreScreen(); ms.Location = new Point(this.Left, this.Top); // Add the User Control to the Form Form f = this.FindForm(); f.Controls.Remove(this); f.Controls.Add(ms); ms.Focus(); } Refresh(); }
private void mainGame_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { imgStill = 0; if (e.KeyCode == Keys.Escape) { pause = true; if (brightness > 100) { backBrush.Color = Color.FromArgb(140, 0, 0, 0); backBrush2.Color = Color.FromArgb(120, 0, 0, 0); } timer1.Enabled = false; Refresh(); } if (!pause) { if (e.KeyCode == Keys.Right && !fart) { right = true; } if (e.KeyCode == Keys.Left && !fart) { left = true; } if (e.KeyCode == Keys.Space) { right = false; left = false; fart = true; Form1.fartSound.Play(); } } else { if (e.KeyCode == Keys.Space) { pause = false; timer1.Enabled = true; Refresh(); } if (e.KeyCode == Keys.M) { // Create an instance of the SecondScreen Form1.mainGameMusic.Stop(); Form1.titleMusic.PlayLooping(); MainScreen cs = new MainScreen(); cs.Location = new Point(this.Left, this.Top); // Add the User Control to the Form Form f = this.FindForm(); f.Controls.Remove(this); f.Controls.Add(cs); cs.Focus(); } } if (brightness < 245) { if (e.KeyCode == Keys.B) { brightness += 10; } } if (brightness > 12) { if (e.KeyCode == Keys.M) { brightness -= 10; } } //gameOver if (e.KeyCode == Keys.G) { // Create an instance of the SecondScreen loseScreen cs = new loseScreen(); cs.Location = new Point(this.Left, this.Top); // Add the User Control to the Form Form f = this.FindForm(); f.Controls.Remove(this); f.Controls.Add(cs); cs.Focus(); } }