Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having some trouble understanding ways to sequence events in my game. Assume the game is data driven, what is the best way to control the events?

Do I have some sort of EventSequencer that loads all the possible events for a level and the enemies? If so, would it be a list of events that I 'fire' off one at a time into the game engine and when the event is completed or finished, remove the event and fire the next one?

My thoughts were similar to the above questions: Build an event sequencer that manages what event is running and loads the proper event (enemy wave, boss battle, etc)...

I'm just not sure if this is a good idea.

share|improve this question
It sounds like you're suffering from design paralysis. Why don't you just try it and get back to us when you actually have a real problem instead of a theoretical one? – Tetrad Mar 23 '13 at 13:08
Sounds like you need trigger zones (e.g. an area or volume which can start events when the player enters/leaves it). I'd store the position and extends (and maybe orientation and shape) of the trigger zone and a reference to the script which should be executed upon entering the trigger zone with the level data. A script can be as simple as a single command (e.g. spawn an enemy) or a list of commands (spawn explosion, spawn enemy, change to boss fight state). – sarahm Mar 23 '13 at 14:21

Based on your example "events", I would probably use a state machine with rules on which state can come next. You can be in EnemyWave state, and as soon as the last enemy is killed switch to BossBattle state. A simplistic code fragment might look like this

class EnemyWave : State
    void main()
        // Game logic for handling the enemy wave
    State nextState()
            return new BossBattle();
            return this;

    // Game logic goes here

    // State specific logic

    // More game logic

    // Ask state for next state
    currentState = currentState.nextState();

If the game is data driven, then your nextState condition would be driven by your data, and your game logic for the particular state just gets swapped in.

share|improve this answer

Your Answer


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.