Re: Keeping Track of a game's storyline/objectivs

You can simplify this problem by using a finite state machine. This is usually achieved using enums.

Let's take your coordinates example. Logic like this will work just fine:

if state == waitingForDesiredCoords and coords == desiredCoords then:
  advance the state machine // This will advance the state and also play the next objective if your game requires this.

No need to complicate this with bitwise operators like another poster suggested--it will be really easy to lose track of things by employing that tactic and will also make your code much more difficult to read. In the end, readable code is generally desired over code that looks cool.

Here is a state example from TDV:

        public enum Stage
        {
            takingOff,
            missileHit,
            aboveIsland,
            trainingGrounds,
            airbase,
            discovery,
            powerPlant,
            chopperFight,
            juliusRadioIntercept,
            radarTowers,
            juliusBattle,
            gameEnd
        }

There is a function, playNextMissionObjective, which increments the enum state by 1 since enums are internally stored as integers, so playing the next mission objective is simply:

playFile("filename" + (int)stage + ".wav")

So state holds the stage of the objective list the player is currently looking to achieve. For example, enum.takingOff means the player is looking to complete the taking off objective.



-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Munawar via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Munawar via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Munawar via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Munawar via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : NicklasMCHD via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector

Reply via email to