diff --git a/assets/config.json b/assets/config.json index 0fdf7b4..54c6d59 100644 --- a/assets/config.json +++ b/assets/config.json @@ -10,6 +10,7 @@ "torch_horizontal_floor": "assets/torch_horizontal_floor-256.png", "evil_eye": "assets/evil_eye-sprites.png", "peasant_girl": "assets/undead_peasant-256.png", + "grave_stone": "assets/grave_stone-256.png", "floor": "assets/floor_tile_test-256.png", "ceiling": "assets/ceiling_test-256.png", "healing_potion_small": "assets/healing_potion_small-256.png", diff --git a/assets/devices.json b/assets/devices.json index 285edba..012ade7 100644 --- a/assets/devices.json +++ b/assets/devices.json @@ -49,5 +49,21 @@ "events": ["Events::GUI::TRAP"]}, {"_type": "Sprite", "name": "tripwire_trap"} ] + }, + "GRAVE_STONE": { + "id": "GRAVE_STONE", + "name": "Grave Stone", + "description": "Something died here. Was this your doing?", + "inventory_count": 0, + "components": [ + {"_type": "Tile", "display": "\u21ef", + "foreground": [32, 123, 164], + "background": [24, 205, 189] + }, + {"_type": "Device", + "config": {"test": true}, + "events": []}, + {"_type": "Sprite", "name": "grave_stone"} + ] } } diff --git a/assets/enemies.json b/assets/enemies.json index 56dc2ff..4fcc809 100644 --- a/assets/enemies.json +++ b/assets/enemies.json @@ -40,7 +40,7 @@ }, "RAT_GIANT": { "components": [ - {"_type": "Tile", "display": "\u08ea", + {"_type": "Tile", "display": "\u08ac", "foreground": [205, 164, 246], "background": [30, 20, 75] }, diff --git a/assets/grave_stone-256.png b/assets/grave_stone-256.png new file mode 100644 index 0000000..4bd9d4b Binary files /dev/null and b/assets/grave_stone-256.png differ diff --git a/guecs.cpp b/guecs.cpp index 7a1410e..575ac60 100644 --- a/guecs.cpp +++ b/guecs.cpp @@ -91,18 +91,15 @@ namespace guecs { }); } - void UI::mouse(sf::RenderWindow &window) { - if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { - sf::Vector2f pos = window.mapPixelToCoords(sf::Mouse::getPosition(window)); - $world.query([&](auto ent, auto& cell, auto &clicked) { - if((pos.x >= cell.x && pos.x <= cell.x + cell.w) && - (pos.y >= cell.y && pos.y <= cell.y + cell.h)) - { - auto& cn = $world.get(ent); - clicked.action(ent, cn.name); - } - }); - } + void UI::mouse(float x, float y) { + $world.query([&](auto ent, auto& cell, auto &clicked) { + if((x >= cell.x && x <= cell.x + cell.w) && + (y >= cell.y && y <= cell.y + cell.h)) + { + auto& cn = $world.get(ent); + clicked.action(ent, cn.name); + } + }); } Clickable make_action(DinkyECS::World& target, Events::GUI event) { diff --git a/guecs.hpp b/guecs.hpp index 864a947..1e90a0c 100644 --- a/guecs.hpp +++ b/guecs.hpp @@ -131,7 +131,7 @@ namespace guecs { void init(TexturePack& textures); void render(sf::RenderWindow& window); - void mouse(sf::RenderWindow &window); + void mouse(float x, float y); }; Clickable make_action(DinkyECS::World& target, Events::GUI event); diff --git a/gui.cpp b/gui.cpp index 40be879..b0211af 100644 --- a/gui.cpp +++ b/gui.cpp @@ -352,9 +352,11 @@ namespace gui { } void FSM::mouse() { - // need to sort out how this will be easier with multiple UIs - $combat_view.$gui.mouse($window); - $status_view.$gui.mouse($window); + if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { + sf::Vector2f pos = $window.mapPixelToCoords(sf::Mouse::getPosition($window)); + $combat_view.$gui.mouse(pos.x, pos.y); + $status_view.$gui.mouse(pos.x, pos.y); + } } void FSM::generate_map() { diff --git a/systems.cpp b/systems.cpp index adac189..7a586b5 100644 --- a/systems.cpp +++ b/systems.cpp @@ -125,6 +125,10 @@ void System::death(GameLevel &level) { world.send(Events::GUI::DEATH, ent, {}); } else { // remove their motion so they're dead + // CHANGE: this needs to remove the enemies that are + // dead and then replace them at that position with + // a gave_stone device. And then that makes it so you + // can loot their dead bodies. world.remove(ent); } }