Maze2

Download and unzip this Maze2 Starter Project as a starting point. Here is the source code for that starter version.

Write a program that allows the user to move a PictureBox object through a maze with the arrow keys on the keyboard. The maze must contain at least 10 horizontal and vertical lines drawn using the Drawline method. It is not recommended that you add any diagonal or curved lines since collision detection with those types of lines is very difficult. (However, you may find hints or algorithms for that logic in our lecture notes or website.) You may use the same interface from a previous maze assignment and simply copy and paste the DrawLine statements or create a new maze. Either way, the maze must be accurately drawn with labelled endpoints on graph paper BEFORE you begin to write code. Your maze should be contained within the region illustrated by this model.

Identify an area as the end of the maze and make sure that the PictureBox begins at a designated beginning area. If the PIctureBox touches a boundary of the maze or a wall within the maze, automatically reposition it to the beginning of the maze. If the user successfully navigates to the end of the maze, display a MessageBox or update a Label indicating that he/she finished the maze and then reset his/her position to the beginning. You must also allow the user to reset the PictureBox to the beginning for a new game when he/she single clicks the mouse. Allow the user to exit the game by right-clicking.

You must use create and reuse a method named GameReset. Call that method where appropriate.

Here are some examples of former students' projects though some of them do not follow all of the specs above: RobertM GioM EmilyW JohnB ElvisD

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

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

  • a screen capture graphic named Maze2JohnD.png.
  • a pdf of your source code named Maze2JohnD.pdf.
  • a screencast video named Maze2JohnD.mp4. Do not record audio with this screencast. Be sure that the video shows the player hitting an outer boundary as well as a wall and being reset to the beginning. The video must show the user intentionally clicking to reset the player. The video must show the player winning the maze by reading the end. Finally the video must show the player right-clicking to end the program.
  • 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 Maze2SketchJohnD.png or Maze2SketchJohnD.pdf

 

 

You may wish to copy and paste the ElseIf clauses below and then replace the words IN_ALL_CAPS with numeric coordinates from your maze interface graph paper. The message in the MessageBox's should be customized for each specific line for debugging purposes but then edited to something generic like "You lost."

You must also figure out how to add an If statement that detects if the player reaches the end of the maze.

          


' collision detection between player & horizontal walls
             
If (picPlayer.Top < Y_COORDINATE And picPlayer.Bottom > Y_COORDINATE And picPlayer.Right > LEFT_END_POINT And picPlayer.Left < RIGHT_END_POINT) Then      ' line 1
   MessageBox.Show("collision with line 1") ' temporary debugging statement
   GameReset()
ElseIf (picPlayer.Top < Y_COORDINATE And picPlayer.Bottom > Y_COORDINATE And picPlayer.Right > LEFT_END_POINT And picPlayer.Left < RIGHT_END_POINT) Then  ' line 2
   MessageBox.Show("collision with line 2") ' temporary debugging statement
   GameReset()
End If



' collision detection between player & vertical walls
             
If (picPlayer.Right > X_COORDINATE And picPlayer.Left < X_COORDINATE And picPlayer.Bottom > TOP_END_POINT And picPlayer.Top < BOTTOM_END_POINT) Then       ' line 3
   MessageBox.Show("collision with line 3") ' temporary debugging statement
   GameReset()
ElseIf (picPlayer.Right > X_COORDINATE And picPlayer.Left < X_COORDINATE And picPlayer.Bottom > TOP_END_POINT And picPlayer.Top < BOTTOM_END_POINT) Then   ' line 4
   MessageBox.Show("collision with line 4") ' temporary debugging statement
   GameReset()
End If