hello, I have a question about my snake game I have the code below, but its not working well at all.. the snake ´repeats´ himself every 256 pixels and I can´t seem to get the bounds right. Can someone help me? The code is in full below.
Code:
Public Class Form1
    Dim m As Integer = 4
    Dim p(m) As Point
    Dim k As Keys = Keys.Right


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Dim b As New Bitmap(256, 256)
        Dim g As Graphics = Graphics.FromImage(b)
        If k = Keys.Left And p(m).X >= Me.Bounds.Left Then
            p(m).X -= 16
        End If
        If k = Keys.Right And p(m).X <= Me.Bounds.Left Then
            p(m).X += 16
        End If
        If k = Keys.Up And p(m).Y >= Me.Bounds.Left Then
            p(m).Y -= 16
        End If
        If k = Keys.Down And p(m).Y <= Me.Bounds.Left Then
            p(m).Y += 16
        End If
        For i As Integer = 0 To m - 1
            p(i) = p(i + 1)
            g.FillRectangle(Brushes.Black, New Rectangle(p(i), New Size(16, 16)))
        Next
        g.FillRectangle(Brushes.Black, New Rectangle(p(m), New Size(16, 16)))
        g.Dispose()
        Me.BackgroundImage = b
        Me.Refresh()
        Me.ClientSize = b.Size
        Me.Refresh()
    End Sub

    Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.Left Then
            k = Keys.Left
        End If
        If e.KeyCode = Keys.Right Then
            k = Keys.Right
        End If
        If e.KeyCode = Keys.Up Then
            k = Keys.Up
        End If
        If e.KeyCode = Keys.Down Then
            k = Keys.Down
        End If
    End Sub