Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
GlossaryNovember 22, 20263 min read

What is a game loop?

Every real-time game runs one repeating cycle: read input, update the world, draw it. Here is what that cycle looks like and why it decides how your game feels.

Startbase Team
Editorial ink illustration of a hand-cranked music box drum plucking a metal comb, the crank handle in ember orange

Key takeaways

  • The game loop repeats three steps every frame: read input, update the game state, render the result.
  • In a browser it is driven by requestAnimationFrame, which fires once per screen refresh (usually 60 or 120 times a second).
  • It is a code concept. The "core loop" of game design (play, reward, upgrade) is a different idea with a similar name.

The game loop is the piece of code that runs over and over while a game is open, each pass reading the player's input, moving everything in the world forward a little, and drawing one new frame. Run it 60 times a second and still pictures become motion, the same way a flip book does.

Think of a referee in a board game who, every few seconds, asks each player what they want to do, applies the rules, then redraws the board. A video game does exactly that, just fast enough that you never see the pauses.

The three steps, every frame

  1. 01Input. Which keys are held, where the finger is, whether the jump button was pressed since the last frame.
  2. 02Update. Apply movement, gravity, timers, enemy decisions and collisions. This is where the rules of the game live.
  3. 03Render. Draw the world as it now stands: background, sprites, effects, then the score and buttons on top.

In a browser game the loop is usually started with requestAnimationFrame, a browser function that calls your code right before the screen refreshes. On a 60 Hz phone that gives you about 16.7 milliseconds for all three steps; on a 120 Hz screen, about 8.3. Go over budget and the frame is late, which players feel as stutter.

A stripped-down shape of the code looks like this: `function frame(now) { const dt = (now - last) / 1000; last = now; readInput(); update(dt); render(); requestAnimationFrame(frame); }`. The dt value is delta time, the seconds since the previous frame, which keeps speed the same on fast and slow screens.

Fixed steps versus variable steps

The simplest loop runs update once per frame with whatever dt it got. That works for most casual games. Physics-heavy games often use a fixed timestep instead: the update always advances the world by the same slice, say 1/60 of a second, running twice on a slow frame or zero times on a fast one, while rendering happens once per frame. Fixed steps make jumps the same height on every device and keep physics stable. A good starting rule: variable steps for puzzle and card games, fixed steps for platformers, pinball and anything with a physics engine.

Why it matters when you build with Startbase

You do not write the loop by hand: Startbase games run on PixiJS for 2D and Three.js for 3D, and the agent sets up the loop when it creates the game (games template docs). Knowing the word still helps you describe problems precisely. "The player moves faster on my laptop than on my phone" is a loop problem (speed not scaled by dt). "The game hitches every few seconds" is usually too much work inside one update. The Engine panel's Perf view shows how long frames take, so you can see the budget being blown instead of guessing.

The game feels different on my phone and my laptop. Make all movement and timers use delta time, run physics on a fixed 60 Hz step, and cap dt at 0.1 seconds so returning from a background tab does not teleport the player.

Common confusions

  • Game loop vs core loop. The core game loop is a design term for what the player repeats (fight, loot, upgrade). The game loop here is the code that ticks every frame.
  • Loop speed vs game speed. A faster loop should mean smoother motion, not a faster game. If the game speeds up on a 120 Hz screen, movement is counted per frame instead of per second.
  • Paused tabs. Browsers stop calling requestAnimationFrame in background tabs. When the player comes back, the first dt can be many seconds long, which is why loops clamp it.

To see the loop in a full game, read how to make a platformer, and for keeping it under budget on phones, game performance on phones.

Frequently asked questions

How many times per second does a game loop run?

In a browser, usually once per screen refresh: 60 times a second on most screens and 120 on high-refresh phones and monitors. Some games run their update at a fixed rate separate from drawing.

Do turn-based games have a game loop?

Usually yes, because animations, hover effects and timers still need frames. The rules may only change when a player acts, but the drawing keeps looping.

Is setInterval fine for a game loop?

It works but is a poor fit: it is not synced to the screen refresh, so frames tear or double up. requestAnimationFrame is the standard choice in browsers.

On this page

  • The three steps, every frame
  • Fixed steps versus variable steps
  • Why it matters when you build with Startbase
  • Common confusions

Keep reading

More in Glossary
Editorial ink illustration of a brass stopwatch beside a small wind-up toy car, the second hand in ember orange
GlossaryNovember 22, 2026

What is delta time?

Delta time is the number that keeps your game the same speed on every screen. Here is how to use it, where it breaks, and how to spot a game that forgot it.

3 min read
Editorial ink illustration of a flip book riffling under a thumb with a running figure across its pages, the page edge in ember orange
GlossaryNovember 22, 2026

What is frame rate (FPS)?

FPS counts the pictures a game draws per second. Here is what the numbers mean in milliseconds, why a steady 60 beats a jumpy 90, and what drags a phone game down.

3 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.