

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Modules
incomplete
2: Logging Game State
incomplete
3: Game Loop
incomplete
4: FPS
incomplete
This lesson's interactive features are locked, please to keep using them
As it stands, our game is re-drawing the screen as fast as it possibly can. This causes it to use a lot more CPU than it actually needs!
The Greek letter delta (Δ) is often used to represent a change in a value in mathematics. In game development, we use "delta time" to represent the amount of time that has passed since the last frame was drawn. This value is useful to decouple the game's speed from the speed it's being drawn to the screen.
If your computer's CPU speeds up (its speed is not constant, like a sprinter running as fast as they can), the asteroids shouldn't also speed up. Conversely, if your computer slows down, the asteroids shouldn't also slow down: they may just move less smoothly.
FPS stands for frames per second. We're going to restrict our game to draw a maximum of 60 times per second, or 60 FPS.
Use 0.0 instead of 0 because dt will store a decimal number of seconds. Keeping it as a float from the start makes the type hints line up with how we'll use it later.
dt = clock.tick(60) / 1000
If everything is still working as you'd expect, let the game run for a few seconds so that multiple entries are written to game_state.jsonl, run and submit the CLI tests.