Added: 1 year ago
From: 8gogochristov8
Views: 7,212
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (22)

Sign In or Sign Up now to post a comment!
  • @a00king It's using a loop that keeps updating the snake position on every iteration. The keys only change the variable's sign, i.e

    while (true) { snakeX += increaseX; // this would be 0 if moving down/up snakeY += increaseY; // this would be 0 if moving left/right

    }

    and then for the keys you have...

    if key == up { increaseX = 0; IncreaseY = -increaseY;

    }

    etc. of course this means that when you press up twice the snake would start to go down :)

  • hi, could you send me the source text, or explain how you did it that the snake keeps his direction after pressing the key, i have to press the key for every "step" again...

    thanks

  • you should implement double buffering if you haven't already. When I mirrored asteroids, double buffering made the graphics a lot smoother.

  • ty dude:)

  • omg, love this song !!

  • can u send me the code? pls just send in my email add pls raery14@yahoo.com pls i nid it badly.:).tnx

  • @raery14 the source code is included in the program itself - try downloading and installing it from my website and you should see a Source tab in the main panel :)

  • @8gogochristov8 can u make some.tutorial of how did u make dis?.

  • @raery14 I'm starting uni right now so I won't have much time to do that but you could probably find something useful on Google :)

  • @8gogochristov8 wat kind netbeans version did u use in making dis program?.

  • I got the logic down, but how will I draw the snake? what shape?

  • @ekojk1242 I am just drawing squares for the snake, the first of which is different color... you can use images as well

  • coords.add( new Point( x, y ) )

    // Coords is an arraylist of Point objects...

  • @8gogochristov8 i've been asking around and a lot of people have been recommending i use the point class for my arraylist instead of using two arraylists to store each coordinate separately. so should i try that instead?

  • @bingin15 yeah using the Point class should be much easier and faster :)

  • hi, i'm trying to make a snake game in java but i'm having trouble storing coordinates in the arraylist. every time i store new coordinates into the lists for the x and y it will store the same coordinate (i think it's cuz i'm using global variables). do you have any ideas on how to get it to not store the same coordinates?

  • hi, global variables shouldn't be a problem though, and using an arraylist should work for storing the coordinates ( it does not check for identical items when adding new ones ). Try something like this:

  • how long have you been programing

  • @TheGreekSkater 2 and a half years :)

  • I've downloaded your program, thanks for including the source code, it's given me something to learn from. I made a snake game myself today, and although it works, I've no idea how to organise my classes, so it's one big mess at the moment!

  • nice one mate, is this 100% java?

  • @MaksimilijanYT 10x, yeah it's all Java :)

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more