Page 1 of 1

Simple snake clone

Posted: Thu Apr 19, 2012 9:26 pm
by veethree
Decided to write a simple snake clone the other day..this is basically the results. Doesn't have any fancy bloom shaders but it is functional..haha.

I'd love it if someone would look over the code..The way i made the snake may not be the best one..i'd love comments on that.

There's also some bugs..if you find any that i don't know of please let me know!

Bugs i know of:
-When you hit the bottom or right border the warping is a little weird..not too sure what's causing that
-If you're for example going up, then hit the right/left arrow then down really fast the snake collides with himself and you lose.

Controls: WASD or arrow keys. And the mouse in the menu (just click start)

in-game screenshot:
Image

Made for version 0.8.0, May not be compatible with older versions

Re: Simple snake clone

Posted: Thu Apr 19, 2012 11:23 pm
by Santos
Storing the grid coordinates instead of the absolute position of the snake's pieces might be something to consider. For example, instead of storing {x = 16, y = 48}, you could store {x = 1, y = 3}. This should make things easier to understand and code.

Also, you might want to avoid using magic numbers. For example, instead of having the number "16" throughout the code, you can set a variable to 16 with a name describing what it really means.

Hope this helps! ^^

Re: Simple snake clone

Posted: Thu Apr 19, 2012 11:58 pm
by Kadoba
Hmm.. this looks familiar :crazy:

By the way, you can keep clicking the start button even after the game starts.

Re: Simple snake clone

Posted: Fri Apr 20, 2012 12:21 pm
by veethree
Santos wrote:Storing the grid coordinates instead of the absolute position of the snake's pieces might be something to consider. For example, instead of storing {x = 16, y = 48}, you could store {x = 1, y = 3}. This should make things easier to understand and code.

Also, you might want to avoid using magic numbers. For example, instead of having the number "16" throughout the code, you can set a variable to 16 with a name describing what it really means.

Hope this helps! ^^
I do deal with grid coordinates for the "blips" (stuff you pick up). As for the magic number, The grid is all 16x16 cells, So i use 16 for a bunch of things. Anyway i see what you mean, I'll have a look at that.