Author Topic: Having trouble with creating a rope object  (Read 845 times)

BillyMayonnaise

  • Wannabe
  • Posts: 1
  • OS:
  • Windows 8/Server 2012 Windows 8/Server 2012
  • Browser:
  • Chrome 54.0.2840.99 Chrome 54.0.2840.99
    • View Profile
  • Playstyle: Keyboard
Having trouble with creating a rope object
« on: December 03, 2016, 02:14:21 PM »
So, I'm trying to make a rope object in YoYoYo's engine, and it's not working. What I want to do is make it so that if the player jumps on the rope, he'll latch on to a side, and be able to climb it up or slide down, or turn to the other side. But what's actually happening is that the rope isn't even latching on to the player. Here's the code (in the player step event):

Code: [Select]
var onRope = (scrCheckObjectCollisionX(objRope) && notOnBlock);

if (onRope && !onVineR && !onVineL)
{
    var ropeLeft = -(place_meeting(x + 1,y,objRope)) //left side of rope
    var ropeRight = (place_meeting(x - 1,y,objRope)) //right side of rope
    var ropeSide = ropeLeft + ropeRight //what side of the rope the player is on
    vspeed = 0
    hspeed = 0
    image_speed = 0
    sprite_index = sprPlayerSliding
    if(scrButtonCheckPressed(global.upButton)) //climb up the rope
    {
        vspeed = -1
        image_speed = 1/4
    }
    if(scrButtonCheckPressed(global.downButton)) //slide down
    {
        vspeed = 2
        image_speed = 1/2
    }
    image_xscale = ropeSide //direction the player is facing
    //switch sides
    if (ropeSide = 1 && scrButtonCheckPressed(global.leftButton))
    {
        x = objRope.x - 2
    }
    if (ropeSide = -1 && scrButtonCheckPressed(global.rightButton))
    {
        x = objRope.x + 2
    }
    //pressed away from the rope
    if (ropeSide = 1 && scrButtonCheckPressed(global.rightButton)) || (ropeSide = -1 && scrButtonCheckPressed(global.leftButton))
    {
        if (scrButtonCheck(global.jumpButton))  //jumping off rope
        {
            if (ropeSide = -1)
                hspeed = -15;
            else
                hspeed = 15;
           
            vspeed = -9 * global.grav;
            audio_play_sound(sndWallJump,0,false);
            sprite_index = sprPlayerJump;
        }
        else    //moving off rope
        {
            if (ropeSide = -1)
                hspeed = -3;
            else
                hspeed = 3;
           
            sprite_index = sprPlayerFall;
        }
    }
}

If anyone could tell me what's happening, it would be great.