The code shown above resides in the StartRound state, which sits at the bottom of the state stack. Here’s the logic that sets up a new round (simplified from the original source for clarity): (īecause all of the states can be stacked up at once within a single function, none of the states have to be aware what state comes next.įor example, PlaceWalls doesn’t have to know to show a stats summary when it ends it just pops itself off the stack when done and lets the next state kick in. Before each phase, a banner scrolls across the screen telling the player what phase they are in. First you place some turrets in your territory, then you fire at your opponent, and then you try to repair the damage done during the firing phase. In it, a match is divided into rounds, and each round passes through a series of phases. I leveraged this while making damage_control, a game reminiscent of the Arcade/SNES title Rampart. Stacking states provides a nice way to isolate chunks of game logic from one another. The example code is written in D, but it should be pretty easy to apply in any language. In this article, I’ll give a quick overview of this technique and some examples of what makes it useful. In my past two game projects, I found it helpful to structure my game flow as a stack of states. If you’re not careful, you quickly end up with a scattered collection of state variables and conditionals that is difficult to wrap your head around. Structuring the flow of logic in a game can be challenging.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |