Maze3 - PacMan

In addition to the specs for the Maze2 project, extend that project by creating a picture box that represents a ghost. Driven by a Timer object, the ghost must chase after the player as he/she moves around the maze. If the ghost collides with the player, an appropriate sound clip must play and the game must reset with the player and ghost returning to their original positions.

When the game initially loads, the computer's voice should greet the player with a suitable greeting message. Also, add a passageway to one side of the maze that allows the player to wrap around the screen going off one side and coming in on another side.

Give the player an updated "Time Left" message in the corner of the screen that gives him/her 60 seconds to complete the maze. If the time expires, reset the player and the ghost to their original positions and reset the game timer at 60 seconds. The should immediately count down again for the player's second attempt through the maze.

For extra credit, make the collision detection between the player and ghost work if the player and ghost barely touch each other rather than if the ghost is completely inside the player.
For extra credit, make the ghost stay within the walls of the maze as it chases the player.
For extra credit, make the player bounce off the walls instead of colliding with them and being reset to the beginning of the maze.
For extra credit, add more than one ghost.
For extra credit, add a string of 5 or more power pills and keep track and display the number of power pills that the player ate.

Before you begin this project, copy and paste your whole Maze2 project folder and rename the outer folder from Maze2 to Maze3. (The project itself insider of the outer folder will still be named Maze2.)

Preconditions:

  • The user will not attempt to cheat.

Your program must follow standard Windows conventions as well as our school's Visual Basic Coding Standards.

Staple your printouts in the following order:

  1. VB code
  2. The screen capture of your actual form window at runtime.

Objects
picPlayer
picGhost
tmrGhost
tmrGameTimer
lblTime
msMain
mnuFile
mnuFileReset
mnuFileExit

Pseudocode for tmrGhost_Tick method:
if ghost's left < player's left then move ghost right
if ghost's right > player's right then move ghost left
if ghost's bottom > player's bottom then move ghost up
if ghost's top < player's top then move ghost down
if ghost and player collide (i.e. if ghost is inside of player) then reset player & ghost & the game timer

Code for moving the ghost to catch the player:

' ghost moves left to catch the player
If (picGhost.Left < picPlayer.Left) Then
   picGhost.Left += 1
End If

' ghost moves right to catch the player
If (picGhost.Right > picPlayer.Right) Then
   picGhost.Left -= 1
End If

' ghost moves up to catch the player
If (picGhost.Bottom > picPlayer.Bottom) Then
   picGhost.Top -= 1
End If

' ghost moves down to catch the player
If (picGhost.Top < picPlayer.Top) Then
   picGhost.Top += 1
End If

Code for collision detection:

' collision detection between ghost and player
' if ghost is inside of player
' this assumes that the ghost's PictureBox is smaller
' than the player's PictureBox
If (picGhost.Left >= picPlayer.Left And picGhost.Right <= picPlayer.Right And picGhost.Top >= picPlayer.Top And picGhost.Bottom <= picPlayer.Bottom) Then
   PlaySound("pacmandying.wav", 0, 1)
   mintTimeAllowed = 60

   ' reset the ghost
   picGhost.Left = 150
   picGhost.Top = 150

   ' reset the player
   picPlayer.Left = 50
   picPlayer.Top = 50
End If