Public Group

# Trying to make a snake game.

This topic is 2777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 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 on other sites
Thanks very much for the replies both of you. I now have a clearer idea of what i have to do.

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631419
• Total Posts
2999983
×