Beispiel #1
0
        // checking collision
        public void checkCollision()
        {
            //checks if rectangles intersect
            if (pacman.Intersect(ghost) || pacman.Intersect(ghost2))
            {
                //checks LiveInfoEventArgs to see how many lives are left
                LiveInfoEventArgs CurrentLives = new LiveInfoEventArgs(lives);
                OnLiveChanged(CurrentLives);
                lives -= 1;

                //resets pacman to the starting position
                death.Play();

                pacman.Position = new Point(21, 13);

                //restarts the timer
                pacmanTimer.Start();
            }
        }
Beispiel #2
0
        protected virtual void OnLiveChanged(LiveInfoEventArgs e)
        {
            int value;

            if (LivesChanged != null)
            {
                LivesChanged(this, e);
            }
            this.RemainingLivesTextBox.Text = e.lives.ToString();

            if (Int32.TryParse(RemainingLivesTextBox.Text, out value))
            {
                if (value < 1)
                {
                    LoseDisplay loser = new LoseDisplay();
                    loser.Show();
                }
            }
        }