Enemies now actually adopt their color and all items too.

main
Zed A. Shaw 1 week ago
parent 59a6882b70
commit 7c56f350ab
  1. 24
      assets/items.json
  2. 9
      components.cpp
  3. 7
      components.hpp
  4. 4
      systems.cpp

@ -2,8 +2,8 @@
"TORCH_BAD": { "TORCH_BAD": {
"id": "TORCH_BAD", "id": "TORCH_BAD",
"name": "Crappy Torch", "name": "Crappy Torch",
"foreground": [24, 205, 189], "foreground": [24, 120, 189],
"background": [230, 20, 120], "background": [230,120, 120],
"description": "A torch that barely lights the way. You wonder if it'd be better to not see the person who murders you.", "description": "A torch that barely lights the way. You wonder if it'd be better to not see the person who murders you.",
"inventory_count": 1, "inventory_count": 1,
"components": [ "components": [
@ -14,8 +14,8 @@
"SWORD_RUSTY": { "SWORD_RUSTY": {
"id": "SWORD_RUSTY", "id": "SWORD_RUSTY",
"name": "Rusty Junk Sword", "name": "Rusty Junk Sword",
"foreground": [24, 205, 189], "foreground": [24, 120, 189],
"background": [24, 205, 189], "background": [24, 120, 189],
"description": "A sword left to rot in a deep hole where it acquired a patina of dirt and tetanus. You aren't sure if it's more deadly for you to hold it or for the people you stab with it.", "description": "A sword left to rot in a deep hole where it acquired a patina of dirt and tetanus. You aren't sure if it's more deadly for you to hold it or for the people you stab with it.",
"inventory_count": 1, "inventory_count": 1,
"components": [ "components": [
@ -26,8 +26,8 @@
"SWORD_LIGHT_AND_FLAME": { "SWORD_LIGHT_AND_FLAME": {
"id": "SWORD_LIGHT_AND_FLAME", "id": "SWORD_LIGHT_AND_FLAME",
"name": "Sword of Light and Flame", "name": "Sword of Light and Flame",
"foreground": [24, 205, 189], "foreground": [24, 205, 210],
"background": [24, 205, 189], "background": [24, 205, 210],
"description": "A sword so powerful, a great man from the Land of The Rising Sun thrust it into the ocean of Nerf to chill its effects.", "description": "A sword so powerful, a great man from the Land of The Rising Sun thrust it into the ocean of Nerf to chill its effects.",
"inventory_count": 1, "inventory_count": 1,
"components": [ "components": [
@ -39,8 +39,8 @@
"CHEST_SMALL": { "CHEST_SMALL": {
"id": "CHEST_SMALL", "id": "CHEST_SMALL",
"name": "Small Chest", "name": "Small Chest",
"foreground": [24, 205, 189], "foreground": [150, 100, 189],
"background": [24, 205, 189], "background": [150, 100, 189],
"description": "A small chest of gold. You wonder who would leave something like this around.", "description": "A small chest of gold. You wonder who would leave something like this around.",
"components": [ "components": [
{"type": "Tile", "config": {"chr": "\uaaea"}}, {"type": "Tile", "config": {"chr": "\uaaea"}},
@ -51,8 +51,8 @@
"WALL_TORCH": { "WALL_TORCH": {
"id": "WALL_TORCH", "id": "WALL_TORCH",
"name": "Basic Wall Torch", "name": "Basic Wall Torch",
"foreground": [24, 205, 189], "foreground": [24, 205, 210],
"background": [24, 205, 189], "background": [24, 205, 210],
"description": "A torch on a wall you can't pick up.", "description": "A torch on a wall you can't pick up.",
"inventory_count": 0, "inventory_count": 0,
"components": [ "components": [
@ -63,8 +63,8 @@
"POTION_HEALING_SMALL": { "POTION_HEALING_SMALL": {
"id": "POTION_HEALING_SMALL", "id": "POTION_HEALING_SMALL",
"name": "Small Healing Potion", "name": "Small Healing Potion",
"foreground": [24, 205, 189], "foreground": [255, 205, 189],
"background": [24, 205, 189], "background": [255, 205, 189],
"description": "A small healing potion.", "description": "A small healing potion.",
"inventory_count": 1, "inventory_count": 1,
"components": [ "components": [

@ -13,7 +13,14 @@ namespace components {
} else if(comp_type == "Loot") { } else if(comp_type == "Loot") {
world.set<Loot>(entity, {config["amount"]}); world.set<Loot>(entity, {config["amount"]});
} else if(comp_type == "Tile") { } else if(comp_type == "Tile") {
world.set<Tile>(entity, {config["chr"]}); world.set<Tile>(entity, {
config["chr"],
entity_data["foreground"][0],
entity_data["foreground"][1],
entity_data["foreground"][2],
entity_data["background"][0],
entity_data["background"][1],
entity_data["background"][2]});
} else if(comp_type == "EnemyConfig") { } else if(comp_type == "EnemyConfig") {
world.set<EnemyConfig>(entity, {config["hearing_distance"]}); world.set<EnemyConfig>(entity, {config["hearing_distance"]});
} else if(comp_type == "Combat") { } else if(comp_type == "Combat") {

@ -32,6 +32,13 @@ namespace components {
struct Tile { struct Tile {
std::string chr; std::string chr;
uint8_t fg_h = 0;
uint8_t fg_s = 0;
uint8_t fg_v = 0;
uint8_t bg_h = 0;
uint8_t bg_s = 0;
uint8_t bg_v = 0;
DEFINE_SERIALIZABLE(Tile, chr); DEFINE_SERIALIZABLE(Tile, chr);
}; };

@ -213,8 +213,8 @@ void System::draw_entities(DinkyECS::World &world, Map &map, const Matrix &light
const TileCell& cell = tiles.at(pos.location.x, pos.location.y); const TileCell& cell = tiles.at(pos.location.x, pos.location.y);
// the 2 and 4 are from ftxui::Canvas since it does a kind of "subpixel" drawing // the 2 and 4 are from ftxui::Canvas since it does a kind of "subpixel" drawing
canvas.DrawText(loc.x*2, loc.y*4, tile.chr, [light_value, cell](auto &pixel) { canvas.DrawText(loc.x*2, loc.y*4, tile.chr, [tile, light_value, cell](auto &pixel) {
pixel.foreground_color = Color::HSV(255, 200, 180 * light_value); pixel.foreground_color = Color::HSV(tile.fg_h, tile.fg_s, tile.fg_v * light_value);
pixel.background_color = Color::HSV(cell.bg_h, cell.bg_s, cell.bg_v * light_value); pixel.background_color = Color::HSV(cell.bg_h, cell.bg_s, cell.bg_v * light_value);
}); });
} }

Loading…
Cancel
Save