Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Most game development happens with a main game loop. Are there any good articles/blog posts/discussions about games without a game loop? I imagine they'd mostly be web games, but I'd be interested in hearing otherwise.

(As a side note, I think it's really interesting that the concept is almost exclusively used in gaming as far as I'm aware, perhaps that may be another question.)

Edit: I realize there's probably a redraw loop somewhere. I guess what I really mean is a loop that is hidden to you. Frames are something you as the developer are not concerned with as you're working on a higher level of abstraction. E.g. someLootItem.moveTo(inventory, someAnimatationType) and that will move from the loot box to your inventory using the specified animation type without the game developer having to worry about the implementation details of that animation.

Maybe that's how "real" games end up working, but from reading most tutorials they seem to imply a much more granular level of control is used, but that might just be an artifact of being a tutorial.

Edit2: I think most people are misunderstanding what I'm trying to ask, likely because I'm having trouble describing exactly what I'm trying to ask. After some more thinking perhaps what I'm referring to is more along the lines of what I believe is referred to as "scripting" where you're working at a very high level and having some game engine take care of the low level details.

For example, take custom maps in Starcraft II or Warcraft III. Many of the "maps" have gameplay that deviates enough from the primary game that they could be considered a separate game written on the same engine. What I'm referring to then is along those lines. I may be wrong because I only dabbed in the Warcraft III editor, but as far as I remember no where in the map editor do you control the game loop, and yet you can create many different games out of it. In my mind, these are games in their own right. If you're playing DotA you don't say you're playing Warcraft III, you say you're playing DotA because that's the actual game you're playing.

Such a system may impose limitations that don't exist if you're creating a game from scratch, but it greatly reduces development time because much of the "hard" work has already been done for you.

Hopefully that clarifies what I'm asking. Another example of what is I mean, is when you write a web app, of course it communicates through sockets and TCP. But does the average web developer doesn't explicitly write code for connecting sockets. They just need to know about receiving a request and sending a response. There are unique scenarios where you do occasionally need to use raw sockets, but it's generally rare in web development.

In a similar fashion, it's very possible to write a game without directly using the game loop, even though one is used behind the scenes. Probably not a AAA title, but there must be hundreds of smaller scale games that can and possibly are written this way. Are there any good resources on writing these "simpler" games?

share|improve this question
Update-Draw-Repeat ... what simplier should be? :) – Notabene Mar 6 '11 at 15:33
What wouldn't have a game loop? Even something like ZORK has one. – The Communist Duck Mar 6 '11 at 15:44
3  
The main loop is very common, every Windows application has one: en.wikipedia.org/wiki/Event_loop and every webserver. – Hendrik Brummermann Mar 6 '11 at 15:49
Unless you're meaning games where the game loop is implicit; or at least not written by you? – The Communist Duck Mar 6 '11 at 16:32
@Duck that's exactly what I mean. I edited that into the question. (Do you get notifications for @Duck? I'm not sure whether SE's notification system handles that) – Davy8 Mar 6 '11 at 16:57
show 2 more comments

5 Answers

First off, I don't think it is possible to have a game that doesn't have a loop, somewhere, unless it is absolutely trivial. A web game uses a loop, the only difference is that you aren't writing the loop, you generally just respond to events. There is still a loop happening. In a way, the distinction is immaterial anyways, you generally must repeat a sequence of code many times. If you use a loop to do so, then fine, if you use events or some other mechanism, great: the end result is that you are repeating. A loop just seems to be the more straightforward way of repeatedly executing a block of code without overflowing your stack. ;)

I can't think of any other paradigm other than event-based when there is no explicit loop, so maybe you can describe what it is you are having difficulties with or want more information about. Is it a general question of how to structure code, or how stuff gets done? For example, in Javascript/HTML5 I'd use a repeating timer to send an event every 1/30 of a second to signal the drawing of a new frame of animation.

share|improve this answer
See my edit. Basically I mean that you don't care about frames, and what I'm thinking of is event-based, but perhaps there are others. – Davy8 Mar 6 '11 at 16:52
I'm not really having any difficulties, just general curiosity. – Davy8 Mar 6 '11 at 17:09

The only way I imagine you can avoid a game loop is recursion, which would eventually end in a stack overflow. Even if a game is event-based, there's something outside the game looping and sending those events. IE: Flash triggering tick/update/draw events. Inherently, to have more than a single frame of a game, you need to loop. That or your game is limited to a certain number of frames that are precomputed. That limits you to a rather simple game that isn't very actively... interactive.

share|improve this answer
What about a model that blocks until an update is issued, say a blocking queue of commands that sleeps until a command comes in to say "hey, something changed". I realize internally this queue would probably be implemented in some sort of loop, but that's an implementation detail. – Davy8 Mar 6 '11 at 16:56
1  
Still a loop. Sure, you don't control it, but you're still subject to the architecture of a game loop. Your input will be called. Then your update will be called. Then your draw/render will be called. Ultimately, that architecture is imposed in some manner. – Sion Sheevok Mar 6 '11 at 17:01
@Sion Right, but all programs are eventually compiled into/interpreted as machine language but that doesn't I as a programmer need to deal with it. Basically what I'm getting at is user code not dealing with the details of frames and just letting some library or engine handle any kind of interpolation and generally just "do the right thing" automatically. – Davy8 Mar 6 '11 at 17:13
There's a difference. You're talking about assembly/bytecode, which is lower than your code and has to do with language, while the game/application loop imposed on you is higher and has to do with software architecture. You are working on a higher-level than assembly/bytecode, but you are working within the game loop. – Sion Sheevok Mar 6 '11 at 17:20
@Sion I think we're not quite understanding one another. What I'm talking about is for instance in a Java program, you may be working within on various operating systems, but the JVM abstracts away the differences for you so you don't need to know or care what OS you're on (most of the time). Similarly I'm wondering about game architectures where you don't know or care that there's a gameloop internally. With JQuery I can say "shift this div 100 pixels to the right over 3 seconds". I need zero knowledge that some loop even exists in order to implement that. That's what I'm referring to. – Davy8 Mar 6 '11 at 17:30
show 6 more comments

Panda3D is entirely event driven, so the main loop of all games written in it is implicit really (one call to a library function that doesn't return until the game ends).

share|improve this answer

It's not entirely clear what you're asking. It's certainly possible for there to be no explicit game loop, eg. when the operating system essentially does your loop for you, but very little changes as far as the game is concerned.

  1. Instead of calling update() in an explicit loop, you could put that function in an OnIdle handler or other Idle event callback - what exactly to use for that would be platform specific. If you have no idle events provided by your OS then you could simulate these with another thread that sets a condition each time you need to update.
  2. Instead of polling directly for input, you respond to input events and then cache any values that you later need to poll for (eg. in the update function).
  3. Instead of rendering directly, you might have to render in an OnPaint handler or something similar.

Beyond that though there's no real difference. However, I'm not convinced that's actually what you're asking, because you seem to be asking about how complex time-based actions take place in AAA games and the like.

E.g. someLootItem.moveTo(inventory, someAnimatationType) and that will move from the loot box to your inventory using the specified animation type without the game developer having to worry about the implementation details of that animation.

If the 'game developer' didn't have to worry about it, someone else did. Probably the same developer, earlier in the development cycle. :) Motion over time can be handled by creating an object or system to monitor that motion. Each update() call moves the item towards the destination until it arrives, at which point the motion stops.

Maybe that's how "real" games end up working, but from reading most tutorials they seem to imply a much more granular level of control is used, but that might just be an artifact of being a tutorial.

Pretty much. A much more granular level of control is used, and most games do run frame by frame, but most gameplay code won't need to take that directly into account. If I call walkTo(14, 15) then there is a separate system that slices that walking behaviour up over as many frames or loop iterations as takes to reach that destination. Same thing with something trivial such as mario.jump(). He still moves frame by frame, but there's a physics system that runs each frame which decides exactly how to move the guy. When you type mario.jump() you don't need to worry about how jumping is implemented - but someone had to work it out and implement it.

share|improve this answer

Are there any good articles/blog posts/discussions about games without a game loop?

No. Every electronic game thats some sort of updates in real time use a game loop. The Only kind of game that wouldn't really use a game loop would be txt based game that reacts to user input only.

I guess what I really mean is a loop that is hidden to you.

Sure, but even though it is hidden, everything applies. Flash for example has a loop for code execution, and you cannot specifically edit the main loop, you however can use different events to trigger code, or have code on the timeline which flash executes when it hits it.

. E.g. someLootItem.moveTo(inventory, someAnimatationType) and that will move from the loot box to your inventory using the specified animation type without the game developer having to worry about the implementation details of that animation.

That is easily doable, but the thing is, someone has to set up that Method and set up the animation. Game Development is not magic.

share|improve this answer
Then Flash is such an example then maybe. I've never actually worked in Flash. Of course it's not magic (for some definitions of "magic") but there must be games where the developer of said game never needs to touch the game loop. I'm interested in resources about those types of games. Simple games, not AAA titles, maybe not even A titles (if such a thing exists), but fits the definition of a game, and is played on a computer. – Davy8 Mar 7 '11 at 5:11
I work in web development and I'm aware of sockets and know how they work, but I've never had to actually write my own socket connections. I'm looking for similar thing in games. A game loop could be sufficiently abstracted away such that most games using that abstraction would not have to touch it. – Davy8 Mar 7 '11 at 5:14
No but it is the same thing as having an update method. – AttackingHobo Mar 7 '11 at 5:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.