Back to course overview
Game Prototyping & Systems
The Game Loop in Code
Draw on an HTML canvas, run an update/draw loop with delta time, and respond to keyboard input.
3 lessons · 2h
- 35mDrawing with canvasReading
Draw a sprite on an HTML canvas, move it by changing its state, and keep it inside the play area.
- 53mThe game loopReading
Write an update/draw loop with requestAnimationFrame and delta time so movement is the same at any frame rate.
- 32mInput handlingReading
Track keyboard state with keydown and keyup, move a player from that state each frame, and avoid stuck keys.