Home | Rules and Guide | Sign In/Create Account | Write a Post | Donate | #ludumdare on irc.afternet.org (Info)

Ludum Dare 24 — Coming August 2012

Ludum Dare 23 — April 20th-23rd, 2012 — 10 Year Anniversary
[ Results: Top 50 Compo, Jam | Top 25 Categories | View My Entry ]
[ View All 1402 Games (Compo Only, Jam Only) | Warmup ]


Adding an overall game flow loop

Posted by
September 8th, 2009 12:41 am

In playing through people’s entries I found a lot of them just jump straight into the game and stop when you win or lose.  This is a post intended to inform anyone who doesn’t know how, about a quick and dirty way to create a simple ‘start screen’ -> ‘game’ -> ‘end’ -> ‘reset’ loop in thier game.  I’ve no idea if there is a more ‘proper’ way to do this, but this is quick, dirty, and works.  There may be some differences depending on how your game is structured, but you can fit the idea to most.

First you will need to add one integer variable to tell the program what state the game is currently in (i.e. the start screen, the actual game etc.) called something like ‘gameState’.  Initialize this to 1, corrisponding to the menu screen, so that when the game starts up it shows the menu. You’ll also want to pull out any specific initialization that needs to be done before the game starts into a separate method, not the image loading or any of that, just things like generating maps, reseting scores to 0 and the like.

Now for the magic, wrap any parts that are involved with updating your game in great big ‘if elseif’ statements checking the value of ‘gameState‘.  Leave the normal playing of the game stuff in ‘gameState == 2′.  Now, when at the menu (gameState == 1) draw whatever is needed for a main menu (instructions, keys, intro, etc.) and check for whatever causes the game to start (clicking a button or pressing a key) and when that happens call the game inialization stuff you pulled out earlier and set ‘gameState = 2′.  In the actual game (gameState == 2), when checking for Win/Lose conditions, when they occur (or after a button is pressed after they occur etc.) clean up anything that should be from the game and set gameState to 3 or 4 to go to win/lose screens (or alternativly just back to 1 to jump back to the menu).  If using a win lose screen make sure to have a point in them that will set gameState back to 1, to put you back on the menu.

Using this simple idea it’s quick and easy to create game flow for your game.  You can also have the nice aspect of being able to restart easily by calling the reinitialize method, or to even quit back to the menu from the game easily too.  So please to the peoples out there, add game flow to your game.  It ends up making the whole thing feel like a much more complete and rounded game experience, with only a few minutes work.

4 Responses to “Adding an overall game flow loop”

  1. noonat says:

    This is all true, but if it comes down to the wire and I have the option of either polishing up my gameplay and adding sounds (as I did) or adding pre-game and post-game mensu, I’m going to go for polish every time. Most people are scrambling just to finish their gameplay in the last few minutes, and haven’t had time to even think about menus yet.

    • Jonny D says:

      That’s why you should put menus in early (i.e. between hours 1 and 12). Do that before you get your time taken away by heavy involvement in gameplay. If you *actually* use 48 hours (or, I suppose 32 hours with sleep taken) for gameplay, then you chose the wrong game idea :) . It’s too bad that the “Polish” rating is gone, since that says a lot about how you manage LD time.

      • Epitaph64 says:

        Well, I tend to just integrate how polished the specific features (audio, humor. etc) are as part of their scores, so I think it probably was removed because all the sub-categories could be polished.

        • Jonny D says:

          Polish isn’t about the parts, it’s about the whole. The quality of each part is taken into the respective rating, whereas ‘polish’ is about how well-presented the game is (as opposed to ‘overall’ which deals more with gameplay). I agree that it’s not a necessary rating, but I really liked the flavor.

Leave a Reply

You must be logged in to post a comment.


All posts, images, and comments are owned by their creators.

[fcache: storing page]