N
N
nevro2015-07-17 23:35:28
JavaScript
nevro, 2015-07-17 23:35:28

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

4 answer(s)
E
Evgeny Shatunov, 2015-07-18
@nevro

ps. Someone writes here on Phaser.js, does it make sense to ask questions about it?

This is not a forum, here the format of communication is a question-answer. One question from you and many answers from others.
Write with the javascript or phaser-js tag and you will probably get an answer.
About the organization: as your heart desires. But it is better to approach the issue analytically.
How do you change levels? Is there a screen between scenes?
If there is, then it is more convenient to make the gameplay in two stages - the stage of the game scene and the stage of the screen. If there is no screen and the gameplay is not interrupted between levels, then it is better to arrange it in one stage.
Here is my answer: Approach the question analytically, understand what will be more convenient for your gameplay structure. You did not give any information on your question, so you can hardly expect clear answers. Asam the question is very simple.

L
localghost, 2015-07-18
@localghost

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.

M
Misha Kogan, 2015-07-18
@Kogan4ik

As I understand it, it all depends on you, you can set any level of abstraction

D
Dmitry, 2015-08-07
@Dit81

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 question

Ask a Question

731 491 924 answers to any question