Add sliding and fix sprites for Knuckles

This commit is contained in:
Lucas S. Vieira 2025-04-10 00:26:36 -03:00
parent e222916636
commit b7d252467f
7 changed files with 22 additions and 4 deletions

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Before After
Before After

Binary file not shown.

View file

@ -402,8 +402,10 @@ _spring_update(ObjectState *state, ObjectTableEntry *, VECTOR *pos, uint8_t is_r
player.anim_dir = -1;
state->anim_state.animation = 1;
sound_play_vag(sfx_sprn, 0);
if(player.action != ACTION_ROLLING)
if(player.action != ACTION_ROLLING) {
player_set_action(&player, ACTION_NONE);
player.sliding = 0;
}
} else if(state->flipmask & MASK_FLIP_ROTCW) { // Right-pointing spring
//player.pos.vx = (solidity_vx + solidity_w + player_width + 8) << 12;
player.ev_left.collided = 0; // Detach player from left wall if needed
@ -413,8 +415,10 @@ _spring_update(ObjectState *state, ObjectTableEntry *, VECTOR *pos, uint8_t is_r
player.anim_dir = 1;
state->anim_state.animation = 1;
sound_play_vag(sfx_sprn, 0);
if(player.action != ACTION_ROLLING)
if(player.action != ACTION_ROLLING) {
player_set_action(&player, ACTION_NONE);
player.sliding = 0;
}
} else if(state->flipmask == 0) { // Top-pointing spring
player.pos.vy = (solidity_vy - (player_height >> 1)) << 12;
player.grnd = 0;

View file

@ -660,6 +660,7 @@ _player_update_collision_tb(Player *player)
player->vel.vx = 0;
else {
player->sliding = 1;
player->glide_turn_dir = 0;
player->vel.vx -= KNUX_GLIDE_FRICTION * player->anim_dir;
player->vel.vy = 0;
}
@ -724,6 +725,13 @@ _player_update_collision_tb(Player *player)
player->vel.vz = 0;
player->airdirlock = 0;
}
} else {
// If NOT touching the ground.
if(player->sliding) {
// Player was sliding but left the platform. Reset action.
player_set_action(player, ACTION_NONE);
player->sliding = 0;
}
}
if((player->ev_ceil1.collided || player->ev_ceil2.collided) && (player->vel.vy < 0)) {
@ -1574,6 +1582,11 @@ player_draw(Player *player, VECTOR *pos)
uint8_t is_rolling =
is_rolling_angle
|| (player_get_current_animation_hash(player) == ANIM_SPINDASH);
uint8_t is_gliding =
(player_get_current_animation_hash(player) == ANIM_GLIDE)
|| (player_get_current_animation_hash(player) == ANIM_GLIDECANCEL)
|| (player_get_current_animation_hash(player) == ANIM_GLIDETURNA)
|| (player_get_current_animation_hash(player) == ANIM_GLIDETURNB);
int32_t anim_angle = -_snap_angle(player->angle);
uint8_t show_character = (((player->iframes >> 2) % 2) == 0);
uint8_t facing_left = (player->anim_dir < 0);
@ -1583,7 +1596,8 @@ player_draw(Player *player, VECTOR *pos)
chara_draw_gte(&player->chara,
player->anim_frame,
(int16_t)(pos->vx >> 12),
(int16_t)(pos->vy >> 12) + (is_rolling ? 4 : 0),
(int16_t)(pos->vy >> 12)
+ (is_rolling ? 4 : (is_gliding ? 8 : 0)),
facing_left,
(is_rolling_angle ? 0 : anim_angle));
}