Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualKhatharr

Posted 30 November 2012 - 08:16 AM

Typically an individual game state is one of several available methods for creating an interface between the user and the game's "hidden" persistent state.

For instance, for an RPG you're walking around on the world map and you hit the button to being up the menu. You change game states to do this. Once you're done checking your items you close the menu. Now if you were storing your player's position and etc in the map state then you're going to find a problem here since when closing the map state you lost all that information. (Unless you're using a stack-style state manager, which is something that was mentioned to me recently and sounds like it would be fun to try out.)

If you have a map class that encapsulates that information then you can use your map state to represent and interact with that information. Then when you close the menu you just switch back to the map state and it can pick up right where it left off because the map class object is part of the persistent state rather than the gamestate. Likewise, if you move to a new map your map state just fades the screen, replaces the current map class object, then fades the screen back in.

Having your game states clearly separated from the game's persistent state (this is why I call them 'scenes' instead of 'game states', lol) also makes it a lot easier to do things like saving and loading the game. All of the data that you would want to save or load will belong to the persistent state rather than the scene/gamestate.

Typically I assign the following responsibilities to a scene/gamestate:
  • load or acquire the graphics, audio and other resources required to represent the state
  • react to user input
  • provide the user with a means of affecting the persistent state (the menu scene gives an interface for changing the inventory, the map scene changes your location, etc)
  • represent the persistent state in a meaningful way to the player using the audio/video/etc resources that were loaded
  • perform logic, including trigger AI updates or trigger the update of any continual process in the game world, such as physics, etc (depending on the game type these things may be triggered outside for an un-pausable game)
That's the general idea as I see it, anyway. This is a subject that I'm presently reviewing, however.

Hope that helps.

#3Khatharr

Posted 30 November 2012 - 08:15 AM

Typically an individual game state is one of several available methods for creating an interface between the user and the game's "hidden" persistent state.

For instance, for an RPG you're walking around on the world map and you hit the button to being up the menu. You change game states to do this. Once you're done checking your items you close the menu. Now if you were storing your player's position and etc in the map state then you're going to find a problem here since when closing the map state you lost all that information. (Unless you're using a stack-style state manager, which is something that was mentioned to me recently and sounds like it would be fun to try out.)

If you have a map class that encapsulates that information then you can use your map state to represent and interact with that information. Then when you close the menu you just switch back to the map state and it can pick up right where it left off because the map class object is part of the persistent state rather than the gamestate. Likewise, if you move to a new map your map state just fades the screen, replaces the current map class object, then fades the screen back in.

Having your game states clearly separated from the game's persistent state (this is why I call them 'scenes' instead of 'game states', lol) also makes it a lot easier to do things like saving and loading the game. All of the data that you would want to save or load will belong to the persistent state rather than the scene/gamestate.

Typically I assign the following responsibilities to a scene/gamestate:
  • load or acquire the graphics, audio and other resources required to represent the state
  • react to user input
  • provide the user with a means of affecting the persistent state (the menu scene gives an interface for changing the inventory, the map scene changes your location, etc)
  • represent the persistent state in a meaningful way to the player using the audio/video/etc resources that were loaded
  • trigger AI updates or trigger the update of any continual process in the game world, such as physics, etc (depending on the game type these things may be triggered outside for an un-pausable game)
That's the general idea as I see it, anyway. This is a subject that I'm presently reviewing, however.

Hope that helps.

#2Khatharr

Posted 30 November 2012 - 08:12 AM

Typically an individual game state is one of several available methods for creating an interface between the user and the game's "hidden" persistent state.

For instance, for an RPG you're walking around on the world map and you hit the button to being up the menu. You change game states to do this. Once you're done checking your items you close the menu. Now if you were storing your player's position and etc in the map state then you're going to find a problem here since when closing the map state you lost all that information. (Unless you're using a stack-style state manager, which is something that was mentioned to me recently and sounds like it would be fun to try out.)

If you have a map class that encapsulates that information then you can use your map state to represent and interact with that information. Then when you close the menu you just switch back to the map state and it can pick up right where it left off because the map class object is part of the persistent state rather than the gamestate. Likewise, if you move to a new map your map state just fades the screen, replaces the current map class object, then fades the screen back in.

Having your game states clearly separated from the game's persistent state (this is why I call them 'scenes' instead of 'game states', lol) also makes it a lot easier to do things like saving and loading the game. All of the data that you would want to save or load will belong to the persistent state rather than the scene/gamestate.

Typically I assign the following responsibilities to a scene/gamestate:
  • load or acquire the graphics, audio and other resources required to represent the state
  • react to user input
  • provide the user with a means of affecting the persistent state (the menu scene gives an interface for changing the inventory, the map scene changes your location, etc)
  • represent the persistent state in a meaningful way to the player using the audio/video/etc resources that were loaded
That's the general idea as I see it, anyway. This is a subject that I'm presently reviewing, however.

Hope that helps.

#1Khatharr

Posted 30 November 2012 - 08:09 AM

Typically an individual game state is one of several available methods for creating an interface between the user and the game's "hidden" persistent state.

For instance, for an RPG you're walking around on the world map and you hit the button to being up the menu. You change game states to do this. Once you're done checking your items you close the menu. Now if you were storing your player's position and etc in the map state then you're going to find a problem here since when closing the map state you lost all that information. (Unless you're using a stack-style state manager, which is something that was mentioned to me recently and sounds like it would be fun to try out.)

If you have a map class that encapsulates that information then you can use your map state to represent and interact with that information. Then when you close the menu you just switch back to the map state and it can pick up right where it left off. Likewise, if you move to a new map your map state just fades the screen, replaces the current map class object, then fades the screen back in.

Having your game states clearly separated from the game's persistent state (this is why I call them 'scenes' instead of 'game states', lol) also makes it a lot easier to do things like saving and loading the game. All of the data that you would want to save or load will belong to the persistent state rather than the scene/gamestate.

Typically I assign the following responsibilities to a scene/gamestate:
  • load or acquire the graphics, audio and other resources required to represent the state
  • react to user input
  • provide the user with a means of effecting the persistent state (the menu scene gives an interface for changing the inventory, the map scene changes your location, etc)
  • represent the persistent state in a meaningful way to the player using the audio/video/etc resources that were loaded

That's the general idea as I see it, anyway. This is a subject that I'm presently reviewing, however.

Hope that helps.

PARTNERS