Does My Game Need a Main() loop?

I guess with “Main() loop” you mean the game loop. (The loop that presents a single frame when running the game).

The BGE already has a game loop. This is the reason why you can simply start the default scene and it works. You do not need to start or maintain the game loop.

Have a look at Prof. Monster's BGE Guide to the GameLoop for details how that works.

You “customize” the game loop by adding logic bricks. While this runs inside the game loop, you describe the behavior within a single logic frame.

You might see people writing functions with the name “main”. There is no restriction nor a convention to use this name. It does not describe the game loop. It is not a loop at all. It is a function that is called within the game loop. In my opinion it is not even a good name for several reasons. One is that is matches the conventions of other systems with a complete different meaning. This can easily lead to confusion. (I guess this is why you ask this question.)

Some people do not like the logic bricks and try to reduce to use them as less as possible. So they use one Python controller (which will be called at each single frame) as “entry point” to run their own logic system from there. It is still not the game loop, but is used for nearly all custom logic.

1 Like