private void Game_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right) { PlaySound("pacman_move.wav"); } if (e.KeyCode == Keys.Up) { verVelocity = -heroSpeed; horVelocity = 0; direction = "up"; } else if (e.KeyCode == Keys.Down) { verVelocity = heroSpeed; horVelocity = 0; direction = "down"; } else if (e.KeyCode == Keys.Left) { verVelocity = 0; horVelocity = -heroSpeed; direction = "left"; } else if (e.KeyCode == Keys.Right) { verVelocity = 0; horVelocity = heroSpeed; direction = "right"; } else if (e.KeyCode == Keys.P) { if (gamePaused) { TimerMain.Start(); TimerPacman.Start(); gamePaused = false; ScoreLabel.Text = "Score: " + score.ToString(); } else { TimerMain.Stop(); TimerPacman.Stop(); gamePaused = true; ScoreLabel.Text = "Game Paused..."; } } else if (e.KeyCode == Keys.T) { SaySomething("Cool"); } else if (e.KeyCode == Keys.C) { ShowCoordinates(); } }
private void InitilizeTimers() { TimerMain.Interval = 10; TimerMain.Start(); TimerAnimateGhost.Interval = 300; TimerAnimateGhost.Start(); TimerPacman.Interval = 100; TimerPacman.Start(); }