]> git.lizzy.rs Git - dungeon_game.git/commitdiff
Hide color-indepenent entities at a light level <= 0.0
authorElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 9 Jun 2021 16:07:27 +0000 (18:07 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 9 Jun 2021 16:07:27 +0000 (18:07 +0200)
plugins/game/game.c

index c77a53c1ffdec9753f5df345436dcf95cbf38444..c6ca4f81f3874dccdd1e946864e6d34d3ee0e874 100644 (file)
@@ -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);