• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Sprite flickering after jump and clipping trouble.

C

Chuckle_Huck

Guest
I've been looking at some tutorials and learned how to create movement, collision, and jumping; however, after adding animated sprites to the code, whenever the character jumps into a wall they flicker between standing and jumping sprites and it also clips into the ground and can't move due to said clipping (also flickers when jumping out too). Here's the entire code I learned for the character object and animation:


//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;

if (place_meeting(x,y+1, obj_Floor))
{
vsp = key_jump * -jumpspeed
}

//Horizontal Collision
if (place_meeting(x+1+hsp,y,obj_Floor))
{
while(!place_meeting(x-1-sign(hsp),y,obj_Floor))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;

//Vertical Collision
if (place_meeting(x,y+1+vsp,obj_Floor))
{
while(!place_meeting(x,y+sign(vsp),obj_Floor))
{
y += sign(vsp);
}
vsp += 0
}
y += vsp;

//Animate
if (move!=0) image_xscale = move;
if (place_meeting(x,y+1,obj_Floor))
{
if (move!=0) sprite_index = spr_Jenny_Walk; else sprite_index = spr_True_Idle
}
else
{
if (vsp < 1) sprite_index = spr_Jenny_Jump; else sprite_index = spr_Jenny_Fall
}


Maybe it's the sprite origin but I'm just not sure. Thanks for the help!
 
A

Aura

Guest
That happens when both the sprites have different origins and collision masks of different sizes IMO.
 
C

Chuckle_Huck

Guest
Ah okay, I'll see what I can do about that, thanks a lot bud!
 
Top