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

Code Help: Climbable and Abilities #170

Closed leoportilho closed 10 years ago

leoportilho commented 10 years ago

Hi there!

Collin thx very much for this library, it's amazing how fast I'm configuring the game (I can't say "programming" coz thats not what I'm doing right now lol)

I did all the basic tutorials and had no problem, the documentation is amazing, but I had very few issues that I solved by reading the suppercollider and jumpnrun samples.

Now I want to do some custom stuffs, but I'm complete newbie. Thats why I need some help, I dont want any code, just some logics behind them.

I want to try something like kid chameleon, the player changes costumes and powers depending of the helmet picked. Kid can climb and slide in walls, can fly, can double jump, can run faster, can be a samurai.

I know that Impact++ is the one to me, but I still need some studying.

What I intend to do:

Flying ability: My problem is what do I have to extend? I thought I could only change GravityFactor to 0 and thats all.

Climbing ability: I want to extend Shape-Climbable, put it near a wall to make possible to climb like Kid, but I want to change the fact that the player can walk out of the wall. If the player is climbing and press right/left the animation should change to one hand grabbed version. Only leaves the wallclimbing by jumping.

Wall Sliding: Same thing as before, but this time the player slides down slowly.

How to change abilities? Press tab, ability A activated, press again ability B. It's in the main or in the player that I have to code?

Change Animation Sprites after changing abilities?

Thx for the help guys!

collinhover commented 10 years ago

For changing abilities through player input, check out the player's handle input method: https://github.com/collinhover/impactplusplus/blob/master/lib/plusplus/abstractities/player.js#L156

For changing animations, you can do that by changing the sprite sheet in the entity's updateChanges method, after you've checked what ability is active. You may need some custom code to change the sprite sheet, but I know several people have done it before. Search the impact forums for ideas on that.

For flying, it should work to set the gravity factor to 0, that is how it is done for the ghost in the run n jump demo. Is this not working for you? You may need to reset the velocity of the entity as well.

For climbing and hanging off the wall with one hand, I don't know where I'd start. That is very specific to your game.

For wall sliding, you'll need to add that behavior to your entity and probably change the friction while the entity if colliding with a wall horizontally. I think the collision map result may help you determine that, see https://github.com/collinhover/impactplusplus/blob/master/lib/plusplus/core/entity.js#L169.

Hope this helps you get started!