Making a double jump using functions (capx attached)

0 favourites
  • 14 posts
From the Asset Store
Make your own platformer for both the web and mobile easy with this Santas Platformer Template, FULLY DOCUMENTED
  • Wondering if anyone can help me fix up this double jump. I am trying to make it using functions. I have it working a bit but I've obviously messed something up because it's not working the way it should.

    At the moment, the player will do a double jump if he is falling (if he walks off the platform), but he won't double jump after a standing jump.

    If I change the 'Compare instance variable' for the 'doubleJump' variable to 'less than or equal to 1' rather than 'less than 1' as it now, then the player will double jump following a standing jump, but in that case, he will do two double jumps when he is falling (if he walks off the platform).

    I want the player to be able to double jump once following a regular standing jump, and double jump once if he is falling after walking off a platform.

    I hope that makes sense. Here is the capx file

    By the way, jump is the 'Z' key.

    Thanks for any help.

  • The biggest problem is that statement: "By the way, jump is the 'Z' key."

    It is not. Why ?

    Well, the Platform-Behaviour is still running in 'Default Controls'. That makes the Up-Arrowkey the JumpKey.

    If you want different. Then you have to change the 'Default Controls' property from 'yes' to 'no' in the Platform-Behaviour.

    After that you are free to use 'z' as the JumpKey. But that means also that you have to make events for Left and Right. Once done that, everything else will be easy and work as you expect it to do.

    Maybe follow this Tut for a minute:

    /tutorials/455/platformer-enhancements-double-jump/page-1

  • Why can't you just use the default double jump ?

    All you need is this

    and this

  • laypax, I'll probably just end up using the default double jump behavior if I can't get this working. Im trying to do it with functions, basically because I think functions are like 'best practice'. I bought a game kit from the scirra store which Im using to try and learn, and all the player's movement mechanics are built out using functions to control everything: moving left and right, jumping, controlling the player shooting etc. So I am trying to build in some additional player mechanics myself, using the same system that the author has in place.

    I found some double jump tutorials, for example the one 99Instances2Go mentioned above: Platformer Enhancements - Double Jump, and tried to build that methodology into a function... It kind of works, but not quite.

    99Instances2Go, well, I dont think adding custom jumping mechanics to the 'Z' key should clash with the platform behavior should it? The arrow keys still work, and the 'Z' key works for a normal jump, and it even works for a double jump, I just have something screwed up with how the instance variable works...

    Ill keep playing with it. Thanks for the replies guys.

  • No, there is no clash. I did't expect you to read it like that. Even though, i could have written that, there are languages i write much better in.

    I tried to lead you in finding out the things by yourself.

    The default controls do what you need: A double jump when in the air.

    If you change one of the default controls, you need to take control of them all. And suddenly, as by magic, you will see the solution just by yourself.

    If i understand you correct, you want a double jump when in the air only if 'z' is pressed. In that case you also need to alter the 'up arrow', so it dont double jump. Easy as that, when you take control.

    https://

    drive.google.com/open?id=0B1SSuCVV8v74MjR5NWJWV3VpU1U

    Not that i would like play this way. I still prefer default to play.

  • Of course if u just want 'z' to be the jump key. Use the custom keys. And avoid a mess by taking control of them all.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I actually managed to get this working (amazed at self :-0). And it was such a simple thing that was stopping it from working.

    All I had to do was change the order of the events. Originally I had the events calling the 'Player_Jump' function come first in the event sheet. All I had to do was rearrange things so the events calling the 'Player_DoubleJump' function were above the events calling the 'Player_Jump' and it started working exactly how I wanted! I have no idea why the events needed to be arranged that way... to my mind it shoudn't make a difference. But what do I know!

    Yay

    fixed capx

  • Actually, event ordering is important in certain cases as event sheets run top to bottom every tick, so events at the very top will get executed first. Also, some events can clash with each other, depending on the order they're in.

    Also, made some changes if you don't mind (you're free to use this):

    https://dl.dropboxusercontent.com/u/589 ... fixed.capx

    You might also want to make the height of the double jump a bit more, as I found it slightly difficult to reach the drop through platforms from below them.

  • Hi thanks for that feedback and for the edits.. So you disabled default controls and made functions for Right and Left I see. I actually have movement functions already working in my more developed prototype (not the test capx's I posted here), but I note your tip about leaving 'Player is on floor' out of any player movement controls. Thanks for that.

    As for the order of events.. I know I have read in various tutes that event order matters, its just in this case, i can't really see why. It seems to me that it should work the same regardless of whether the input for 'double jump' comes before or after 'jump'. Not sure why it matters in this case. But never mind, its working so I am happy.

    My next challenges are: making a wall jumping behavior using functions & making a dash attack using functions.

    I have the wall jump working in a simplistic way, but not yet using functions. Dashing is hard though.

  • Maybe because since you have to jump first in order to double jump, jump functions have to come first, order wise?

    I could try to help you with the wall jumping function and dash one too, soon.

  • Well thats what makes sense to me too, but in this case having the input for the double jump before the jump is what worked lol... I dont know!

    Well any help is greatly appreciated. Thanks man. But Ill try and do them myself over coming days first to see if I can work them out.

  • I'm not really time limited as it stands, so if you send me your latest capx, I'll tinker with it when I get some freetime on my tasklists.

  • Thanks LD I really appreciate the help. Let me see what I can make first and I'll send you my efforts over the next day or two.

  • Hi again LaD. I pm'd you a capx with my attempt at making a wall jump using functions. Like my double jump that I posted at the start of this thread, the wall jump kinda works, but has bugs

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)