' John Doe ' Maze1 ' Per ? Public Class Form1 ' constants Const STARTING_X As Integer = 10 ' x coordinate of player's start position Const STARTING_Y As Integer = 12 ' y coordinate of player's start position ' display instructions & reset player Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Setup() End Sub ' draws maze Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.DrawLine(Pens.Black, 2, 2, 300, 2) ' top boundary e.Graphics.DrawLine(Pens.Black, 2, 300, 300, 300) ' bottom boundary e.Graphics.DrawLine(Pens.Black, 2, 2, 2, 300) ' left boundary e.Graphics.DrawLine(Pens.Black, 300, 2, 300, 300) ' right boundary ' horizontal lines e.Graphics.DrawLine(Pens.Black, 2, 40, 260, 40) ' line 1 e.Graphics.DrawLine(Pens.Yellow, 40, 110, 260, 110) ' line 2 e.Graphics.DrawLine(Pens.Red, 80, 150, 300, 150) ' line 3 ' vertical lines e.Graphics.DrawLine(Pens.Orange, 40, 110, 40, 300) ' line 4 e.Graphics.DrawLine(Pens.Cyan, 80, 150, 80, 300) ' line 5 e.Graphics.DrawLine(Pens.White, 260, 40, 260, 110) ' line 6 ' identifying start & finish e.Graphics.DrawString("Start", New Font("Arial", 8), Brushes.Black, 15, 15) e.Graphics.DrawString("Finish", New Font("Arial", 8), Brushes.Black, 42, 280) End Sub ' exit or reset the application Private Sub Form1_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick If (e.Button = Windows.Forms.MouseButtons.Right) Then ' exit application on right-click Application.Exit() ElseIf (e.Button = Windows.Forms.MouseButtons.Left) Then ' reset player on left-click picPlayer.Left = STARTING_X picPlayer.Top = STARTING_Y End If End Sub ' moves player through maze when user double clicks the form Private Sub Form1_DoubleClick(sender As Object, e As System.EventArgs) Handles Me.DoubleClick For J = 1 To 26 ' to the right - hallway A picPlayer.Left += 10 Me.Refresh() Threading.Thread.Sleep(50) Next For J = 1 To 11 ' down the screen - hallway B picPlayer.Top += 10 Me.Refresh() Threading.Thread.Sleep(50) Next For J = 1 To 22 ' to the left - hallway C picPlayer.Left -= 10 Me.Refresh() Threading.Thread.Sleep(50) Next For J = 1 To 15 ' down the screen - hallway D picPlayer.Top += 10 Me.Refresh() Threading.Thread.Sleep(50) Next End Sub ' set up game and player Private Sub Setup() Me.Text = "Maze" ' displaying instructions in form's title bar picPlayer.Left = STARTING_X ' starting position of player picPlayer.Top = STARTING_Y Me.Width = 320 ' setting desired size of form window since it Me.Height = 340 ' is not exactly 300 by 300 Me.BackColor = Color.FromArgb(200, 0, 200) ' setting background to custom shade of purple End Sub ' display instructions Private Sub lblInstructions_MouseEnter(sender As Object, e As System.EventArgs) Handles lblInstructions.MouseEnter lblInstructions.Text = "GO double-click" + vbCrLf + "RESET left-click" + vbCrLf + "EXIT right-click" End Sub ' hide instructions Private Sub lblInstructions_MouseLeave(sender As Object, e As System.EventArgs) Handles lblInstructions.MouseLeave lblInstructions.Text = "Instructions" End Sub End Class