1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 Platform code for upside down room

Discussion in 'Programming' started by Bolt3dge, May 29, 2019.

  1. Bolt3dge

    Bolt3dge Member

    Joined:
    May 29, 2019
    Posts:
    1
    I used the platform code that Shawn Spradling showed on his youtube channel. I want to have a room that make your player jump upside down so the gravity and jumping will go up instead of down. Here is the code I use for regular platform code, but I can't figure out what to change.
    Code:
    ///React to input
    if room==room0 or room==room3
    {
    
    if keyboard_check(ord('D'))
    vsp=20
    //key_left = -keyboard_check(ord('A'));
    key_jump = keyboard_check_pressed(vk_space);
    //attack = mouse_check_button_pressed(mb_left)
    //moving
    //x += global.movespeed;
    move = 1;//key_left + key_right;
    //Jumping
    hsp = move * global.movespeed * movefactor;
    
    if (vsp < 12) vsp += grav;
    
    if (place_meeting(x,y+1,obj_block))
    {
      vsp = key_jump * -global.jumpspeed;
    }
    //Collisions Horizontal
      if (place_meeting(x+hsp,y,obj_block))   
    {
        while(!place_meeting(x+sign(hsp),y,obj_block))
        {
            x += sign(hsp);
        }
         hsp = 0;
     }
     x += hsp;
     //Verticle collisions
     if (place_meeting(x,y+vsp,obj_block))
    {
        while(!place_meeting(x,y+sign(vsp),obj_block))
        {
            y += sign(vsp);
        }
      vsp = 0;
      }
     y += vsp;
     }
     
  2. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    2,012
    You'd flip gravity, jumpspeed and ground collision detection that gates the jump action. Personally I'd do with changing variables, but the code changes would be:
    Code:
    // Replace these lines:
    if (vsp < 12) vsp += grav;
    if (place_meeting(x,y+1,obj_block))
    {
      vsp = key_jump * -global.jumpspeed;
    }
    
    // With these:
    if (vsp > -12) vsp -= grav;
    if (place_meeting(x,y-1,obj_block))
    {
      vsp = key_jump * global.jumpspeed;
    }
    
    I'm not sure what the idea is with:
    Code:
    if keyboard_check(ord('D'))
    vsp=20
    Or "when moving right, set vertical speed to 20."
     

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