Game design decisions

Certain versions of snake run differently; however, for the sake of paying homage to the classical approach, we will be implementing a snake that moves based on a grid, as illustrated next:

Game design decisions

Taking this approach makes it easier to later check for collision between the snake segments and the apple. Grid movement basically means updating at a static rate. This can be achieved by utilizing a fixed time-step, which we covered back in Chapter 2, Give It Some Structure – Building the Game Framework.

The outside area symbolizes the boundaries of the game, which in the case of a grid-based movement would be in the range of [1;Width-1] ...

Get SFML Game Development By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.