you have your ifs nested incorrectly.
The way you've got it now, the control has to start with "picturebox" to get to the check to see if it starts with "ghost". Obviously it will never start with ghost if it has to start with picturebox.Code:For Each myControl As Control In Me.Controls If TypeOf myControl Is PictureBox Then If Pacman.Bounds.IntersectsWith(myControl.Bounds) Then If myControl.Name.StartsWith("Wall") Then Pacman.Location = currentLocation ElseIf myControl.Name.StartsWith("PictureBox") Then If myControl.Visible = True Then myControl.Visible = False score = score + 1 Label1.Text = score ElseIf myControl.Name.StartsWith("Ghost") Then Pacman.Location = New Point(901, 83) End If End If End If End If Next
I haven't looked at all of your code, but this change SHOULD fix it...
Code:For Each myControl As Control In Me.Controls If TypeOf myControl Is PictureBox Then If Pacman.Bounds.IntersectsWith(myControl.Bounds) Then If myControl.Name.StartsWith("Wall") Then Pacman.Location = currentLocation ElseIf myControl.Name.StartsWith("PictureBox") Then If myControl.Visible = True Then myControl.Visible = False score = score + 1 Label1.Text = score end if ElseIf myControl.Name.StartsWith("Ghost") Then Pacman.Location = New Point(901, 83) End If End If End If Next




Reply With Quote