App 6: Make a Game, Snake in Pygame / Build Snake
Lesson 9 of 10
Restart and speed up
Press R to restart after game over, and make the game faster as the snake grows for extra challenge.
Key points
- Put setup in a reset() function
- clock.tick(10 + score // 3)
- Show 'Press R to play again'
def reset():
global snake, direction, food, game_over
snake = [(10, 10), (9, 10), (8, 10)]
direction = (1, 0)
food = new_food()
game_over = FalseYour turn
Add restart with R and increasing speed.
Quiz · +10 XP
Why put the starting values in reset()?
Log in to save progress and earn XP.