How to manage global gameState?
Unanswered
Mini Rex posted this in #help-forum
Mini RexOP
How would you guys recommend handling gamestate in next.js/react for something with a timer that should be accesible across the website? I was thinking doing something to the effect of creating a zustand store to keep track of my gameState attributes but im not sure if there is a better way.
4 Replies
Plott Hound
What is gameState? Are you using useState?
For accurate timer you’ll want to store the start time somewhere and calculate the difference for accuracy. You could use a normal state, local storage or a database to store this
@Plott Hound For accurate timer you’ll want to store the start time somewhere and calculate the difference for accuracy. You could use a normal state, local storage or a database to store this
Mini RexOP
gameState will be represented by an instance of this object
i wanted a centralized location to interact with my games state whch can be modified by things other than just player interaction