Jennifer will not jump very high of normal vspeed -10

Discussion in 'Legacy GameMaker Community Tech Support' started by TunnelRhino, Jan 6, 2020.

  1. TunnelRhino

    TunnelRhino Member

    Joined:
    Jun 21, 2016
    Posts:
    35
    Here are the four instances of objects in the game
    horizontally_moving_platform
    Jennifer
    vertically_moving_platform
    Wall



    Information for Jennifer
    Code:
    Information about object: Jennifer
    
    Sprite: Jennifer_Sprite
    Solid: false
    Visible: true
    Depth: 0
    Persistent: false
    Parent: <no parent>
    Mask: <same as sprite>
    
     Step Event:
    execute code:
    
    if (place_free(x-2,y))
    {
      if (keyboard_check(vk_left))
      {
        x -= 2;
      }
    }
    if (place_free(x+2,y))
    {
      if (keyboard_check(vk_right))
      {
        x += 2;
      }
    }
    if (instance_exists(horizontally_moving_platform))
    {
      if (position_meeting(x-sprite_xoffset+sprite_width/2,y-sprite_yoffset+sprite_height,horizontally_moving_platform))
      {
        var objID;
        objID = instance_position(x-sprite_xoffset+sprite_width/2,y-sprite_yoffset+sprite_height,horizontally_moving_platform);
        hspeed = objID.hspeed;
      }
      else
      {
        hspeed = 0;
      }
    }
    if (instance_exists(vertically_moving_platform))
    {
      if (position_meeting(x-sprite_xoffset+sprite_width/2,y-sprite_yoffset+sprite_height,vertically_moving_platform))
      {
        var objID2;
        objID2 = instance_position(x-sprite_xoffset+sprite_width/2,y-sprite_yoffset+sprite_height,vertically_moving_platform);
        vspeed = objID.vspeed;
      }
      else
      {
        vspeed = 0;
      }
    }
    if (place_free(x,y+2))
    {
      gravity = 0.5;
    }
    else if (!place_free(x,y+2))
    {
      gravity = 0;
    }
    if (vspeed > 12)
    {
      vspeed = 12;
    }
    if (keyboard_check(vk_up))
    {
      if (!place_free(x,y+2))
      {
        vspeed = -10;
      }
    }
    
    Key Press Event for J-key Key:
    execute code:
    
    x = xstart;
    y = ystart;
    


    information for vertically_moving_platform
    Code:
    Information about object: vertically_moving_platform
    
    Sprite: sprite_vertically_moving_platform
    Solid: true
    Visible: true
    Depth: 0
    Persistent: false
    Parent: <no parent>
    Mask: <same as sprite>
    
    Create Event:
    execute code:
    
    reverse_direction = 1;
    vspeed = 1;
    
    Alarm Event for alarm 0:
    execute code:
    
    vspeed = -vspeed;
    reverse_direction = 1;
    
     Step Event:
    execute code:
    
    if (reverse_direction == 1)
    {
      alarm[0] = 40;
      reverse_direction = 0;
    }
    


    infromation for Wall
    Code:
    Information about object: Wall
    
    Sprite: Wall_Sprite
    Solid: true
    Visible: true
    Depth: 0
    Persistent: false
    Parent: <no parent>
    Mask: <same as sprite>
    


    information for horizontally_moving_platform
    Code:
    Information about object: horizontally_moving_platform
    
    Sprite: sprite_horizontally_moving_platform
    Solid: true
    Visible: true
    Depth: 0
    Persistent: false
    Parent: <no parent>
    Mask: <same as sprite>
    
    Create Event:
    execute code:
    
    reverse_direction = 1;
    hspeed = 1;
    
    Alarm Event for alarm 0:
    execute code:
    
    hspeed = -hspeed;
    reverse_direction = 1;
    
     Step Event:
    execute code:
    
    if (reverse_direction == 1)
    {
      alarm[0] = 40;
      reverse_direction = 0;
    }
    
     
  2. TrunX

    TrunX Member

    Joined:
    Jun 30, 2016
    Posts:
    145
    It seems that you're resetting vspeed to 0 every step in which you are not standing on a vertical_moving_platform.
     

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