collinhover / impactplusplus

Impact++ is a collection of additions to ImpactJS with full featured physics, dynamic lighting, UI, abilities, and more.
http://collinhover.github.com/impactplusplus
MIT License
276 stars 59 forks source link

Multiple jump for characters #156

Closed Pattentrick closed 10 years ago

Pattentrick commented 10 years ago

Here is the multiple jump functionality we talked about. Because I already played games where you can do a triple or quadruple jump (rogue legacy for example) this is not strict for “double jumps”. Instead you can define how many additional jumps you like once you are in the air.

I made a new property canJumpRepeatedly which is also present in the config and by default false. Also there is a new property additionalJumps, where the user can define the amount of additional jumps. For example, 1 results in in one additional jump, so we have a classic double jump.

The additionalJumps property is not present in the config, because I thought that this will be specific to the entity. For example, some enemies can double jump, but just the player can do a triple jump.

There are also two new internal properties, one counter for the jumps and one for triggering the actual extra jump. I reset those at the jumpEnd method.

I modified the jump method just a little bit. Basically I just check if an additional jump is possible and modify the specific property, so that a jump will be triggered.

If you think everything is cool with the code, it would be great if you can merge this with the current dev branch. If not, please tell me how I can improve the code.

collinhover commented 10 years ago

@Pattentrick looks great! Thanks :-)