Legacy GM [solved]make player change image_index for a whole jump

S

SonicTheHedgehog+123

Guest
I making a platformer and want my player to switch his image_index for a whole jump. My problem is that at the climax of my jump the image_index switches for an instant. I could use an alarm when jumping so the player is
always in the wanted sprite but I think this is cheap. Is there a better method? Open for help:D
Code:
with Fledermaus{
if vspeed < 0 || vspeed > 0 // checks if the player is jumping or falling
image_index = 3
else
 if ( image_index >1 ) with (Fledermaus_Bild)
{
image_index = 0;
}
}
 

Rob

Member
I making a platformer and want my player to switch his image_index for a whole jump. My problem is that at the climax of my jump the image_index switches for an instant. I could use an alarm when jumping so the player is
always in the wanted sprite but I think this is cheap. Is there a better method? Open for help:D
Code:
with Fledermaus{
if vspeed < 0 || vspeed > 0 // checks if the player is jumping or falling
image_index = 3
else
 if ( image_index >1 ) with (Fledermaus_Bild)
{
image_index = 0;
}
}
You're checking for <> vspeed, but at the apex, vspeed is probably 0 which is why you're seeing the index change. It would be worth looking into "State Systems" so you can lock away code between states but i think you can also go for a simpler approach if you don't have too many systems going on in your game - just check for the presence of a platform beneath your characters feet - that way it will work regardless of vspeed.
 
S

SonicTheHedgehog+123

Guest
Thank you Rob you brought me to a good idea. And now it works thanks to your help.:p
Code:
with Fledermaus{
if place_free(x,y+1)
image_index = 3
else
 if ( image_index >1 ) with (Fledermaus_Bild)
{
image_index = 0;
}
}
//I did make the player check if he is one pixel above the wall with place_free
 
  • Like
Reactions: Rob
Top