A
AtomicToilet
Guest
Hola!
First a caveat: I've eyeballed similar threads on here and gather I need to somehow tell the Player object to ignore very small changes in height (as this is what's triggering the change to the 'falling' animation when they descend), but I'm not sure how I can implement this with my particular code. Any suggestions are gratefully received!
Here's (I think) the most relevant/important parts of my move script:
And in case the answer's as simple as tweaking my animation code, here's that:
First a caveat: I've eyeballed similar threads on here and gather I need to somehow tell the Player object to ignore very small changes in height (as this is what's triggering the change to the 'falling' animation when they descend), but I'm not sure how I can implement this with my particular code. Any suggestions are gratefully received!
Here's (I think) the most relevant/important parts of my move script:
Code:
if (place_meeting(x,y+1,obj_wall))
{
in_air = false;
vsp = key_up * -jumpspeed
}
else if (!place_meeting(x,y+1,obj_wall))
{
in_air = true;
}
//Horizontal Collision
if place_meeting(x+hsp,y,obj_wall)
{
yplus = 0;
while (place_meeting(x+hsp,y-yplus,obj_wall) && yplus <=abs (1*hsp)) yplus += 1;
if place_meeting(x+hsp,y-yplus,obj_wall)
{
while (!place_meeting(x+sign(hsp),y,obj_wall))
x += sign(hsp);
hsp = 0;
}
else
{
y -= yplus
}
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall))
{
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
y += sign(vsp);
in_air = true;
}
vsp = 0;
}
y += vsp;
Code:
if (in_air == true)
{
sprite_index = spr_player_jump;
image_speed = 0;
image_index = (y > yprevious);
}
else if (in_air == false) && (xprevious !=x)
{
sprite_index = spr_player_run;
image_speed = .4;
}
else
{
sprite_index = spr_player_idle;
image_speed = .05;
}