Skip to content
Lesson 1 of 14

Step 1 of 5 · Reading · ~2 min

Read

Game Loop

What Game Engines Solve

A game engine is the runtime that powers a game:

  • Rendering: draw graphics on screen.
  • Input: keyboard, mouse, gamepad.
  • Audio: sound effects, music.
  • Physics: collision, gravity.
  • AI: NPC behavior.
  • Scripting: gameplay logic.
  • Asset loading: textures, models, sounds.
  • Network: multiplayer.

Real engines:

  • Unity: C#, cross-platform, dominant in indie + mobile.
  • Unreal: C++/Blueprints, AAA + Fortnite.
  • Godot: free, GDScript or C#, lightweight.
  • GameMaker: 2D-focused.
  • Bevy: Rust, ECS-based.
  • MonoGame (XNA reborn): C#, lower level.

Smaller / specialty:

  • Pico-8: fantasy console.
  • Construct: visual scripting.
  • RPG Maker: turn-based RPG.

We'll build a toy engine: game loop + ECS + simple rendering. By the end you understand the runtime architecture of every modern engine.

Reference: Bevy source, Game Engine Architecture (Gregory).

The Heart: The Game Loop.

loop:
    handle_input()
    update(dt)        # AI, physics, gameplay
    render()

That's the simplest possible game. Real engines layer features on top.

We'll start with the loop, then add:

  • Time management (fixed vs variable timestep).
  • Entity-Component System (ECS): the modern way to organize game state.
  • Asset management.
  • Rendering pipeline.

Modern games: 60-144 FPS, dozens of subsystems running in parallel, gigabytes of assets streamed in real-time. The engine is the substrate.

Frame time is the real number; FPS is the display

Engines measure milliseconds per frame, not frames per second. FPS is just its reciprocal, scaled: fps = 1000 / ms. The two are not linearly related, which is why frame time is what profilers show.

python

Dropping from 16.7 ms to 33.3 ms costs 30 FPS; dropping from 33.3 ms to 50 ms costs only 10. Averaging matters too: average the millisecond samples and convert once at the end. Averaging the per-frame FPS values instead gives a different (and wrong) number, because the mean of reciprocals is not the reciprocal of the mean.

That is exactly the calculation the practice problem asks for — a running total of frame durations, a running count, one conversion per frame.

Up nextThe Game LoopGame Loop

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…