Game Dev From Zero · Episode 3

Loop lab

This is a real game loop, and the game runs exactly these lines, in this order, every frame. Switch lines off, move them up and down, pause and step through one line at a time. Break it, then fix it.

The game hold → (or the button) to move

The picture only changes at wait for the next frame: that's when what you drew is shown.

RAM and screen live

x (in RAM)
0
x (on screen)
0
frame
0
trips / second
0

The loop tick = on · ↑↓ = move

Break it, then fix it

  1. No clear: every old ghost stays on screen.
  2. Draw before update: the screen is one frame behind. Watch the two x boxes.
  3. No wait: the loop runs as fast as it can.
  4. Clear after drawing: you wipe the ghost away before it's ever shown.
  5. Pause, then press Step one line again and again. Watch it reach the bottom and go back to the top.

Press Reset to fix everything.