Main Loop

2025/12/27

Type
Learning Resource
Format
Glossary Article
Version
General
Subject Tags
Code
Assets
All else
Copyright 2016-2026, GDQuest
Created
2026/02/16
Updated
2025/12/27

Main Loop

In traditional game programming, the "Game Loop" is a function that runs continuously, updating the game state and rendering the game world. It's the heart of the game.

Here's a pseudo main loop in a fake language that looks like GDScript:

while true:
  process_inputs()
  update_physics()
  update_game()
  render_game()

In all modern engines, including Godot, you don't have to write the main loop by hand; it is handled behind the scenes for you. Nonetheless, the core structure of any game engine remains similar to the above; some core function runs as many times per second as it can, and calls other functions to update the game's physics, logic, and rendering.

Become an Indie Gamedev with GDQuest!

Don't stop here. Step-by-step tutorials are fun but they only take you so far.

Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.

Nathan

Founder and teacher at GDQuest
  • Starter Kit
  • Learn Gamedev from Zero
Check out GDSchool

You're welcome in our little community

Get help from peers and pros on GDQuest's Discord server!

20,000 membersJoin Server

Contribute to GDQuest's Free Library

There are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!