//Form Load Event
 private void Form1_Load(object sender, EventArgs e)
 {
     //Starting the timer and initalising the tick event for the first time
     TimerMain.Start();
     TimerMain_Tick(null, null);
     UpdateUpTime();
 }
Exemple #2
0
        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();
            }
        }
Exemple #3
0
 private void GameOver()
 {
     TimerMain.Stop();
     TimerPacman.Stop();
     PlaySound("game_over.wav");
     MessageBox.Show("GAME OVER");
     Application.Restart();
     Environment.Exit(0);
 }
Exemple #4
0
        private void InitilizeTimers()
        {
            TimerMain.Interval = 10;
            TimerMain.Start();

            TimerAnimateGhost.Interval = 300;
            TimerAnimateGhost.Start();

            TimerPacman.Interval = 100;
            TimerPacman.Start();
        }
Exemple #5
0
        public FormMain()
        {
            Form mainPanel = this;

            this.DoubleBuffered   = true;
            mainPanel.MouseWheel += _MouseWheel;
            mainPanel.Click      += _MouseClick;
            mainPanel.MouseDown  += _MouseDown;
            mainPanel.MouseUp    += _MouseUp;
            mainPanel.MouseMove  += _MouseMove;
            InitializeComponent();
            TimerMain.Tick += _GameTimerTick;
            TimerMain.Start();
        }
Exemple #6
0
        private void SetRunning(bool running)
        {
            if (running)
            {
                //tSec = DateTime.Now.Second;
                lastTime = DateTime.Now;
                TimerMain.Start();
                StartBtn.Text = "Stop";
            }
            else
            {
                flash = false;
                ended = false;

                BackPanel.BackColourName = "FormColour";
                Theme.ChangeControl(BackPanel);

                TimerMain.Stop();
                StartBtn.Text = "Start";
            }

            CheckReset();
        }