Jump/float function

Discussion in 'Programming' started by KNM, Sep 12, 2019.

  1. KNM

    KNM Member

    Joined:
    Sep 12, 2019
    Posts:
    2
    Hello, I've been using gamemaker for a while now. So far, I've learned several functions and have been able to made the player to jump, but how do I make the function more differently than simply just jumping? I'm thinking more of adding a floatish function that acts like the jump button for the game, something more like Balloon Fight. I want the player's 'jump' not to be limited and to be able to keep tapping the button multiple times until it falls, I'm thinking of the player having a balloon after all, so basically the function is floating overall. I have seen multiple tutorials about the jump function and how you can make the jump height vary, but so far, I have no idea on how to create the exact same coding I'm looking for.

    Thanks in advance.
     
  2. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    662
    Im no expert but I think you could reduce the player gravity so he falls slowly and then make it so that tapping a button increases his y position by a bit so he rises up again before coming back down.
    I once managed to achieve exactly what you are trying to do but it was unintentional....from my perspective, it was an error in my game. So I had to get rid of the code. lol.
     
    KNM likes this.
  3. Bentley

    Bentley Member

    Joined:
    Jun 18, 2017
    Posts:
    790
    I would think it'd be something like this:
    Code:
    // Rise
    if (keyboard_check_pressed(vk_up)) // Or w/e key floats
    {
        vspd = -float_speed;     
    }
    
    // Gravity
    vspd = min(vspd + grav, fall_speed); 
     
    KNM likes this.
  4. KNM

    KNM Member

    Joined:
    Sep 12, 2019
    Posts:
    2
    I see, thanks a lot for the suggestions, sorry for the late reply.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice