Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualpunkcoders

Posted 22 September 2013 - 09:23 AM

To program behaviors of games like princeofpersia-flashback-abe-etc you need a state machine. Each character is managed like a mini-application with a small sub-program for each action.

 

First have a look to the design pattern state (google is your friend). For characters you can make simple states with at least 2 events: start(), routine(). (i think it does not need stop, pause, resume, etc)

 

Create a CharacterStateManager motherclass ( with its events routine() and changestate() ). It needs a "frame-timer" variable to control the end of states. On every changeState call the frame-timer must be reset to 0. The routine call only one state routine at once. Each character is an instance of CharacterStateManager.

 

Then, for each action (most will be shared by all characters) make an abstract motherclass CharacterState with empty functions to make sure there won't be any call of undefined function. Then, each character will use one instance of each state class.

 

Examples:

 

- standing up state. on start() event set the frame of character standing up. on routine() event, wait for an action input (keypress for player, ia for non-player, or hit), and when key pressed, call changeState( TheNextState );

 

- crouching state. on start() event change height of hitBox .on routine() event, display the frames or crouching animation. When finished, call a changeState to te crouched state

 

- crouched state. on routine() event, wait the input for standing up (release key "down" for player, ia for non player)

 

- standing state. on start() event change height of hitBox. on routine() event, play in reverse the crouching animation frames and change height of hitbox, when finished, call a changeState to the standing up state.

 

- walking state. on routine() event, play animation. Each time character reach a new tile, chek the input (ia or keyboard or hit), if no change state then carry on walking.

 

- etc...

 

 

I developed a game like this a long time ago, was really more simple than flashback or abe, the states i used for all characters were: standing, walking on floor, walking on stairs up, walking stairs down, jumping, falling, knocked, speaking.

 

good work !

 

 

P.S. do not forget to manage your characters with an object pool, because javascript garbage collector is a pure crap you cannot trust on. So, do not subclass the CharacterStateManager, use a "behavior" index instead, and use it to reference global or static functions.


#7punkcoders

Posted 22 September 2013 - 09:22 AM

To program behaviors of games like princeofpersia-flashback-abe-etc you need a state machine. Each character is managed like a mini-application with a small sub-program for each action.

 

First have a look to the design pattern state (google is your friend). You NEED tu master this state in all modern games cos now they're all divided in subprograms (intro, menu, cinematics, loading level, playing level, demo in one level, hall of scores...). You can make simple states with at least 2 events: start(), routine(). (i think it does not need stop, pause, resume, etc)

 

Create a CharacterStateManager motherclass ( with its events routine() and changestate() ). It needs a "frame-timer" variable to control the end of states. On every changeState call the frame-timer must be reset to 0. The routine call only one state routine at once. Each character is an instance of CharacterStateManager.

 

Then, for each action (most will be shared by all characters) make an abstract motherclass CharacterState with empty functions to make sure there won't be any call of undefined function. Then, each character will use one instance of each state class.

 

Examples:

 

- standing up state. on start() event set the frame of character standing up. on routine() event, wait for an action input (keypress for player, ia for non-player, or hit), and when key pressed, call changeState( TheNextState );

 

- crouching state. on start() event change height of hitBox .on routine() event, display the frames or crouching animation. When finished, call a changeState to te crouched state

 

- crouched state. on routine() event, wait the input for standing up (release key "down" for player, ia for non player)

 

- standing state. on start() event change height of hitBox. on routine() event, play in reverse the crouching animation frames and change height of hitbox, when finished, call a changeState to the standing up state.

 

- walking state. on routine() event, play animation. Each time character reach a new tile, chek the input (ia or keyboard or hit), if no change state then carry on walking.

 

- etc...

 

 

I developed a game like this a long time ago, was really more simple than flashback or abe, the states i used for all characters were: standing, walking on floor, walking on stairs up, walking stairs down, jumping, falling, knocked, speaking.

 

good work !

 

 

P.S. do not forget to manage your characters with an object pool, because javascript garbage collector is a pure crap you cannot trust on. So, do not subclass the CharacterStateManager, use a "behavior" index instead, and use it to reference global or static functions.


#6punkcoders

Posted 22 September 2013 - 09:10 AM

To program behaviors of games like princeofpersia-flashback-abe-etc you need a state machine. It's really more complex than a mario-like routine. Each character is managed like a mini-application with a small sub-program for each action.

 

First have a look to the design pattern state (google is your friend). You NEED tu master this state in all modern games cos now they're all divided in subprograms (intro, menu, cinematics, loading level, playing level, demo in one level, hall of scores...). You can make simple states with at least 2 events: start(), routine(). (i think it does not need stop, pause, resume, etc)

 

Create a CharacterStateManager motherclass ( with its events routine() and changestate() ). It needs a "frame-timer" variable to control the end of states. On every changeState call the frame-timer must be reset to 0. The routine call only one state routine at once. Each character is an instance of CharacterStateManager.

 

Then, for each action (most will be shared by all characters) make an abstract motherclass CharacterState with empty functions to make sure there won't be any call of undefined function. Then, each character will use one instance of each state class.

 

Examples:

 

- standing up state. on start() event set the frame of character standing up. on routine() event, wait for an action input (keypress for player, ia for non-player, or hit), and when key pressed, call changeState( TheNextState );

 

- crouching state. on start() event change height of hitBox .on routine() event, display the frames or crouching animation. When finished, call a changeState to te crouched state

 

- crouched state. on routine() event, wait the input for standing up (release key "down" for player, ia for non player)

 

- standing state. on start() event change height of hitBox. on routine() event, play in reverse the crouching animation frames and change height of hitbox, when finished, call a changeState to the standing up state.

 

- walking state. on routine() event, play animation. Each time character reach a new tile, chek the input (ia or keyboard or hit), if no change state then carry on walking.

 

- etc...

 

 

I developed a game like this a long time ago, was really more simple than flashback or abe, the states i used for all characters were: standing, walking on floor, walking on stairs up, walking stairs down, jumping, falling, knocked, speaking.

 

good work !

 

 

P.S. do not forget to manage your characters with an object pool, because javascript garbage collector is a pure crap you cannot trust on. So, do not subclass the CharacterStateManager, use a "behavior" index instead, and use it to reference global or static functions.


#5punkcoders

Posted 22 September 2013 - 09:09 AM

To program behaviors of games like princeofpersia-flashback-abe-etc you need a state machine. It's really more complex than a mario-like routine. Each character is managed like a mini-application with a small sub-program for each action.

 

First have a look to the design pattern state (google is your friend). You NEED tu master this state in all modern games cos now they're all divided in subprograms (intro, menu, cinematics, loading level, playing level, demo in one level, hall of scores...). You can make simple states with at least 2 events: start(), routine(). (i think it does not need stop, pause, resume, etc)

 

Create a CharacterStateManager motherclass ( with its events routine() and changestate() ). It needs a "frame-timer" variable to control the end of states. On every changeState call the frame-timer must be reset to 0. The routine call only one state routine at once. Each character is an instance of CharacterStateManager.

 

Then, for each action (most will be shared by all characters) make an abstract motherclass CharacterState with empty functions to make sure there won't be any call of undefined function. Then, each character will use one instance of each state class.

 

Examples:

 

- standing up state. on start() event set the frame of character standing up. on routine() event, wait for an action input (keypress for player, ia for non-player, or hit), and when key pressed, call changeState( TheNextState );

 

- crouching state. on start() event change height of hitBox .on routine() event, display the frames or crouching animation. When finished, call a changeState to te crouched state

 

- crouched state. on routine() event, wait the input for standing up (release key "down" for player, ia for non player)

 

- standing state. on start() event change height of hitBox. on routine() event, play in reverse the crouching animation frames and change height of hitbox, when finished, call a changeState to the standing up state.

 

- walking state. on routine() event, play animation. Each time character reach a new tile, chek the input (ia or keyboard or hit), if no change state then carry on walking.

 

- etc...

 

 

I developed a game like this a long time ago, was really more simple than flashback or abe, the states i used for all characters were: standing, walking on floor, walking on stairs up, walking stairs down, jumping, falling, knocked, speaking.

 

good work !

 

 

P.S. do not forget to manage your characters with an object pool, because javascript garbage collector is a pure crap you cannot trust on. So, do not subclass the CharacterStateManager, instead, use a "behavior" index instead.


#4punkcoders

Posted 22 September 2013 - 09:08 AM

To program behaviors of games like princeofpersia-flashback-abe-etc you need a state machine. It's really more complex than a mario-like routine. Each character is managed like a mini-application with a small sub-program for each action.

 

First have a look to the design pattern state (google is your friend). You NEED tu master this state in all modern games cos now they're all divided in subprograms (intro, menu, cinematics, loading level, playing level, demo in one level, hall of scores...). You can make simple states with at least 2 events: start(), routine(). (i think it does not need stop, pause, resume, etc)

 

Create a CharacterStateManager motherclass ( with its events routine() and changestate() ). It needs a "frame-timer" variable to control the end of states. On every changeState call the frame-timer must be reset to 0. The routine call only one state routine at once. Each character is an instance of CharacterStateManager.

 

Then, for each action (most will be shared by all characters) make an abstract motherclass CharacterState with empty functions to make sure there won't be any call of undefined function. Then, each character will use one instance of each state class.

 

Examples:

 

- standing up state. on start() event set the frame of character standing up. on routine() event, wait for an action input (keypress for player, ia for non-player, or hit), and when key pressed, call changeState( TheNextState );

 

- crouching state. on start() event change height of hitBox .on routine() event, display the frames or crouching animation. When finished, call a changeState to te crouched state

 

- crouched state. on routine() event, wait the input for standing up (release key "down" for player, ia for non player)

 

- standing state. on start() event change height of hitBox. on routine() event, play in reverse the crouching animation frames and change height of hitbox, when finished, call a changeState to the standing up state.

 

- walking state. on routine() event, play animation. Each time character reach a new tile, chek the input (ia or keyboard or hit), if no change state then carry on walking.

 

- etc...

 

 

I developed a game like this a long time ago, was really more simple than flashback or abe, the states i used for all characters were: standing, walking on floor, walking on stairs up, walking stairs down, jumping, falling, knocked, speaking.

 

good work !

 

 

P.S. do not forget to manage your characters with an object pool, because javascript garbage collector is a pure crap you cannot trust on. So, do not subclass the CharacterStateManager, instead, use a "behavior" object or index instead.


#3punkcoders

Posted 22 September 2013 - 09:07 AM

To program behaviors of games like princeofpersia-flashback-abe-etc you need a state machine. It's really more complex than a mario-like routine. Each character is managed like a mini-application with a small sub-program for each action.

 

First have a look to the design pattern state (google is your friend). You NEED tu master this state in all modern games cos now they're all divided in subprograms (intro, menu, cinematics, loading level, playing level, demo in one level, hall of scores...). You can make simple states with at least 2 events: start(), routine(). (i think it does not need stop, pause, resume, etc)

 

Create a CharacterStateManager motherclass ( with its events routine() and changestate() ). It needs a "frame-timer" variable to control the end of states. On every changeState call the frame-timer must be reset to 0. The routine call only one state routine at once. Each character is an instance of CharacterStateManager.

 

Then, for each action (most will be shared by all characters) make an abstract motherclass CharacterState with empty functions to make sure there won't be any call of undefined function. Then, each character will use one instance of each state class.

 

Examples:

 

- standing up state. on start() event set the frame of character standing up. on routine() event, wait for an action input (keypress for player, ia for non-player, or hit), and when key pressed, call changeState( TheNextState );

 

- crouching state. on start() event change height of hitBox .on routine() event, display the frames or crouching animation. When finished, call a changeState to te crouched state

 

- crouched state. on routine() event, wait the input for standing up (release key "down" for player, ia for non player)

 

- standing state. on start() event change height of hitBox. on routine() event, play in reverse the crouching animation frames and change height of hitbox, when finished, call a changeState to the standing up state.

 

- walking state. on routine() event, play animation. Each time character reach a new tile, chek the input (ia or keyboard or hit), if no change state then carry on walking.

 

- etc...

 

 

I developed a game like this a long time ago, was really more simple than flashback or abe, the states i used for all characters were: standing, walking on floor, walking on stairs up, walking stairs down, jumping, falling, knocked, speaking.

 

good work !

 

 

P.S. do not forget to manage your characters with an object pool, because javascript garbage collector is a pure crap. So, do not subclass the CharacterStateManager, instead, use a "behavior" object or index instead.


PARTNERS