still playing with that nibbles game, i've got the snake moving around the window and getting longer when it hits the number that's randomly placed on the screen
but what i need to do is have it checking with every move (everytime the tick event fires) to see if the snake's crossed it's own path
this is what i currently have (of which it doesnt seem to work)
but what i need to do is have it checking with every move (everytime the tick event fires) to see if the snake's crossed it's own path
this is what i currently have (of which it doesnt seem to work)
VB.NET:
'tmrTimer.Interval = 50 btw
Private blnSnakeCrossed As Boolean = False
Private Sub tmrTimer_Tick(...) Handles tmrTimer.Tick
blnSnakeCrossed = CheckSnake()
If blnSnakeCrossed = True Then tmrTimer.Enabled = False
End Sub
Private Function CheckSnake() As Boolean
Dim intCounter As Integer
'I do need the counter to start at 2 instead of 0 as the first two items is picDot and lblNumber
For intCounter = 2 To Me.Controls.Count - 1
If TypeOf (Me.Controls(intCounter)) Is PictureBox Then
If picDot.Top = CType(Me.Controls(intCounter), PictureBox).Top And picDot.Left = CType(Me.Controls(intCounter), PictureBox).Left Then
Return True
Else
Return False
End If
End If
Next
End Function