• 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!

GML Selective image_index for Jump (not using vspeed)

M

mamacato

Guest
Often you'll see image_index = 0 while vertical speed < 0, then image_index = 1 on the way down. I want the same image_index for the up and down animation (simple to resolve), but I'd like a different image_index for either the on_the_ground frame (y collision), or for a couple frames before that, including the on_the_ground frame. Maybe I have to go through putting player_landed_state in my player state machine, but I'm wondering if there's something else that can be done within the animation script shown below.

Code:
sprite_index = sprites_array[state];
mask_index = mask_array[state];
image_xscale = facing;

switch(state)
{
   case states.JUMP:
       if vsp < 0 image_index = 0 else image_index = 1;
   break;
   
   case states.ATTACK:
       if !on_ground() sprite_index = sPlayerAttackAir; //AttackAir
       else
           if hsp != 0 sprite_index = sPlayerAttackWalk; //AttackWalk
           else sprite_index = sPlayerAttack; // Attack (only)
   break;
   
   case states.HURTING:
       if !on_ground()
       {
           sprite_index = sPlayerJump;
           if vsp < 0 image_index = 0 else image_index = 1;
       }
   break;
}
If contribution { Thanks! }
 
N

NeZvers

Guest
I've built my own state machines but PixelatedPope took it to next level with True State. It's amazing even for learning purposes.
I usually like to have 3 frames (going up, close to 0 v speed, and falling). For impact certainly, I'd suggest a separate state but if you want "to prepare for impact" image then you need to measure distance and direction, so you have at least 2-4 frames for that image.
 
M

mamacato

Guest
I've built my own state machines but PixelatedPope took it to next level with True State. It's amazing even for learning purposes.
I usually like to have 3 frames (going up, close to 0 v speed, and falling). For impact certainly, I'd suggest a separate state but if you want "to prepare for impact" image then you need to measure distance and direction, so you have at least 2-4 frames for that image.
Thanks NeZ! What's 5 bucks, eh?

I'm using Peter Morgan's platformer as a base. I really like it. And it's getting easier to modify as I get better. I'll see what new things I can learn from the TrueState you linked.
 
Top