Hi! Your tutorial is very useful! I am trying to program the same game as an assignment though we use labels for the field and then you make the snake by basically coloring the boxes. my snake moves by giving the current box the color of the background and giving the next box, of where the snake is headed, the color of the snake. I can't seem to make the body lengthen though everytime it eats an apple. Well it actually lengthens by one. but then the body stays were the apple used to be and it doesn't follow the snake.
Im now trying to make a msgbox that displays game over then it clears the screen then redraws the snake but i cant seen to remove the body ive got the head and fruit to work just by removing their control but the body doesn't work could you please help
After i have done the keys 'wasd' i have now put a start button in and now they don't work, i also have put in some other forms that display after a button is pressed eg aboutbox, can you help me please
To place the snake head in the center of the Form1 use the .top and .left. So place the code below, in the click event of your start button... snake(0).top = gamefield.height / 2 snake(0).left = gamefield.width / 2 You also have to reset the length of snake. So again in the click event of your start button.... lengthOfSnake = 0 Try that.
Do you have a button on the form? If yes, the button will take the Focus. So in the click event of the button be sure to have: buttonName.hide() me.focus() If you don't have a button, is the timer turned on? Be sure the enabled property is set to TRUE.
@@CoachBoughen nothing happen I try snake (0).Top("+=up_down_mover") The description of the error is property access must be assign to the property or use its value .
When you place a button on the Form it will always have focus. Meaning it has the attention of the next input by the user. So you need to hide the button, and then pass the focus back to the form so that the Key Press Events will work. So... in the button click event you need these two lines; whatEverTheButtonNameIs.hide() me.Focus()
It gets removed so thanks but when i hit the start button again it starts where the body was and the controls start to lag out, so they have a delay and im not near the fruit then it will disappear and increment the label 1 as if i have scored. i really appreciate the help as i want to get a job when im older in programming, i hope you can help me for the third time. Thanks anyway.
i have a error in the lengthhensnake code Private Sub lengthhenSnake() lengt_of_snake += 1 snake(lengt_of_snake) = New PictureBox With snake(lengt_of_snake) .Height = 10 .Width = 10 .BackColor = Color.White .Top = snake(length_of_snake(-1) Error 1 Value of type 'System.Windows.Forms.PictureBox' cannot be converted to 'Integer'. C:\Users\MELANIE\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 37 20 WindowsApplication1
in the lengthen snake part is it "i" or "1" in the For bit For I = length_of_snake To 1 Step -1 snake(0).Top = snake(1 - 1).Top snake(0).Left = snake(1 - 1).Left Next
hey corbin, there is one error in mine after i input the create_mouse() the snake wont move because it block the tm_snakeMover() and mouse didn't appear on the picturebox. can you help me? for my proposal. i know this is a year ago video but i badly needed it.
Im afraid that didn't work it came out with error 'Object reference is not set to an instance of object' for the snake(0).top = gamefield.height / 2 and the left one but i get that error on the timer part when i put the LenghtOfSnake to 0 the part in the timer is 'Snake(i).Top = Snake(i - 1).Top' i hope you can work this out because im not very good at coding at the moment but im defiantly getting better thanks to you, so if you could help again it would be really appreciated.
after trying out the stuff from video 1, I get the body of the snake but it just wont move. I've tried typing what you typed in and the same thing happens.
Hi Jerome, Be sure in your For Loop that you have i-1. It is hard to see in the video. It looks like it is 1-1 For i = length_of_snake To 1 Step -1 snake(0).Top = snake(i - 1).Top snake(0).Left = snake(i - 1).Left Next
Hey corbin. Congratulations by the game. I do it, and it works correctly, I do some adds to it, and I wannsa do other, but i need your help to do it. I wanna do a Restart button, that i click it and the snake is on the middle of the field, and the lengt of snake = 2 (just like you start the game). I try many and many times to do it alone but I can't.
ahhh i understand thank you i will do that as soon as I've played a little bit of minecraft your awesome btw and im subbing now.
Hi! Your tutorial is very useful! I am trying to program the same game as an assignment though we use labels for the field and then you make the snake by basically coloring the boxes. my snake moves by giving the current box the color of the background and giving the next box, of where the snake is headed, the color of the snake. I can't seem to make the body lengthen though everytime it eats an apple. Well it actually lengthens by one. but then the body stays were the apple used to be and it doesn't follow the snake.
Am not getting snake in design page how to do snake key
Im now trying to make a msgbox that displays game over then it clears the screen then redraws the snake but i cant seen to remove the body ive got the head and fruit to work just by removing their control but the body doesn't work could you please help
After i have done the keys 'wasd' i have now put a start button in and now they don't work, i also have put in some other forms that display after a button is pressed eg aboutbox, can you help me please
To place the snake head in the center of the Form1 use the .top and .left. So place the code below, in the click event of your start button...
snake(0).top = gamefield.height / 2
snake(0).left = gamefield.width / 2
You also have to reset the length of snake. So again in the click event of your start button....
lengthOfSnake = 0
Try that.
Do you have a button on the form?
If yes, the button will take the Focus. So in the click event of the button be sure to have:
buttonName.hide()
me.focus()
If you don't have a button, is the timer turned on? Be sure the enabled property is set to TRUE.
i have an error in this
video 2:31
Private Sub
snake (0).Top+- up_down_mover
snake(0).left +- left right mover
Try +=
Instead of +-
@@CoachBoughen nothing happen I try snake (0).Top("+=up_down_mover")
The description of the error is property access must be assign to the property or use its value .
When you place a button on the Form it will always have focus. Meaning it has the attention of the next input by the user. So you need to hide the button, and then pass the focus back to the form so that the Key Press Events will work.
So...
in the button click event you need these two lines;
whatEverTheButtonNameIs.hide()
me.Focus()
whenever i press any of the keys... snake does not move... help plz
My snake can only have one body part for some reason, any solution?
It gets removed so thanks but when i hit the start button again it starts where the body was and the controls start to lag out, so they have a delay and im not near the fruit then it will disappear and increment the label 1 as if i have scored. i really appreciate the help as i want to get a job when im older in programming, i hope you can help me for the third time. Thanks anyway.
i have a error in the lengthhensnake
code
Private Sub lengthhenSnake()
lengt_of_snake += 1
snake(lengt_of_snake) = New PictureBox
With snake(lengt_of_snake)
.Height = 10
.Width = 10
.BackColor = Color.White
.Top = snake(length_of_snake(-1)
Error 1 Value of type 'System.Windows.Forms.PictureBox' cannot be converted to 'Integer'. C:\Users\MELANIE\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 37 20 WindowsApplication1
in the lengthen snake part is it "i" or "1" in the For bit
For I = length_of_snake To 1 Step -1
snake(0).Top = snake(1 - 1).Top
snake(0).Left = snake(1 - 1).Left
Next
For i = length_of_snake To 1 Step -1
Snake(i).Top = Snake(i - 1).Top
Snake(i).Left = Snake(i - 1).Left
Next
hey corbin,
there is one error in mine after i input the create_mouse() the snake wont move because it block the tm_snakeMover() and mouse didn't appear on the picturebox. can you help me? for my proposal. i know this is a year ago video but i badly needed it.
Im afraid that didn't work it came out with error 'Object reference is not set to an instance of object' for the snake(0).top = gamefield.height / 2 and the left one but i get that error on the timer part when i put the LenghtOfSnake to 0 the part in the timer is 'Snake(i).Top = Snake(i - 1).Top' i hope you can work this out because im not very good at coding at the moment but im defiantly getting better thanks to you, so if you could help again it would be really appreciated.
How do i make the food? and how he eats it?
yo bro, for the sub tm_snakeMover, what is the ending line after "eventargs"?
why the snake head isnt moving
i dont know what is the problem in my code
sorry
i do it dont know what to do
Did u get any solution
My snake is also not moving at all
after trying out the stuff from video 1, I get the body of the snake but it just wont move. I've tried typing what you typed in and the same thing happens.
Same thing is happening to me
Somebody can tell me the solution of this problem plz
Try a FOR LOOP that removes the body.
For i=0 to LengthOfSnake
me.controls.remove(snake(i))
Next
could I possibly send u the suspected part of my code that Im having trouble with... I have tm_snakemover.start but I honestly don't know whats wrong
thanks
legthensnake doesnt work for me
Hi Jerome,
Be sure in your For Loop that you have i-1. It is hard to see in the video. It looks like it is 1-1
For i = length_of_snake To 1 Step -1
snake(0).Top = snake(i - 1).Top
snake(0).Left = snake(i - 1).Left
Next
Thanks. I'll try it later
Hey corbin.
Congratulations by the game. I do it, and it works correctly,
I do some adds to it, and I wannsa do other, but i need your help to do it.
I wanna do a Restart button, that i click it and the snake is on the middle of the field, and the lengt of snake = 2 (just like you start the game).
I try many and many times to do it alone but I can't.
VB.net game of Snake part 3
let me check stay on stand by for a min plz
did i heard a baby?