86
game loop
Input, update, render, repeat. Not a chain of setTimeouts that drift.
What is game loop?
The game loop is the heartbeat: read input, step the simulation, draw. It runs on a frame callback. Update and render are separate so you can step the sim without drawing, and draw without changing the sim.
Why does game loop matter when vibe coding?
Models animate with CSS or a pile of timers. Collisions then depend on frame rate. Name the loop: one place that advances the world.
How do you do game loop?
One `requestAnimationFrame` or engine tick. Fixed order: input, update(dt), render. No gameplay in a timer beside the loop.
How do you ask a model for game loop?
One game loop. Order: input, update, render. Do not use setTimeout or CSS to move gameplay objects. Keep drawing separate from the simulation step.
What goes wrong with game loop?
Two loops, one for UI and one for “enemies,” that do not share time. One clock.