Python Snake Game
1. Basic Features
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 (10 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. Advanced Features
Note that you can earn 75% of the scores by finishing all three projects with the only basic features.
That is to say, to get a higher score, you may want to consider adding some advanced features:
(Please pick some features from the followings.
The corresponding bonus scores will be added to your final score,
and the upper bound of your final score is 100 pts.
That's to say, you can get at most 100 pts by picking fives 5 pts features or a 10 pts feature with three 5 pts features.)
- Different Effects of Food (10 pts) Different types of food are generated randomly.
You simply need to add two additional types of food.
Some foods may increase the snake's length of two units, while others may change (speed or slow) the snake's speed. Different types of food should be distinguished by using different colors.
- Adding Obstacles (5 pts) The game ends if the snake collides with obstacles, you can randomly generate obstacles in the game scene adding extra challenges.
- Multi-Level Challenges (10 pts) Different game levels can be added, each with varying difficulties and layouts.
At least two levels should be designed, with each level automatically proceeding to the next after reaching a specified score.
- Dynamic velocity (5 pts) As time passes, You can gradually increase the snake's movement speed.
- menu screen (5 pts) You can customize the theme to design a game menu that includes two button controls: 'Start Game' and 'Exit Game'.