In this second entry of the Snake Rewind devlog series we bring the grid to life. We are adding player controlled snake movement using step based logic and clean keyboard input handling.
What We Covered
- Implemented grid based movement that updates on a fixed timer interval
- Handled directional input with arrow keys including turn buffering
- Kept the snake moving smoothly in one direction until a valid turn is made
- Introduced a simple
Snake
struct to track position, direction and tiles - Laid the foundation for growing the snake and introducing game mechanics
Instead of animating per frame we step the snake every 100 milliseconds. This keeps gameplay deterministic and perfectly grid aligned.
Design Highlights
- Movement is time based, not tied to framerate (fps)
- Turns are buffered when valid, preventing 180° reversals
- Snake wraps around screen edges
- Directional input is decoupled from movement logic
Lessons Learned
- Separating input handling from movement updates keeps logic clean
- Using a
stepTimer
helps us keep gameplay speed consistent and independent of framerate (fps) - Representing the snake as a list of tiles (with the head always at index 0) makes future logic (collision, food, clones) simple and predictable
Acknowledgements
Snake Snake Snake - Original idea of a Snake clone
What’s Next?
In Episode 3 we’ll add the food system and make the snake grow when it eats, setting the stage for our clone mechanic to follow.