when i start the program the snake shold move but is dosent and i dont know why!
Public Class Form1
#Region "Snake"
Dim snake(1000) As PictureBox
Dim comprimento_da_cobra As Integer = -1
Dim esquerda_direita As Integer = 0
Dim cima_baixo As Integer = 0
Dim r As Random
Private Sub cabeça()
comprimento_da_cobra += 1
snake(comprimento_da_cobra) = New PictureBox
With snake(comprimento_da_cobra)
.Height = 10
.Width = 10
.BackColor = Color.Black
.Top = (pb1.Top + pb1.Bottom) / 2
.Left = (pb1.Left + pb1.Right) / 2
End With
Me.Controls.Add(snake(comprimento_da_cobra))
snake(comprimento_da_cobra).BringToFront()
End Sub
Private Sub Form1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Me.KeyPress
Select Case e.KeyChar
Case "d"
esquerda_direita = 10
cima_baixo = 0
Case "a"
esquerda_direita = -10
cima_baixo = 0
Case "w"
esquerda_direita = 0
cima_baixo = 10
Case "s"
esquerda_direita = 0
cima_baixo = -10
End Select
End Sub
Private Sub tsnake_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
snake(0).Top += cima_baixo
snake(0).Left += esquerda_direita
End Sub
#End Region
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
cabeça()
Timer1.Start()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
End Sub
End Class
this is the code
and the grafic code is
<global.microsoft.visualbasic.compilerservices.designergenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<system.diagnostics.debuggernonusercode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<system.diagnostics.debuggerstepthrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.pb1 = New System.Windows.Forms.PictureBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Button1 = New System.Windows.Forms.Button()
Me.Label6 = New System.Windows.Forms.Label()
Me.Label7 = New System.Windows.Forms.Label()
Me.Button2 = New System.Windows.Forms.Button()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
CType(Me.pb1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'pb1
'
Me.pb1.BackColor = System.Drawing.Color.White
Me.pb1.Location = New System.Drawing.Point(22, 22)
Me.pb1.Name = "pb1"
Me.pb1.Size = New System.Drawing.Size(750, 358)
Me.pb1.TabIndex = 0
Me.pb1.TabStop = False
Me.pb1.WaitOnLoad = True
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(612, 423)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(51, 15)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Pontos"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(31, 401)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(112, 24)
Me.Label2.TabIndex = 2
Me.Label2.Text = "Instruçoes:"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 72.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(201, 410)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(375, 108)
Me.Label3.TabIndex = 3
Me.Label3.Text = "SNAKE"
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button1.Location = New System.Drawing.Point(643, 476)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(129, 48)
Me.Button1.TabIndex = 5
Me.Button1.Text = "Começar"
Me.Button1.UseVisualStyleBackColor = True
'
'Label6
'
Me.Label6.BackColor = System.Drawing.Color.White
Me.Label6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Label6.Location = New System.Drawing.Point(687, 410)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(85, 28)
Me.Label6.TabIndex = 7
'
'Label7
'
Me.Label7.BackColor = System.Drawing.Color.Red
Me.Label7.Location = New System.Drawing.Point(32, 425)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(76, 50)
Me.Label7.TabIndex = 8
Me.Label7.Text = "Teclas W,S,A,D para mover"
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.Location = New System.Drawing.Point(14, 478)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(129, 46)
Me.Button2.TabIndex = 9
Me.Button2.Text = "Sair"
Me.Button2.UseVisualStyleBackColor = True
'
'Timer1
'
Me.Timer1.Enabled = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.Red
Me.ClientSize = New System.Drawing.Size(789, 546)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.pb1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.pb1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents pb1 As System.Windows.Forms.PictureBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Timer1 As System.Windows.Forms.Timer
End Class