Title: Gamedev Glossary: What Is the “Game Loop”?
Headings: Gamedev Glossary: What Is the “Game Loop”?
Gamedev Glossary: What Is the “Game Loop”?
Initialize, Update and Draw
Managing States
Entities Within the Game
Conclusion

Content: This will load the game menu and then keep running and executing the menu logic until it receives an input event (a mouse click, keyboard press, or similar). This event then triggers a change in the main game state, moving the execution flow to the intro scene, so the game menu code is not executed any more. The game loop keeps running, but it executes a different part of the code - the part corresponding to the intro scene. Advertisement
Advertisement
Entities Within the Game
Now that you have all your states under control you'll need to interact with all your entities (chars, objects, NPCs, and so on) and update their properties (status, health, position, ...) to actually move objects and players on your game. So as well as executing the specific part of the code based on the current state, the game loop also has an inner loop that executes the specific part of the code for each entity in the current state. Interacting with entities
The same behavior happens in the draw phase, where each entity gets drawn. Conclusion
The game loop is the heart of the game, and it is not too difficult to understand its concept if you're coming from any different software development branch. There's a lot more that could be said about it, but I hope this post helps you to start understanding the core of what it's about! Advertisement
Advertisement
PotHix
PotHix is a hobbyist game developer that works mainly with HTML5 and Javascript for games on his spare time. His latest game was Skeleton Jigsaw (http://plaev.me/skeleton-jigsaw) that is available open source on his organization on Github: