diff --git a/src/game/level.c b/src/game/level.c index feae51c..992119b 100644 --- a/src/game/level.c +++ b/src/game/level.c @@ -306,8 +306,7 @@ static void handle_collisions(EntityManager *em) { } /* ── Enemy contact damage to player ──── */ - if (player && !(player->flags & ENTITY_INVINCIBLE) && - entity_is_enemy(a) && !(a->flags & ENTITY_DEAD)) { + if (player && entity_is_enemy(a) && !(a->flags & ENTITY_DEAD)) { if (physics_overlap(&a->body, &player->body)) { /* Check if player is stomping (falling onto enemy from above) */ bool stomping = (player->body.vel.y > 0) && @@ -319,7 +318,7 @@ static void handle_collisions(EntityManager *em) { damage_entity(a, 2); if (a->flags & ENTITY_DEAD) stats_record_kill(); player->body.vel.y = -PLAYER_JUMP_FORCE * 0.7f; - } else { + } else if (!(player->flags & ENTITY_INVINCIBLE)) { /* Charger deals extra damage and knockback while charging */ int dmg = a->damage; if (a->type == ENT_ENEMY_CHARGER) { diff --git a/src/game/player.c b/src/game/player.c index 67cfe64..4dafbaf 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -308,8 +308,8 @@ void player_update(Entity *self, float dt, const Tilemap *map) { pd->dash_timer = PLAYER_DASH_DURATION; pd->dash_dir = vec2(0.0f, 1.0f); - /* Brief invincibility during dash */ - pd->inv_timer = PLAYER_DASH_DURATION; + /* Invincibility during dash + short grace period after */ + pd->inv_timer = PLAYER_DASH_DURATION + PLAYER_DASH_INV_GRACE; self->flags |= ENTITY_INVINCIBLE; /* Jetpack burst downward */ diff --git a/src/game/player.h b/src/game/player.h index a23fc5f..ce9a4c8 100644 --- a/src/game/player.h +++ b/src/game/player.h @@ -39,6 +39,7 @@ /* Invincibility after taking damage */ #define PLAYER_INV_TIME 1.5f /* seconds of invincibility */ +#define PLAYER_DASH_INV_GRACE 0.15f /* extra invincibility after dash */ /* Aim direction (for shooting) */ typedef enum AimDir {