VB.net Game of Snake part 2

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.พ. 2025
  • A class assignment of how to code the game of snake in vb.net. Here are some more resources:
    boughen.wikisp...
    and
    boughen.wikisp...

ความคิดเห็น • 36

  • @_Thundrix
    @_Thundrix 12 ปีที่แล้ว

    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.

  • @BoredWave
    @BoredWave 7 ปีที่แล้ว

    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.

  • @factsfunny12
    @factsfunny12 9 หลายเดือนก่อน

    Am not getting snake in design page how to do snake key

  • @_Thundrix
    @_Thundrix 12 ปีที่แล้ว

    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

  • @_Thundrix
    @_Thundrix 12 ปีที่แล้ว

    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

  • @CoachBoughen
    @CoachBoughen  12 ปีที่แล้ว

    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.

  • @CoachBoughen
    @CoachBoughen  11 ปีที่แล้ว

    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.

  • @melanieyap5925
    @melanieyap5925 6 ปีที่แล้ว

    i have an error in this
    video 2:31
    Private Sub
    snake (0).Top+- up_down_mover
    snake(0).left +- left right mover

    • @CoachBoughen
      @CoachBoughen  6 ปีที่แล้ว

      Try +=
      Instead of +-

    • @melanieyap5925
      @melanieyap5925 6 ปีที่แล้ว

      @@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 .

  • @CoachBoughen
    @CoachBoughen  12 ปีที่แล้ว

    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()

  • @ccbaseball1998
    @ccbaseball1998 11 ปีที่แล้ว

    whenever i press any of the keys... snake does not move... help plz

  • @plenta96
    @plenta96 10 ปีที่แล้ว

    My snake can only have one body part for some reason, any solution?

  • @_Thundrix
    @_Thundrix 12 ปีที่แล้ว

    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.

  • @melanieyap5925
    @melanieyap5925 5 ปีที่แล้ว

    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

  • @williamyang6664
    @williamyang6664 8 ปีที่แล้ว +1

    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

    • @timur4460
      @timur4460 6 ปีที่แล้ว

      For i = length_of_snake To 1 Step -1
      Snake(i).Top = Snake(i - 1).Top
      Snake(i).Left = Snake(i - 1).Left
      Next

  • @laverndelacruz5861
    @laverndelacruz5861 9 ปีที่แล้ว

    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.

  • @_Thundrix
    @_Thundrix 12 ปีที่แล้ว

    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.

  • @brunosetubal1996
    @brunosetubal1996 11 ปีที่แล้ว

    How do i make the food? and how he eats it?

  • @codyrigon4367
    @codyrigon4367 6 ปีที่แล้ว

    yo bro, for the sub tm_snakeMover, what is the ending line after "eventargs"?

  • @melanieyap5925
    @melanieyap5925 5 ปีที่แล้ว

    why the snake head isnt moving
    i dont know what is the problem in my code

    • @melanieyap5925
      @melanieyap5925 5 ปีที่แล้ว

      sorry
      i do it dont know what to do

    • @sanskritisaklani7983
      @sanskritisaklani7983 4 ปีที่แล้ว

      Did u get any solution
      My snake is also not moving at all

  • @EXLR83D
    @EXLR83D 12 ปีที่แล้ว

    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.

    • @sanskritisaklani7983
      @sanskritisaklani7983 4 ปีที่แล้ว

      Same thing is happening to me
      Somebody can tell me the solution of this problem plz

  • @CoachBoughen
    @CoachBoughen  12 ปีที่แล้ว

    Try a FOR LOOP that removes the body.
    For i=0 to LengthOfSnake
    me.controls.remove(snake(i))
    Next

  • @ccbaseball1998
    @ccbaseball1998 11 ปีที่แล้ว

    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

  • @brunosetubal1996
    @brunosetubal1996 11 ปีที่แล้ว

    thanks

  • @jeromeimson
    @jeromeimson 8 ปีที่แล้ว

    legthensnake doesnt work for me

    • @CoachBoughen
      @CoachBoughen  8 ปีที่แล้ว

      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

    • @jeromeimson
      @jeromeimson 8 ปีที่แล้ว

      Thanks. I'll try it later

  • @rubenmatos7197
    @rubenmatos7197 10 ปีที่แล้ว

    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.

  • @vanessaboughen5458
    @vanessaboughen5458 11 ปีที่แล้ว

    VB.net game of Snake part 3

  • @ccbaseball1998
    @ccbaseball1998 11 ปีที่แล้ว

    let me check stay on stand by for a min plz

  • @setseretze3565
    @setseretze3565 5 ปีที่แล้ว

    did i heard a baby?