Python Snake Game
1. Required Features (20 pts in total)
You are expected to implement a variant of the classic snake game written in Python.
The game utilizes the tkinter library to create a graphical user interface, providing an intuitive user
interaction experience.
Players control a snake moving on the screen, eating the food to grow in length while avoiding
collisions with walls and themselves.
The game should support the following features:
- Preliminary Snake Game Rules (10 pts). The logical layer of your program should support the following game
rules:
- The player's goal is to control a snake to eat as much food as possible, causing the snake to grow longer
and learning a higher score.
- The snake continuously moves forward, and the player can control its direction to find food at a fixed
speed.
- Food items randomly appear on the game board, typically represented as small dots or icons. The snake must
consume these food items to increase its length and score. Once the snake eats the food, new food appears at
another location on the map.
- There should be two types of foods. Each food corresponds to a different increasing of the snake's length.
Every time the snake consumes food, its length increases either one or two units.
- The game ends under the following conditions: 1) The snake collides with the boundaries of the game area. 2) The
snake collides with its own body, essentially running into itself. 3) The snake reaches its maximum length (8 units).
- Python GUI (5 pts). You are required to implement a GUI for the game. The GUI should be implemented in
Python Tkinter package.
It should support the following features, i.e. the GUI should be able to display:
- You can utilize Tkinter's Canvas component to draw game elements such as the snake, food, etc.
- Game over message (including the current length of the snake and the total game times in seconds from the game starts) should be displayed upon game failure.
- The colors of snake, food, and background should appear to be different so that player can differentiate them easily.
- Direct Keyboard Control (5 pts). The GUI should support direct keyboard control, capturing keyboard events to control the snake's direction (up, down, left, or right).
2. Submission
Submission should be made at the blackboard system. You need to submit:
- Video: Prepare a presentation for your project by recording a video. Ensure the video captures your screen to demonstrate how the code runs on your laptop or desktop.
- Code: Prepare your code for submission. The main functions and classes in the code must have comments in a reader-friendly format.
3. Resources
Please use some resources below for finishing your projects:
- Python Tkinter tutorials I.
Tkinker I
- Python Tkinter tutorials II. Tkinker II
- Python reference Reference You can search for the syntax of all Python versions through this document.