Managing global state for simple game in Ember.js


#1

Hi,

i’ve been playing around with developing a little Graphics Adventure Game (a bit like Monkey Island and co but much simpler :wink: ) with Ember.js over the weekend.

Its not much more than links between pages (Locations to go to) and actions (doing something in those locations) that update the game state. It works really well so far, but i’m struggling a bit what the best place for the game state is.

Right now i have a couple of global singleton objects (registered in an initialiser) that represent the player (stats), time and npc stats. For persistence i sync them with local storage when they change (so refreshing gets you back to where you have been). Each of those is rendered with its own controller either statically or in a list that checks who is present in which location. Routes manage the locations. It works really well so far, but i start to run into difficulties with managing the game state across everything, since they start to depend on each other, especially defining the possible interactions depending on the state of other objects.

Is there a better way to manage this kind of logic? I’ve been looking a bit into game-design pattern but haven’t come across anything helpful yet as its a huge topic. I’m thinking about trying to move the state from separate objects into one global, and have the application-route implement a kind of game-loop (re-calculating the state after interactions, no loop needed).