Game Loop

Finally found the word that seems to be the heart of game development…

But…are there very difference from one game loop to another?
Are they not basically Start game/program >main state> wait for input> process> execute> return to main state?

If not, how is it different then? Say…from a 2d and 3d game?

What you’ve just said is how the technology works at the most fundamental level. You’re correct - it’s at the heart of games. The problem is where you are. This isn’t the Scripting forum…it’s the Design forum.

…Of course, you’re also not too far off the mark, either!

One of the breakthroughs I’ve recently had, is that when designing a game, you’re not designing “a game” - you’re designing patterns of action…but instead of worrying about how to tell the computer or game artifacts to present those states, you’re coming at it from the user’s perspective.

Imagine FTL for a second. FTL is a game about a starship that is trying to reach its base. The player chooses a ship, which defines their abilities, limits, and priorities for a playthrough. Then, the player makes choices to try to get their ship to their base intact. That’s what the player is doing. That’s what the people who made FTL figured out that they were making.

So yeah, it’s loops. But more importantly - What is the player doing? That’s the armor-piercing question you should be able to answer for a game you’re making. If you can’t, you should rethink your design.

3 Likes

I’ll illustrate with my own magnum opus, High Frontier. This is a bigger game with a couple of nested loops. The most general loop looks like this: achieve opportunities (gain XP) > spend XP on projects > repeat. Projects sometimes unlock new opportunities, but more often change stuff in the inner loops.

The next layer, which is inside the “achieve opportunities” step above, is basically: design space colony > build space colony > manage/grow space colony > repeat. The parts you have to build with depend on the projects you’ve bought in the outer loop.

There is a little loop in the “design space colony” step, which is the same thing any designer does: try a design > check whether it works > refine design > repeat. We have readouts that tell you whether your design works (calculates gravity, radiation, power, living space, etc.), and it’s unlikely that just slapping parts together at random will make a workable design, so you iterate.

But most of the game is spent in the “manage/grow space colony” step, which has a loop like: lay paths > define zones > add municipal services > watch city growth > repeat. But this one isn’t actually as linear and loopy as this description would suggest. Like in SimCity, you have a lot of different tools to encourage city growth. So I guess in more general terms, you’re looping between applying tools to things you can control, and observing things you can’t control, with the goal of optimizing your city.

(And this last one is where our game, which is still under development, is still a bit thin — we need to round out the tools, and refine the simulation, quite a bit yet for maximum fun.)

So there you go. Those are the sorts of things designers mean when they talk about game loops. As @AndrewGrayGames said, it’s all about defining what the player is doing when they play your game.

3 Likes

Just going to chime in from the scripting point of view here. You have described a event driven application loop, something that might work on a spreadsheet application. A game loop is slightly different, there is no waiting. It looks like this:

  • Poll for input
  • Process render
  • Repeat

There is a more detailed version of the unity loop here. http://docs.unity3d.com/Manual/ExecutionOrder.html

But that’s boring scripting stuff. In game design we think of loops in terms of what the player is doing. Or what the system is doing. Something as simple as a weapons fire-reload-fire-reload cycle. Or more complicated loops findTarget-aimAtTarget-shootTarget-repeat. Both of these loops exist within the same FPS game.

The core loop, as in what your player is spending most of their time doing, is critical to the feel of a game. Mario’s jump-move core loop takes only a few seconds. Civilisations core loop consists of an entire turn, and can take several minutes, or longer, to complete. Both games have very different feels.

3 Likes