1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Platformers Part 2 - Quick Sand, Wall Jumping, Gliding

Discussion in 'Tutorials' started by GMLWaffle, Sep 18, 2016.

  1. GMLWaffle

    GMLWaffle Member

    Joined:
    Sep 4, 2016
    Posts:
    38
    SilentxxBunny and Stretchcb3 like this.
  2. Blakkid489

    Blakkid489 Member

    Joined:
    Jun 30, 2016
    Posts:
    257
    Awesome once again. Any thought on double jumping?
     
  3. GMLWaffle

    GMLWaffle Member

    Joined:
    Sep 4, 2016
    Posts:
    38
    I could add double jumping into part 3 if you'd like. Right now part 3 is set up for ladders and ledge grabbing, but I could add double jumping in there. ;)
     
  4. Blakkid489

    Blakkid489 Member

    Joined:
    Jun 30, 2016
    Posts:
    257
    Subscribed :D

    EDIT: My main problem is with double jumping allowing the player to fall off the plat and jump in mid air.
     
  5. GMLWaffle

    GMLWaffle Member

    Joined:
    Sep 4, 2016
    Posts:
    38
    Ah glad you said something about that! I've recorded part 3, and it came out a bit longer than I had wanted it to, so unfortunately I wasn't able to fit it in part 3, however it will be first priority in part 4! But for the sake of you getting an answer quickly, how exactly are you trying to set it up?

    the best way would be to create a Boolean variable called dblJump = false in the create event, then in the step event check for this:
    Code:
    if (!place_meeting(x,y+1,con_wall)) && !dblJump {
        dblJump = true;
    }
    
    if (dblJump) && (jumpKey) {
        vsp -= jumpspeed;
        dblJump = false;
    }
    this will check for collision below you, and if there is none, set dblJump equal to true, then if it's true it will allow you to jump once before resetting itself back to false.
     
  6. Blakkid489

    Blakkid489 Member

    Joined:
    Jun 30, 2016
    Posts:
    257
  7. GMLWaffle

    GMLWaffle Member

    Joined:
    Sep 4, 2016
    Posts:
    38
    Ahhhh okay you don't want him to be able to jump after walking off a platform xD alright so to fix this it's kind of a similar process to the code I shared before, however we're going to set it up to say if the player has already jumped, then dblJump = true.

    So here's our create event:
    Code:
    dblJump = false;
    dblJumpCount = 2;
    and here's what we're adding to the step event:
    Code:
    //dblJumping
    if (place_meeting(x,y+1,con_wall)) && (jumpKey) && (!dblJump) {
        dblJump = true;
    } else if (place_meeting(x,y+1,con_wall)) && (dblJump) {
        dblJump = false;
        dblJumpCount = 2;
    }
    
    if (dblJump) && (dblJumpCount >= 1) {
        if (jumpKey) {
            vsp = jumpKey * -jumpspeed;
            dblJumpCount -= 1;
        }
    }
    this will set our dblJump variable to only be true if we've jumped directly off of the wall controller object. This also puts a limit to the number of double jumps you get, in this case the variable is set to two, but you really only get one extra double jump. Hope this helps!

    EDIT: btw, nice video response!
     
  8. Blakkid489

    Blakkid489 Member

    Joined:
    Jun 30, 2016
    Posts:
    257
    Awesome. I got it now. I was using the dblJump in the wrong way. Tahnaks a bunch. looking forward to more videos. I've already shared your channel around :D
     
  9. Mister Bread

    Mister Bread Guest

    Hey, great tutorial! Quick question about the wall jumping.

    Is there any way to limit the wall jumping so you can't "climb" the walls by pressing the jump key several times?

    I tried combining the double jump code from your other video with the wall jump code, but it didn't seem to work. Any suggestions?
     
  10. GMLWaffle

    GMLWaffle Member

    Joined:
    Sep 4, 2016
    Posts:
    38
    basically the same thing as the double jump code, but instead of checking for collision the second time with the object below you, check for collision with the wall to either side of the player. so if (!place_free(x-5,y) && !place_free(x+5,y) then do the jump. If this doesn't help, I'll work on a script for you tomorrow as it's rather late here.
     
  11. Mister Bread

    Mister Bread Guest

    Wow, quick response! Thank you.

    I messed around with the code a bit before I rechecked the forum and this is what I came up with. It seems to work as intended...

    Code:
    //Wall Jump
    
    if (key_jump) && (place_meeting(x+1,y,obj_wall) || place_meeting(x-1,y,obj_wall) && (!doublejump))
    {
        doublejump = false;
        doublejumpcount = 1;
        vspd = -jumpspeed;
    }
    
    and combing this with the double jump code...

    Code:
    //Double Jump
    if (place_meeting(x,y+1,obj_wall)) && (key_jump) && (!doublejump) {
        doublejump = true;
    } else if (place_meeting(x,y+1,obj_wall)) && (doublejump) {
        doublejump = false;
        doublejumpcount = 2;
    }
    
    if (doublejump) && (doublejumpcount >= 1) {
        if (key_jump) {
            vspd = key_jump * -jumpspeed;
            doublejumpcount -= 1;
        }
    }
    This way when colliding with the wall object, it'll set the doublejumpcount to 1 and only allow a second jump.

    Haven't noticed any issues while quickly testing it. Do you think this is a decent solution? Still getting used to GML and hope this is sound coding.
     
  12. GMLWaffle

    GMLWaffle Member

    Joined:
    Sep 4, 2016
    Posts:
    38
    pretty well! Almost identical code to the double jump, which does virtually the same thing! (I would have posted code myself, but I've been busy sharing a Liquid Physics example all over the place).

    Hope I was at least of some help!
     
  13. Mister Bread

    Mister Bread Guest

    Only issue I'm just noticing is that the place_meeting(x+1) code doesn't seem to be working... I have a room with walls on the left and right, and the left wall works fine with the code but the right wall doesn't...

    I'll try your idea and see if that works any different.


    EDIT :

    I edited the code line to replace the || with && and it seems to have worked.

    Again, thank you for your quick reply and the help! I'll be looking forward to more of your tutorials as they're incredibly quick and concise.
     
  14. GMLWaffle

    GMLWaffle Member

    Joined:
    Sep 4, 2016
    Posts:
    38
    let me just open up the project file for these tutorials, and i'll write something up quickly

    EDIT: to no luck tonight, I'll have to spend more time on it tomorrow
     
    Last edited: Sep 30, 2016
  15. carzo

    carzo Guest

    Hello Mr GMLWaffle.

    Firstly: Thank you very much for doing this tutorials series.

    I have adapted your quicksands script to my movement with aceleration engine.

    I have a question:

    Why do you need to create an alarm?

    Some guy asked the same in the YouTube comments but I don't understand your reply. Mine works perfectly without an alarm.
     
    Last edited by a moderator: Nov 8, 2016
  16. Ezeeskillz

    Ezeeskillz Guest

    Hey there,

    First and foremost thank you for the excellent tutorials!!!

    I had a question about changing something. I am using a combination of some of your code and some of Jordan Robinson's pixel perfect movement and collision code. So I have the following with k_glide being W.

    //Jumping
    speed_y += grav; //Apply gravity

    if(k_jump && place_meeting(x, y + 1, con_solid))
    {
    speed_y = -6;
    }

    //Gliding
    if (!place_meeting(x,y+1,con_solid)) && k_glide
    {
    grav = 0.06;
    }
    else if (place_meeting(x,y+1,con_solid))
    {
    grav = 0.2;
    }


    scr_collision();

    How would I go about changing this so that if I am on the ground and I am holding W then when I jump my player object does a sort of super jump. How would I make it so that when I press W to glide it will slow my fall and not speed up my rise?
     
  17. ItsMeIvan

    ItsMeIvan Guest

    when do you get into walk & jump animations, i just want to make a basic Mario platformer
     
  18. Kaplah

    Kaplah Member

    Joined:
    Feb 21, 2017
    Posts:
    1
    I'm enjoying your series so far. Quick question for you. How about a future episode covering rooms larger than the viewport? Sort of like any mario game, metroid, castlevania, etc? So far all demos and tutorials I've seen are on single screen platformers that fit in the view.

    Watch I'll post this and my question will be answered in your third video.
     
  19. Itachi

    Itachi Guest

    this is awesome
     
  20. thanks for the tutorials
     

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