Jump to content

Turn based strategy game time implementation?


scheffgames
 Share

Recommended Posts

How would one approach creating a turn based strategy game in Phaser? We have the main update() function, sure, but we're not dealing with moving objects on the screen, rather updating the complex states of various objects in a certain order. Implementing my own customized update function that measures how much time has passed in mSeconds and then performing certain actions comes to mind but it's from the top of my head and I'm sure there must be better ways of doing it.

I've been out of the gamedev loop for some time so I feel a bit stupid asking such a (probably) simple question. :)

Link to comment
Share on other sites

You could do something like CPS (continuation passing style).  This allows you do do a promise style chaining of events, as it sounds like you have ordering.  When one turn completes then your game loop can take the next turn.  I ended up using a library called redux-saga to also handle more complex game logic like inner loops and cancellations/delays as well, but not the CPS part of that library.

Any time you rely on amount of time passed then you will likely end up with your game not working on slow machines/phones.

Link to comment
Share on other sites

I'm not sure to fully understand how the global game loop / update functions to advance game time are related to the structure of the turn-based logic. For me those 2 are disconnected ; it just means that you have different "phases" in every turn, e.g. a "planning" phase and a "transition" phase.

The game, display, entities, etc. are still advanced in both phases, but they behave differently depending on the context. In planning phases, maybe the entities, sprites, etc. (units, buildings, etc.) animate but don't move (idle anims) and react to input (mouse clicks for orders, etc.) ; while in transition phase, entities animate differently (units move, buildings gets upgraded, etc.), they don't react to input anymore, but they have extra combat logic to resolve combat encounters, etc.

Just an example, but this sounds to me like this question should be resolved at the architecture level, not in update/advance functions.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...