system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How video games work from a code perspective.

Is it all one big while(1) loop?
gpt
Game developer here.

Basically, it's a huge loop - or multiple loops. When you launch the game, it loads stuff like textures, models, sounds and so on, and then it begins the "main loop", where it processes the input, updates all objects that need to be updated, and finally draws everything on the screen.

In practice, it's a bit more complicated than that. For example, physics might have an own loop that runs 30 times per second, other "non-visual" code runs 60 times per second, and graphics may run as fast as possible to ensure seamless representation on the screen.

Also, there's the problem of resource handling: if the game is huge (10 GB for example), it can't all be loaded at the beginning. Usually games load the needed resources just when they are needed (between levels, for example), and the unneeded resources are unloaded. This all may happen in the "main loop", or the main loop may be shut down, before the resources are loaded and re-started after the loading is complete. Some games require seamless progression through the world (WoW and other MMOs), where the game may load and unload the resources all the time in the main loop (or another loop running at the same time).