Imagine you’re building a simple game. Your character moves across the screen, enemies spawn, and the score updates. So you write code that waits for user input and then updates the game.
But something feels off: the character only moves when you press a key. Enemies stop between inputs. Everything “pauses” the moment the player does. The game feels broken.
That’s because traditional programs are often event-driven. They wait for something to happen, respond, and then wait again. Games can’t afford that. Enemies must keep moving even when the player is idle. Physics has to run continuously. Animations should stay smooth.
The Game Loop Pattern fixes this by running a continuous loop that, on every frame, processes input, updates the game state, and renders the result whether or not the player does anything.