Maze3 - PacMan

Before you begin this project, copy and paste your whole Maze2 project folder and rename the outer folder from Maze2 to Maze3. (DO NOT RENAME any of the files within the project folder.) Watch this video to learn how to begin this assignment and add .wav sound files to the project.

Extend the Maze2 project by

  • creating a picture box that represents a ghost (such as picEnemy1).

  • Also, create a timer object (such as tmrEnemy1).

  • In the tmrEnemy1_Tick method, the ghost must chase after the player as he/she moves around the maze. Unlike the real PacMan arcade game though, the ghost may go through the walls of the maze to catch the player. If the ghost collides with the player though, an appropriate sound clip, such as pacmandying.wav, must play with the PlaySound method and the game must reset with the player and ghost returning to their original positions (and resetting the game timer which is mentioned below.) Make sure this timer's Enabled property is set to True.

  • Create another timer object (tmrGameTimer) and using its Tick method you must display the time remaining (in seconds) in a label (lblTime) that you placed somewhere on the form. Gives the player 60 or so seconds to complete the maze. If this game timer expires, reset the player and the ghost to their original positions and reset the game timer. The game timer should immediately count down again for the player's second attempt through the maze. Make sure this timer's Enabled property is set to True and that its Interval property is set to 1000 (i.e. 1000 milliseconds which equals 1 second.)

  • When the game initially loads or at some other point in the game, the computer's voice should greet the player with a suitable greeting message using the text-to-speech Speak method.

  • Add a passageway on one of the four outer boundaries of the maze that allows the player to go off the maze on that side and come into the maze through another passageway on one of the other sides and vice versa. You will have to modify one or more of your DrawLine statements in your Form1_Paint method and the ElseIf clauses in our Form1_KeyDown to create these two passageways.

You may edit, change, or redesign the walls of the maze that you used in Maze2 or you can even design a whole new interface on graph paper if you would like. You may choose a new starting point for your player and you may start the ghost anywhere on the form. You may adjust the speeds of the player (changing the amount of pixels that picPlayer moves each time the arrow key is pressed) and/or ghost (changing the number of pixels it moves on each Tick method or its Timer's Interval property) to make the program challenging. Don't forget to set the Enabled properties of your timers to True in order for them to work when the game begins.

Extra Credit - I don't recommend working on extra credit options until you've completed the specs above!

  • make the player bounce off the walls instead of colliding with them and being reset to the beginning of the maze.
  • make the ghost stay within the walls of the maze as it chases the player.
  • add more than one ghost.
  • add a string of 5 or more power pills and display the number of power pills that the player ate so far in a score label.

Your program must follow the Visual Basic Coding Standards. Review the Program Check Off list.

Upload the following files to the location specified by the instructor. Your first name and last initial should replace "JohnD" in the filenames.

  • a screen capture graphic named Maze3JohnD.png.
  • a pdf of your source code named Maze3JohnD.pdf.
  • a screencast video named Maze3JohnD.mp4. You should record audio with this screencast. Be sure that the video shows the player hitting a boundary, getting a caught by an enemy, going through the passageway (both directions), and reaching the end of the maze.
  • the interface sketch of your maze created with the graph paper template in Notability or a carefully cropped picture or scan of a your paper interface sketch. This file must be named Maze3SketchJohnD.png or Maze3SketchJohnD.pdf

Examples of former students' projects. Click on a graphic to watch the game:

2014: ErinS, RicardoA, GioM, ShelbyT
2013: Jocelyn D, Rohan R, Fabrizio F, Charlie T, Cassidy K, Amber S, Danielle S, Jack M, Sonia S, Mara T, Mikayla A

Objects
picPlayer
picGhost
tmrGhost
tmrGameTimer
lblTime
MenuStrip1
mnuFile
mnuFileReset
mnuFileExit


Methods
Form1_Paint - draws maze
Form1_KeyDown - moves player, checks for collisions between player & walls of maze, win detection
tmrGhost_Tick - moves ghost, checks for collisions between player & ghost
GameReset - resets player, ghost, & game timer
tmrGameTimer_Tick - shows elapsed time, resets game when time expires
Form1_Load - plays text-to-speech greeting message
mnuFileReset - resets game
mnuFileExit - ends program

Pseudocode for moving the ghost in the 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 the tmrGhost_Tick method:

' 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

' collision detection between ghost and player
If (picPlayer.Bounds.IntersectsWith(picGhost.Bounds)) Then
   PlaySound("pacmandying.wav", 0, 1)

   GameReset()
End If