Gamestates question

darkfog said basegame is the stone-age, so i decided to use standardgame + gamestates.



now i need to convert all my code from basegame to standardgame+gamestates. and i have some newbie questions :smiley:



what to do with initgame method in basegame.

in the initgame method, i initialize all the terrain, camera, player, input and everything. should i just put everyone of them into a seperate gamestate?



should the input system also be a gamestate? :?

hehe…I'm sorry, I didn't expect you to take me so literally.  Personally I think StandardGame is a much better way to go about game development, but there's really nothing wrong with the way you were going.  However, if you're ready to get on-board the StandardGame bus I'll do my best to help you get there.



init game method code would be introduced into the constructors of your GameStates most likely.  Move what makes sense into its own GameState.  For example, in GalaxiesBeyond I have a universal game state (one that is always enabled no matter what's going on - for console controls, special hotkeys, etc.), a menu game state, a in-game game state, a HUD game state, and a Panels game state (for UI components that you can interact with in the game).



The primary thing to think about in splitting them out is having the ability to enable/disable and load/unload modularly.  However, even inside your GameState you can enable/disable add/remove aspects, so it really is up to the developer how they choose to implement this functionality.  Just try to separate things into a logical groupings that make things easier for you to work with and also make it easier to manage long-term.


neakor said:

should the input system also be a gamestate? :?


You can if you like, but I would probably group it with your actual in-game game state.  Also, while you're making the move forward to "now" you might take a look at GameControlManager as it's a very nice alternative to InputHandler. ;)

thx for the reply~ive studying really hard :smiley:



another 3 questions.


  1. i saw that basicgamestate comes with zbufferstate, does standardgame comes with cullstate?




  2. i created a universalState which contains the skybox, inputhotkeys, cullstate, light, fog and mouse. but the mouse cursor doesnt show up~ this is what i did


      // Create the mouse.
      MouseInput.get().setCursorVisible(true);
      // Use hardware mouse and give it a new cursor.
      URL url = this.getClass().getClassLoader().getResource("cursor.png");
      MouseInput.get().setHardwareCursor(url);
      // Assign it to a listener.
      MouseListener listener = new MouseListener();
      MouseInput.get().addListener(listener);



3. when i try to do skybox.preloadtextures(); it gives me a nullpointer exception. what have i done wrong?
    my skybox is created inside the universalState and attached to the universalState's rootnode


HELP :'(

Did you read my tutorials about using StandardGame and GameStates?  If you haven't already that would be good knowledge.



Both of those portions of code need to be done in the OpenGL thread, so if you simply wrap those calls in a GameTaskQueue update call that should take care of it for you.

oh~ thats y :lol:



sry for the newbie question, and i actually read those tutorials. guess i need to pay more attention ha ~ thx alot :smiley: