INSIDE main.py
-
Setting up the screen title and importing all the other modules scoreboard, food, snake.
-
Creating the objects for the import class.
-
As the turtle size is 20px by default so considering that:
(i) Moving the snake inside while loop
(ii) We will direct the snake head and check for possible collision
(iii) Three types of collision
- Collision with food.
- Collision with tail/ body.
- Collision with the wall.
Inheriting the turtle library in food and scoreboard.
INSIDE food.py
- Shaping the food.
- Using the random module.
- Creating a method which refreshes the food and put it randomly on the screen.
INSIDE snake.py
- It is responsible for Event Listener.
- Creating the method to create the snake adding and extending it.
- Keyboard's Method for up, down, left, right.
INSIDE scoreboard.py
- Creating the Score text on the screen.
- By using the method update_scoreboard.
- Creating the method to check whether the user collided.
- Creating the method to increase the score when the snake eats the food.