From the course: Building the Classic Snake Game with Python
Unlock the full course today
Join today to access over 24,600 courses taught by industry experts.
The game loop - Python Tutorial
From the course: Building the Classic Snake Game with Python
The game loop
- The heart of many games is the game loop. This is where essential game operations, such as updating positions of game objects and checking for collisions occurs continuously until the game ends. The game loop for the snake game needs to achieve the following. We need to clear the existing snake from the screen. We need to draw the snake in his new position, check for collisions, with walls, self, or food, and handle these appropriately and also update the score so far. Our snake animation has been handled by the function of move snake. The game loop needs to do the same, but it has additional responsibilities as well. So we'll rename a moose snake to game loop and add some new functionality. Okay. So we've renamed that now in terms of collision detection, we want to check whether the snake has collided with either of the four walls, the top bottom left, or right. Whether it's collided with itself and later on, whether it's collided with an item of food as well. And we're going to do…