0

1) The extreme case: I have 10 states and 10 possible actions to perform (that result in state transitions). But each of these actions are only allowed in their particular state. State 1 can only perform action 1, State 2 action 2, and so on (a simple graph that only goes forward)

2) The opposite case: I have 10 states and 10 possible actions to perform, each of them are allowed in every state. Some of them behave exactly in the same way among a couple of states, some behave exactly the same in every state and some others work differently in each (like a strategy)

I have presented 2 extreme scenarios. I'd like to have opinions on what to do. Combining patterns will be good too.

jaco0646
  • 15,303
  • 7
  • 59
  • 83
Pato Loco
  • 1,205
  • 1
  • 13
  • 29

1 Answers1

0

Think of states as phases in a simple game. You have a title state, menu state (plus any sub-menus that would inherit from the main menu state), the actual game state, and maybe a credits state. Each of these individual states has its own functionality and purpose, and they are not shared, else why would it need its own state?

If you have functionality that is shared between states, you should look into some sort of inheritance. In my example, that would involve making a base menu state, then an individual menu state for each menu (main menu, options menu, graphics menu, audio menu, etc, etc) that would inherit from the base menu state. In this way, you allow some/all functionality to be shared between the states, because the purpose of the individual states are very similar.

Does this help? I don't feel like I can answer your actual question unless you provide more specific details about what you're trying to accomplish.

Deactivator2
  • 311
  • 1
  • 10