private void GameScreen_KeyDown(object sender, KeyEventArgs e) { if (endGame) { } if (e.KeyCode == Keys.Q) { coinScore += 50; } else if (e.KeyCode == Keys.Space && !endGame && curntMech != "gravity") { if (grounded) // boost { grounded = false; jumping = true; up = true; } else if (!endGame) { up = true; } } else if (e.KeyCode == Keys.P && !endGame) { pausePopup rp = new pausePopup(); rp.Location = this.FindForm().Location; gameTimer.Enabled = false; DialogResult result = rp.ShowDialog(); if (result == DialogResult.Yes) { gameTimer.Enabled = true; backgroundMoveSpd = spdStorage; timeBtwnLasers = 120; coinScore -= 250; endGame = false; lasers.Clear(); } else if (result == DialogResult.No) { dist = 0; actualDist = 0; Refresh(); ShopScreen.switchS = true; Form1.switchScreen(this, "shop"); } } }
private void GameScreen_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Space && !endGame && curntMech != "gravity") // if space, jump on ground, or fly in air { if (grounded) // boost { grounded = false; jumping = true; up = true; } else if (!endGame) { up = true; } } else if (e.KeyCode == Keys.Escape && !endGame) //if pause button is pressed { pausePopup rp = new pausePopup(); rp.Location = this.FindForm().Location; gameTimer.Enabled = false; DialogResult result = rp.ShowDialog(); if (result == DialogResult.Yes) //if continuing { gameTimer.Enabled = true; } else if (result == DialogResult.No)// if quitting to shop { dist = 0; actualDist = 0; Refresh(); ShopScreen.switchS = true; Form1.switchScreen(this, "shop"); } music.Stop(); } }