Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualcrancran

Posted 17 April 2012 - 11:21 AM

Usually, I'll have something like: title_state, menu, level1, level2, pause_menu, for example. But if each component is updating every loop (via the component managers) then surely having a state class with event/update/render functions (which mine have always had) wouldn't be needed since the component managers are being called every loop independently? The only role I can see for my game states now is just to load/remove any game entities relevant for that state. I guess it'll just take a bit of tweaking.


Your game states should also respond to the event system as well.  

For example, you may want your Level state to shift to the Game Menu state after the player hits the ESCAPE button.  Depending on the current state (avatar has a target or has no target) would drive whether you progress to the new state or not but the Level State would need to subscribe to the E_STATE_CHANGE event that gets triggered if a state change was needed.

Steps:
1. Keyboard Component receives ESC
2. Keyboard Component checks if entity has Target
3. If Target, dispatch E_TARGET_BLUR event to deselect target then end.
4. If No Target, dispatch E_STATE_CHANGE event with state id "GameMenu" then end.

#4crancran

Posted 17 April 2012 - 11:20 AM

Usually, I'll have something like: title_state, menu, level1, level2, pause_menu, for example. But if each component is updating every loop (via the component managers) then surely having a state class with event/update/render functions (which mine have always had) wouldn't be needed since the component managers are being called every loop independently? The only role I can see for my game states now is just to load/remove any game entities relevant for that state. I guess it'll just take a bit of tweaking.


Your game states should also respond to the event system as well.  For example, you may want your Level state to shift to the Game Menu state after the player hits the ESCAPE button.  Depending on the current state (avatar has a target or has no target) would drive whether you progress to the new state or not but the Level State would need to subscribe to the E_STATE_CHANGE event that gets triggered if a state change was needed.

Steps:
1. Keyboard Component receives ESC
2. Keyboard Component checks if entity has Target
3. If Target, dispatch E_TARGET_BLUR event to deselect target then end.
4. If No Target, dispatch E_STATE_CHANGE event with state id "GameMenu" then end.

#3crancran

Posted 17 April 2012 - 11:20 AM

Usually, I'll have something like: title_state, menu, level1, level2, pause_menu, for example. But if each component is updating every loop (via the component managers) then surely having a state class with event/update/render functions (which mine have always had) wouldn't be needed since the component managers are being called every loop independently? The only role I can see for my game states now is just to load/remove any game entities relevant for that state. I guess it'll just take a bit of tweaking.


Your game states should also respond to the event system as well.  For example, you may want your Level state to shift to the Game Menu state after the player hits the ESCAPE button.  Depending on the current state (avatar has a target or has no target) would drive whether you progress to the new state or not but the Level State would need to subscribe to the E_STATE_CHANGE event that gets triggered if a state change was needed.

Steps:
1. Keyboard Component receives ESC
2. Keyboard Component checks if entity has Target
3. If Target, deselect target then end.
4. If No Target, dispatch E_STATE_CHANGE event with state id "GameMenu" then end.

#2crancran

Posted 17 April 2012 - 11:18 AM

Usually, I'll have something like: title_state, menu, level1, level2, pause_menu, for example. But if each component is updating every loop (via the component managers) then surely having a state class with event/update/render functions (which mine have always had) wouldn't be needed since the component managers are being called every loop independently? The only role I can see for my game states now is just to load/remove any game entities relevant for that state. I guess it'll just take a bit of tweaking.


Your game states should also respond to the event system as well.  For example, you may want your Level state to shift to the Game Menu state after the player hits the ESCAPE button.  Depending on the current state (avatar has a target or has no target) would drive whether you progress to the new state or not but the Level State would need to subscribe to the E_STATE_CHANGE event that gets triggered.

#1crancran

Posted 17 April 2012 - 11:18 AM

Usually, I'll have something like: title_state, menu, level1, level2, pause_menu, for example. But if each component is updating every loop (via the component managers) then surely having a state class with event/update/render functions (which mine have always had) wouldn't be needed since the component managers are being called every loop independently? The only role I can see for my game states now is just to load/remove any game entities relevant for that state. I guess it'll just take a bit of tweaking.

Your game states should also respond to the event system as well.  For example, you may want your Level state to shift to the Game Menu state after the player hits the ESCAPE button.  Depending on the current state (avatar has a target or has no target) would drive whether you progress to the new state or not but the Level State would need to subscribe to the E_STATE_CHANGE event that gets triggered.

PARTNERS