Sign in to follow this  
Dream Of Sleeping

Trying to make a snake game.

Recommended Posts

Hello.

I'm trying to make a snake game and it's proving to be trickier then i thought. I have a question but i'm finding it hard to find a way of putting it across so it makes sense.

I notice from playing other games the snake must be moving over some form of invisible grid because when the snake turns it can never turn and be half on it's self. It always seems to slots nicely into place Because the games i'm playing move so fast it's hard to see what is going on.

take this game for example http://www.snakegame.net/digisnake.htm

When you hit a key to tell the snake to move it appears to move instantaneously, but i wonder if it must be waiting to be at the right point of the grid. Is it doing this by only re drawing the snake once every time it moves to the next square in the grid. (if it is doings this i would have thought the animation would be much more jerky). Or is it rendrawing the snake at points between the grid squares, and then waits until the right moment to turn?

Share this post


Link to post
Share on other sites
The traditional snake games used to be implemented using text modes, so there is definitely a grid there. The one you linked to is also definitely on a grid. The snake advances one square at a time, not continuously.

Share this post


Link to post
Share on other sites
The most straight-forward way to implement this would be cell-based movement. When you hit a key, you just change the direction of the snake. Once it's time for the snake to advance, it moves in that direction. There are probably some additional checks going on - the game appears to queue direction changes, so you can't immediately turn 180 degrees in one step.

Continuous movement makes little sense in this case (but note that it's perfectly possible to make a snake clone that does use continuous movement!). Note that the snake is moving pretty fast, so things appear to be quite fluid.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this