▶️ Section 09: Final Run & Extension
Full Code Review
This section shows the complete project code so students can compare their final build to the full reference implementation and clear up any misunderstandings.
Review each file carefully and confirm your code structure, method names, and logic order match.
settings.py
utils.py
snake.py
food.py
game.py
main.py
Extensions
To earn full points, copy your final project code into a new file named Mainfile.Ext.py and complete at least one extension.
If no extension is completed, the highest possible score is B (2.5/4).
You may complete one of the options below or propose your own idea. If you create your own, verify it with your teacher first.
- Add a Start Screen and Instructions Build a start menu screen before gameplay begins, including controls and a "Press Any Key to Start" prompt.
- Add a High Score System Track the highest score during the session, and optionally save/load it from a file so it persists between runs.
- Add Difficulty Levels
Let players choose Easy/Medium/Hard and adjust
SNAKE_TPS(and optionally board size) based on the selected difficulty. - Add Obstacles Place wall blocks on the board and end the game when the snake collides with them.
- Add Special Food Types Create bonus food (extra points) or timed food that disappears after a short duration.
- Add Visual Polish Improve visuals with a checkerboard background, animated snake head, smoother food style, and improved game-over overlay text.
Core Concepts List
By the end of this project, students should understand and be able to apply:
- Project organization across multiple modules (
settings,utils,snake,food,game,main). - OOP fundamentals: classes, objects, encapsulation, composition, and class responsibilities.
- Shared constants and configuration-driven behavior in
settings.py. - Utility functions and pure-function design for reusable grid logic.
- Efficient data structures (
deque,set, tuples, dictionaries) for game programming. - Direction vectors and grid-based movement rules.
- Growth, wall collision, and self-collision logic in the
Snakeclass. - Food spawn/respawn rules that avoid occupied cells.
- Event-driven programming with Pygame (
QUIT,KEYDOWN, custom timer events). - State machine flow:
playing,paused, andgameover. - Ordered gameplay logic in
step_snake(move -> lose checks -> eat checks). - Rendering flow and helper methods for drawing grid, snake, food, UI, and overlays.
- Clean entry-point design using
main()andif __name__ == "__main__":. - Incremental development and verification through section-based testing.





