示例#1
0
文件: Form1.cs 项目: annuciis/Pacman
        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();
            }
        }
示例#2
0
文件: Form1.cs 项目: annuciis/Pacman
 private void GameOver()
 {
     TimerMain.Stop();
     TimerPacman.Stop();
     PlaySound("game_over.wav");
     MessageBox.Show("GAME OVER");
     Application.Restart();
     Environment.Exit(0);
 }