Slope Collision going up slope and jumping.

Dreadusa

Member
Code:
if(JUMP&&(!place_free(x,y+1)))//Jump checks for keyboard_check_pressed
{jumpSpeed = -14}
//Horizontal Collision
xtarg = x + lengthdir_x(moveX,xdir);
if (place_free(xtarg,y))
    {
    x = xtarg
    }
else
    {
    while (place_meeting(x+moveX,y,objCollision))
            {
            xtarg = x + lengthdir_x(sign(moveX),xdir)
            if(place_free(xtarg,y))
                {
                x = xtarg;
                }
            moveX = 0;
            }
        for(var i = 0; i < 10; i+=1)
            {
            if (place_free(xtarg,y-i))
                {
                y = y-i;
                x = xtarg;
                exit;
                }
            }
    }      
//Vertical Collision
if (place_free(x,grav))
    {
    y = grav
    }
else
    {
    while(place_free(x,y+sign(grav)))
        {
        y+=sign(grav);
        exit;
        }
    grav = 0
    }
//Jump Collision
if(place_free(x,y+jumpSpeed))
    {
    y+= jumpSpeed
    }
else
    {
    while(place_free(x,y+sign(jumpSpeed)))
        {
        y+=sign(jumpSpeed);
        }
    jumpSpeed = 0;
    }
jumpSpeed++;
This is my collision code, my jumpSpeed is being held until I'm no longer going up the slop and then I jump without pressing the key, or I stop pressing left or right after pressing jump while going up a slope and I jump. Really Weird.
 
Top