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...
@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 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?
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:
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!
@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 :)
8gogochristov8 1 month ago
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
a00king 1 month ago
you should implement double buffering if you haven't already. When I mirrored asteroids, double buffering made the graphics a lot smoother.
bscolls 2 months ago
ty dude:)
emiemi95 2 months ago
omg, love this song !!
sajid2196 4 months ago
can u send me the code? pls just send in my email add pls raery14@yahoo.com pls i nid it badly.:).tnx
raery14 5 months ago
@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 5 months ago
@8gogochristov8 can u make some.tutorial of how did u make dis?.
raery14 5 months ago
@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 5 months ago
@8gogochristov8 wat kind netbeans version did u use in making dis program?.
raery14 4 months ago
I got the logic down, but how will I draw the snake? what shape?
ekojk1242 11 months ago
@ekojk1242 I am just drawing squares for the snake, the first of which is different color... you can use images as well
8gogochristov8 11 months ago
coords.add( new Point( x, y ) )
// Coords is an arraylist of Point objects...
8gogochristov8 1 year ago
@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 1 year ago
@bingin15 yeah using the Point class should be much easier and faster :)
8gogochristov8 1 year ago
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?
bingin15 1 year ago
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:
8gogochristov8 1 year ago
how long have you been programing
TheGreekSkater 1 year ago
@TheGreekSkater 2 and a half years :)
8gogochristov8 1 year ago
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!
spellingmastake 1 year ago
nice one mate, is this 100% java?
MaksimilijanYT 1 year ago
@MaksimilijanYT 10x, yeah it's all Java :)
8gogochristov8 1 year ago