From: Elias Fleckenstein Date: Wed, 9 Jun 2021 16:07:27 +0000 (+0200) Subject: Hide color-indepenent entities at a light level <= 0.0 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=b956b3dea0cbc513221a5d640f24793783269411;p=dungeon_game.git Hide color-indepenent entities at a light level <= 0.0 --- diff --git a/plugins/game/game.c b/plugins/game/game.c index c77a53c..c6ca4f8 100644 --- a/plugins/game/game.c +++ b/plugins/game/game.c @@ -267,10 +267,11 @@ void mix_color(struct color *color, struct color other, double ratio) color->b = (color->b + other.b * ratio) / ratio_total; } -void render_color(struct color color, double light, bool bg) +static bool render_color(struct color color, double light, bool bg) { if (light <= 0.0) { set_color(black, bg); + return false; } else { if (damage_overlay > 0.0) mix_color(&color, get_color("#F20000"), damage_overlay * 2.0); @@ -278,6 +279,7 @@ void render_color(struct color color, double light, bool bg) light_color(&color, light); set_color(color, bg); + return true; } } @@ -319,12 +321,10 @@ static void render(render_entity_list entity_list) struct entity *entity = entity_list[x + LIGHT][y + LIGHT]; - if (entity) { - render_color(entity->color, light, false); + if (entity && render_color(entity->color, light, false)) printf("%s", entity->texture); - } else { + else printf(" "); - } } set_color(black, true);