GameStates

I'm new to the jme scene and i'm trying to understand a few things.

I've read all these documents about the gamestates and it seems it's the best way to implement a complex multiplayer (not hotseat) game.

This seems to be the best explanation of the game states and standard game that i found:

http://www.jmonkeyengine.com/wiki/doku.php?id=some_standardgame_frequently_asked_questions

However I don't get some things:

  1. All the gamestates run in the opengl thread. So where is the multithreading that is provided here?


  2. If the above statement is wrong and each gamestate has it's own thread then would it be better if u create:
  • A gamestate for game graphics (low priority)
  • A gamestate for GUI graphics ( normal priority)
  • A gamestate for input devices (high priority)
  • A gamestate for networking (high priority)
  • A gamestate for game logic (high priority)
  • A gamestate for main menu (normal priority)

    right? Is there a jme way of setting priorities?


  1. Can a gamestate affect another gamestate graphics directly? For example having a gamestate with a lightsource will this lightsource affect Nodes in other gamestates?
  2. if i want some graphical features of the game that will only affect visually and might take a lot of processing. Should i put them in a gamestate and disable/enable it according to options or it's better to simply have an if statement for every feature in the update() of the same gamestate and skip the rendering?

GameStates all run in a single thread and really have nothing to do with multi-threading, they are just an added feature to StandardGame, which provides many things, one of them being assistance in multi-threading.  StandardGame has a start() method that starts its own thread for the OpenGL execution and exists apart from the main game loop. This is really the majority of the multi-threading functionality provided.  This is why I keep saying there's nothing specific about StandardGame that makes you create everything from another thread, rather it just simplifies this ability if it is desired.

So if i got this straight: :-o



StandardGame is simply 1 thread. (the opengl thread) and whatever gamestates you dump inside will all run in the opengl thread created in standardgame.

So in reality if you want to have the game logic and game rendering in a seperate threads you'll need to have 1 StandardGame instance for the graphics (doh openGL) and another thread for your game logic which must be completely independed if u have a slow pc that u want the game logic to continue even if the graphics are not rendered in time (ex. realtime multiplayer games).



I hope this is correct cause it makes things very clear to my puny little brain  :smiley:

That's about right. :wink: