EDN Admin
Well-known member
Hey, im in year 11 and my major assignment for vb is due soon. i chose to create the old fashioned game snake... i have created the borders that sense when the snake hits an edge as its a panel... Most things are completed. the only things i need
to complete but cant figure out as im self teaching is, making it so that when the "snake" moves it stays as a set length. what i mean is that at the moment it keeps printing the snake image to the 10*10 picture box at a timer delay of (what ever my prefered
speed is) and just ends up making a drawing because its not deleting the back end of the snake. also when the snake eats the food (apple in this case) that it senses it and adds the amount of points a assign. and last thing... when the snake hits its body.
ending the game when it senses that it has hit itself...
any help is something i can put towards my learning.
thanks.
my important things to know is.<br/>
Dim boxes(35, 23) As PictureBox (**is my declared variable for the boxes**
Dim i, j As Integer **X,Y coordinates for boxes**
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br/>
<br/>
For i = 0 To 35<br/>
<br/>
For j = 0 To 23<br/>
<br/>
boxes(i, j) = New PictureBox<br/>
<br/>
boxes(i, j).SizeMode = PictureBoxSizeMode.StretchImage<br/>
<br/>
boxes(i, j).BorderStyle = BorderStyle.None<br/>
<br/>
<br/>
boxes(i, j).Top = 3 + (11 * j)<br/>
<br/>
boxes(i, j).Left = 3 + (11 * i)<br/>
<br/>
boxes(i, j).Height = 10<br/>
<br/>
boxes(i, j).Width = 10<br/>
<br/>
boxes(i, j).Visible = True<br/>
<br/>
<br/>
Panel1.Controls.Add(boxes(i, j))<br/>
<br/>
Next<br/>
<br/>
Next<br/>
<br/>
boxes(GetRandom(1, 35), GetRandom(1, 23)).Image = aple.Image **this is my random food generator for the start, just a test**<br/>
snake()<br/>
<br/>
BackColor = Color.Black<br/>
End Sub
this is my game code. once the game is started it loops through the panel and puts the picture boxes in the panel untill the for loop finishes...
snake() =
Private Sub snake()<br/>
<br/>
h = 0 **this is the starting position for the snake picture<br/>
v = 0<br/>
<br/>
boxes(h, v).Image = snke.Image<br/>
<br/>
rightt = True **this tells the game to start going in the "right" direction and this is a procedure i have created that tells the game which way to go once one of the arrow keys are pressed**<br/>
<br/>
End Sub
View the full article
to complete but cant figure out as im self teaching is, making it so that when the "snake" moves it stays as a set length. what i mean is that at the moment it keeps printing the snake image to the 10*10 picture box at a timer delay of (what ever my prefered
speed is) and just ends up making a drawing because its not deleting the back end of the snake. also when the snake eats the food (apple in this case) that it senses it and adds the amount of points a assign. and last thing... when the snake hits its body.
ending the game when it senses that it has hit itself...
any help is something i can put towards my learning.
thanks.
my important things to know is.<br/>
Dim boxes(35, 23) As PictureBox (**is my declared variable for the boxes**
Dim i, j As Integer **X,Y coordinates for boxes**
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br/>
<br/>
For i = 0 To 35<br/>
<br/>
For j = 0 To 23<br/>
<br/>
boxes(i, j) = New PictureBox<br/>
<br/>
boxes(i, j).SizeMode = PictureBoxSizeMode.StretchImage<br/>
<br/>
boxes(i, j).BorderStyle = BorderStyle.None<br/>
<br/>
<br/>
boxes(i, j).Top = 3 + (11 * j)<br/>
<br/>
boxes(i, j).Left = 3 + (11 * i)<br/>
<br/>
boxes(i, j).Height = 10<br/>
<br/>
boxes(i, j).Width = 10<br/>
<br/>
boxes(i, j).Visible = True<br/>
<br/>
<br/>
Panel1.Controls.Add(boxes(i, j))<br/>
<br/>
Next<br/>
<br/>
Next<br/>
<br/>
boxes(GetRandom(1, 35), GetRandom(1, 23)).Image = aple.Image **this is my random food generator for the start, just a test**<br/>
snake()<br/>
<br/>
BackColor = Color.Black<br/>
End Sub
this is my game code. once the game is started it loops through the panel and puts the picture boxes in the panel untill the for loop finishes...
snake() =
Private Sub snake()<br/>
<br/>
h = 0 **this is the starting position for the snake picture<br/>
v = 0<br/>
<br/>
boxes(h, v).Image = snke.Image<br/>
<br/>
rightt = True **this tells the game to start going in the "right" direction and this is a procedure i have created that tells the game which way to go once one of the arrow keys are pressed**<br/>
<br/>
End Sub
View the full article