Snake Game Updates

Matthew Clark

--

I have been working on creating a snake game using SDL2 and wanted to share some of my progress.

I’ve successfully implemented a state machine that manages the transitions between the menu, game, and game over screens. This enables me to display the menu, interact with it to start the game, and seamlessly switch states. When the player loses, the state changes automatically to the game-over screen.

I’ve also implemented grid movement, allowing the snake to move seamlessly across the screen without any alignment issues. Additionally, I’ve applied this grid system to the apple, ensuring it spawns only within the grid. I also updated the apple spawn logic to prevent it from appearing on the snake’s body.

I also did a major refactor of the code from my previous article on this game. I extracted all the game logic from the main file and organized it into a separate SnakeGame header file and corresponding C++ file.

--

--

No responses yet