3. Maze Game With Scoring And Timers - VB Code Included!

Опубликовано: 06 Февраль 2026
на канале: CESOFTWARE
81,593
244

Final video of maze week, using a timer and scoring system to create a new more advanced maze game in visual basic!
Previous videos:
1.    • 1. Moving An Object With WSAD Keys in VB 2012  
2.    • 2. In Game Collisions With Picture Boxes a...  

code:


Public Class Form1
Dim score As Integer = 1000

Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown



If e.KeyCode = Keys.W Then
PictureBox1.Top = PictureBox1.Top - 3
End If

If e.KeyCode = Keys.A Then
PictureBox1.Left = PictureBox1.Left - 3

End If

If e.KeyCode = Keys.S Then
PictureBox1.Top = PictureBox1.Top + 3
End If
If e.KeyCode = Keys.D Then
PictureBox1.Left = PictureBox1.Left + 3
End If


If PictureBox1.Bounds.IntersectsWith(Lbl1.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18

score = score - 100

End If

If PictureBox1.Bounds.IntersectsWith(Lbl3.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl4.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl5.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl6.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl7.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl8.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl9.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl10.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl11.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl12.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl13.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl14.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl15.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl16.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl17.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl18.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl19.Bounds) Then

PictureBox1.Top = 84
PictureBox1.Left = 18
score = score - 100
End If
If PictureBox1.Bounds.IntersectsWith(Lbl20.Bounds) Then
score = score - 100
PictureBox1.Top = 84
PictureBox1.Left = 18

End If
If PictureBox1.Bounds.IntersectsWith(LblFinish.Bounds) Then

Timer1.Stop()

MsgBox("Your Score Is:" & " " & score)

End If



End Sub



Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Timer1.Start()

End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
score = score - 10
LblScore.Text = CStr(score)

If score = 0 Then
Timer1.Stop()

MsgBox("you loose")

End If
End Sub
End Class