Answer the question
In order to leave comments, you need to log in
Dividing the game into GameStates: how?
Basically I come across examples that GameState - menu, splash screen, character selection, etc. That is, windows (it turns out, window = screen). And the game itself? For example, a game divided into levels. Level can be GameState (all object variables and other level variables)? Or is the whole game one GameState?
ps. Someone writes here on Phaser.js, does it make sense to ask questions about it?
Answer the question
In order to leave comments, you need to log in
ps. Someone writes here on Phaser.js, does it make sense to ask questions about it?
It seems to me that the very word state reflects the essence of abstraction well. Of course, it turns out that different windows are usually different states, because in different windows (and different states) the game does different things and expects different actions from the user.
I don't think that in a normal game each level should be a separate state. Try to proceed from the principle of "do not repeat." Usually the same thing happens at each level: the game waits for user input; in response to the same input at different levels, the game reacts the same way, etc. - why do you need different code for different levels? The status code (or window) of the level may not differ at all. The value of the variable changes - other data is loaded. But the algorithms are the same.
Although, of course, in the end, do what is convenient and understandable for you.
As I understand it, it all depends on you, you can set any level of abstraction
This question is also interesting! Making animation using Pixi.js I wanted to add a menu with a choice and made it a separate object with a reaction to the keys. It turned out 3 windows: a menu, a cycle with animation and a window when the cycle stops and again the transition to the menu ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question