Quick hack to test finding a better light. If you find the gold you get a better light.

main
Zed A. Shaw 1 week ago
parent a9217e8423
commit 62f986719d
  1. 4
      components.hpp
  2. 1
      main.cpp
  3. 6
      systems.cpp

@ -48,4 +48,8 @@ namespace components {
struct EnemyConfig {
int HEARING_DISTANCE;
};
struct LightSource {
int strength = 100;
};
}

@ -33,6 +33,7 @@ void configure_world(DinkyECS::World &world, Map &game_map) {
world.set<Combat>(player.entity, {100, 10});
world.set<Tile>(player.entity, {config.PLAYER_TILE});
world.set<Inventory>(player.entity, {5});
world.set<LightSource>(player.entity, {200});
auto enemy = world.entity();
world.set<Position>(enemy, {game_map.place_entity(1)});

@ -117,9 +117,11 @@ void System::collision(DinkyECS::World &world, Player &player) {
auto loot = world.get<Loot>(entity);
auto &loot_pos = world.get<Position>(entity);
auto &inventory = world.get<Inventory>(player.entity);
auto &light = world.get<LightSource>(player.entity);
world.send<Events::GUI>(Events::GUI::LOOT, entity, loot);
inventory.gold += loot.amount;
light.strength = 100;
collider.remove(loot_pos.location);
} else {
println("UNKNOWN COLLISION TYPE {}", entity);
@ -145,6 +147,7 @@ void System::draw_map(DinkyECS::World &world, Map &game_map, ftxui::Canvas &canv
const auto& config = world.get_the<MapConfig>();
const auto& player = world.get_the<Player>();
const auto& player_position = world.get<Position>(player.entity);
const auto& player_light = world.get<LightSource>(player.entity);
Point start = game_map.center_camera(player_position.location, view_x, view_y);
auto &walls = game_map.walls();
auto &paths = game_map.paths();
@ -161,11 +164,10 @@ void System::draw_map(DinkyECS::World &world, Map &game_map, ftxui::Canvas &canv
// it gets brighter.
const int LIGHT_MIN = 10;
const int LIGHT_MAX = 110;
int light_strength = 100; // lower is stronger
Point light_at{start.x+x, start.y+y};
int dnum = paths[light_at.y][light_at.x];
int light_value = std::clamp(255 - (dnum * light_strength), LIGHT_MIN, LIGHT_MAX);
int light_value = std::clamp(255 - (dnum * player_light.strength), LIGHT_MIN, LIGHT_MAX);
// "WALL_TILE": "\u2591",
// "WALL_TILE": "\ua5b8",

Loading…
Cancel
Save