mirror of
https://github.com/luksamuk/engine-psx.git
synced 2025-04-28 13:28:02 +03:00
Add sliding and fix sprites for Knuckles
This commit is contained in:
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 |
Binary file not shown.
|
@ -402,8 +402,10 @@ _spring_update(ObjectState *state, ObjectTableEntry *, VECTOR *pos, uint8_t is_r
|
||||||
player.anim_dir = -1;
|
player.anim_dir = -1;
|
||||||
state->anim_state.animation = 1;
|
state->anim_state.animation = 1;
|
||||||
sound_play_vag(sfx_sprn, 0);
|
sound_play_vag(sfx_sprn, 0);
|
||||||
if(player.action != ACTION_ROLLING)
|
if(player.action != ACTION_ROLLING) {
|
||||||
player_set_action(&player, ACTION_NONE);
|
player_set_action(&player, ACTION_NONE);
|
||||||
|
player.sliding = 0;
|
||||||
|
}
|
||||||
} else if(state->flipmask & MASK_FLIP_ROTCW) { // Right-pointing spring
|
} else if(state->flipmask & MASK_FLIP_ROTCW) { // Right-pointing spring
|
||||||
//player.pos.vx = (solidity_vx + solidity_w + player_width + 8) << 12;
|
//player.pos.vx = (solidity_vx + solidity_w + player_width + 8) << 12;
|
||||||
player.ev_left.collided = 0; // Detach player from left wall if needed
|
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;
|
player.anim_dir = 1;
|
||||||
state->anim_state.animation = 1;
|
state->anim_state.animation = 1;
|
||||||
sound_play_vag(sfx_sprn, 0);
|
sound_play_vag(sfx_sprn, 0);
|
||||||
if(player.action != ACTION_ROLLING)
|
if(player.action != ACTION_ROLLING) {
|
||||||
player_set_action(&player, ACTION_NONE);
|
player_set_action(&player, ACTION_NONE);
|
||||||
|
player.sliding = 0;
|
||||||
|
}
|
||||||
} else if(state->flipmask == 0) { // Top-pointing spring
|
} else if(state->flipmask == 0) { // Top-pointing spring
|
||||||
player.pos.vy = (solidity_vy - (player_height >> 1)) << 12;
|
player.pos.vy = (solidity_vy - (player_height >> 1)) << 12;
|
||||||
player.grnd = 0;
|
player.grnd = 0;
|
||||||
|
|
16
src/player.c
16
src/player.c
|
@ -660,6 +660,7 @@ _player_update_collision_tb(Player *player)
|
||||||
player->vel.vx = 0;
|
player->vel.vx = 0;
|
||||||
else {
|
else {
|
||||||
player->sliding = 1;
|
player->sliding = 1;
|
||||||
|
player->glide_turn_dir = 0;
|
||||||
player->vel.vx -= KNUX_GLIDE_FRICTION * player->anim_dir;
|
player->vel.vx -= KNUX_GLIDE_FRICTION * player->anim_dir;
|
||||||
player->vel.vy = 0;
|
player->vel.vy = 0;
|
||||||
}
|
}
|
||||||
|
@ -724,6 +725,13 @@ _player_update_collision_tb(Player *player)
|
||||||
player->vel.vz = 0;
|
player->vel.vz = 0;
|
||||||
player->airdirlock = 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)) {
|
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 =
|
uint8_t is_rolling =
|
||||||
is_rolling_angle
|
is_rolling_angle
|
||||||
|| (player_get_current_animation_hash(player) == ANIM_SPINDASH);
|
|| (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);
|
int32_t anim_angle = -_snap_angle(player->angle);
|
||||||
uint8_t show_character = (((player->iframes >> 2) % 2) == 0);
|
uint8_t show_character = (((player->iframes >> 2) % 2) == 0);
|
||||||
uint8_t facing_left = (player->anim_dir < 0);
|
uint8_t facing_left = (player->anim_dir < 0);
|
||||||
|
@ -1583,7 +1596,8 @@ player_draw(Player *player, VECTOR *pos)
|
||||||
chara_draw_gte(&player->chara,
|
chara_draw_gte(&player->chara,
|
||||||
player->anim_frame,
|
player->anim_frame,
|
||||||
(int16_t)(pos->vx >> 12),
|
(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,
|
facing_left,
|
||||||
(is_rolling_angle ? 0 : anim_angle));
|
(is_rolling_angle ? 0 : anim_angle));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue