Working on a strategy game. Right now, what I've got is only nominally state-based. There's an "initializing state" that lasts a few frames at most upon startup, and then you're thrown right into a gameplay demo (just able to move units around really).
Obviously I'm gonna want menus to select options from in combat, dialogue scenes out of combat, a main menu, etc.
But what's the best practice for controlling these states, seeing as I've got multiple objects? For example, I've got a keyboard object that detects input from keys, but a cursor object that reads mouse movement and handles click events based on context (EX: selecting/deselecting units).
Of course, in a menu I don't want to mess with moving units - the mouse should only interact with the menu options. Same for the keyboard. So do I just wrap up the entire cursor/keyboard object step events in case statements to check what state the game is in? Do I do that for every object type that would need to know what state we're in (IE, don't draw units on the battlefield if there current state is a full screen menu, don't scroll the camera in that menu, etc)
Or should I rework the way my code is organized, packing everything into one "master" game object, that is in complete control of the state? The master object would handle most of the tasks I'm delegating between objects all in its own step event. Maybe by taking the step events of other objects and dividing them into scripts?
Or is there some other solution? Is there any consensus at all? I'm sure there are some guides out there, but no tutorials I've found really get into the organization of larger-scale games. So pointing me in the right direction is all I really need.
Obviously I'm gonna want menus to select options from in combat, dialogue scenes out of combat, a main menu, etc.
But what's the best practice for controlling these states, seeing as I've got multiple objects? For example, I've got a keyboard object that detects input from keys, but a cursor object that reads mouse movement and handles click events based on context (EX: selecting/deselecting units).
Of course, in a menu I don't want to mess with moving units - the mouse should only interact with the menu options. Same for the keyboard. So do I just wrap up the entire cursor/keyboard object step events in case statements to check what state the game is in? Do I do that for every object type that would need to know what state we're in (IE, don't draw units on the battlefield if there current state is a full screen menu, don't scroll the camera in that menu, etc)
Or should I rework the way my code is organized, packing everything into one "master" game object, that is in complete control of the state? The master object would handle most of the tasks I'm delegating between objects all in its own step event. Maybe by taking the step events of other objects and dividing them into scripts?
Or is there some other solution? Is there any consensus at all? I'm sure there are some guides out there, but no tutorials I've found really get into the organization of larger-scale games. So pointing me in the right direction is all I really need.