Beginner Topic 14 of 49 Graphics, Vision & Media
Game Loop
Repeating cycle of input, update and render.
How it works
The game loop is the central cycle of a real-time program: each iteration processes input, updates the game state, such as physics, AI and animation, and renders a frame, repeating until the game quits. A fixed time step, as in physics simulation, gives deterministic and stable behavior, often combined with variable-rate rendering and interpolation. Techniques include accumulating elapsed time and running multiple updates per frame, vsync, frame limiters and separate threads for rendering.
Where it is used
Video games, simulations, interactive visualizations and animated user interfaces are built around a loop, using requestAnimationFrame in browsers.
Common pitfall
Tying movement to frame rate makes the game run faster on faster machines; scale by delta time. Variable time steps make physics unstable and non-deterministic. Large delta times after pauses cause tunneling and spiral of death, where updates take longer than the time they simulate. Clamp the time step, decouple update and render and profile each phase.
Where it fits in the course
Game Loop is topic 14 of 49 in Graphics, Vision & Media, rated Beginner. It follows Animation Principles. The next topic is Sprites and Tilemaps.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Graphics, Vision & Media quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Graphics, Vision & Media quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Game Loop?
Where do people use Game Loop?
What is the most common mistake with Game Loop?
What should I learn before this topic?
How can I practice it?
Is Game Loop hard to learn?
How long does it take to learn Game Loop?
Which topics are related to Game Loop?
What should I study after Game Loop?
Related topics
- Animation Principles (Graphics, Vision & Media)
- Sprites and Tilemaps (Graphics, Vision & Media)
- Matrices in Graphics (Graphics, Vision & Media)
- Collision Detection (Graphics, Vision & Media)
- Event Loop (Web Development)
- Loop Optimizations (Languages & Compilers)
- Game Theory (Emerging & Frontier Topics)