Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - BillyMayonnaise

Pages: [1]
1
Game Design / 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.

Pages: [1]