Skip to content

Instantly share code, notes, and snippets.

@fl4shk
Created July 28, 2015 23:12
Show Gist options
  • Save fl4shk/7c3c745da5737e8c9568 to your computer and use it in GitHub Desktop.
Save fl4shk/7c3c745da5737e8c9568 to your computer and use it in GitHub Desktop.
void player_sprite_stuff::handle_jumping_stuff ( sprite& the_player,
u32 is_jump_key_hit, u32 is_jump_key_held )
{
if ( the_player.on_ground && is_jump_key_hit )
{
the_player.vel.y = jump_vel;
the_player.jump_hold_timer = max_jump_hold_timer;
}
else if ( !the_player.on_ground )
{
if ( the_player.jump_hold_timer > 0 )
{
if ( is_jump_key_held )
{
--the_player.jump_hold_timer;
}
else
{
the_player.jump_hold_timer = 0;
//if ( the_player.vel.y.data < -0x200 )
//{
// the_player.vel.y.data = -0x200;
//}
apply_gravity (the_player);
//while ( the_player.vel.y.data <= 0 )
//{
// apply_gravity (the_player);
//}
}
}
else if ( the_player.jump_hold_timer == 0 )
{
//if ( the_player.vel.y.data < -0x200 )
//{
// the_player.vel.y.data = -0x200;
//}
apply_gravity (the_player);
//while ( the_player.vel.y.data <= 0 )
//{
// apply_gravity (the_player);
//}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment