Reposition player when touching springs and ignore some collision

This commit is contained in:
Lucas S. Vieira 2024-10-29 21:49:24 -03:00
parent a9ba897d70
commit 9ef4ae1794

View file

@ -240,6 +240,8 @@ _spring_update(ObjectState *state, ObjectTableEntry *, VECTOR *pos, uint8_t is_r
if(collision_side == OBJ_SIDE_NONE)
return;
else if(state->flipmask & MASK_FLIP_ROTCT) { // Left-pointing spring
player.pos.vx = (solidity_vx - player_width) << 12;
player.ev_right.collided = 0; // Detach player from right wall if needed
if(player.grnd) player.vel.vz = is_red ? -0x10000 : -0xa000;
else player.vel.vx = is_red ? -0x10000 : -0xa000;
player.ctrllock = 16;
@ -247,6 +249,8 @@ _spring_update(ObjectState *state, ObjectTableEntry *, VECTOR *pos, uint8_t is_r
state->anim_state.animation = 1;
sound_play_vag(sfx_sprn, 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
if(player.grnd) player.vel.vz = is_red ? 0x10000 : 0xa000;
else player.vel.vx = is_red ? 0x10000 : 0xa000;
player.ctrllock = 16;
@ -254,6 +258,7 @@ _spring_update(ObjectState *state, ObjectTableEntry *, VECTOR *pos, uint8_t is_r
state->anim_state.animation = 1;
sound_play_vag(sfx_sprn, 0);
} else if(state->flipmask == 0) { // Top-pointing spring
player.pos.vy = (solidity_vy - (player_height >> 1)) << 12;
player.grnd = 0;
player.vel.vy = is_red ? -0x10000 : -0xa000;
player.vel.vz = 0;
@ -263,6 +268,7 @@ _spring_update(ObjectState *state, ObjectTableEntry *, VECTOR *pos, uint8_t is_r
player_set_animation_direct(&player, ANIM_WALKING);
sound_play_vag(sfx_sprn, 0);
} else if(state->flipmask & MASK_FLIP_FLIPY) { // Bottom-pointing spring
player.pos.vy = (solidity_vy + solidity_h + (player_height >> 1)) << 12;
player.grnd = 0;
player.vel.vy = is_red ? 0x10000 : 0xa000;
player.vel.vz = 0;