More notes on the next things to do.

main
Zed A. Shaw 2 weeks ago
parent 011fee4872
commit 0e79288afc
  1. 5
      components.hpp
  2. 2
      dinkyecs.hpp
  3. 9
      gui.cpp
  4. 1
      main.cpp
  5. 2
      save.cpp
  6. 3
      save.hpp
  7. 10
      status.txt
  8. 5
      systems.cpp

@ -27,6 +27,11 @@ namespace components {
DEFINE_SERIALIZABLE(Loot, amount); DEFINE_SERIALIZABLE(Loot, amount);
}; };
struct Inventory {
int gold;
DEFINE_SERIALIZABLE(Inventory, gold);
};
struct Tile { struct Tile {
std::string chr; std::string chr;
DEFINE_SERIALIZABLE(Tile, chr); DEFINE_SERIALIZABLE(Tile, chr);

@ -124,6 +124,4 @@ namespace DinkyECS {
return !queue.empty(); return !queue.empty();
} }
}; };
} }

@ -73,18 +73,21 @@ void GUI::create_renderer() {
$document = Renderer([&, player]{ $document = Renderer([&, player]{
const auto& player_combat = $world.get<Combat>(player.entity); const auto& player_combat = $world.get<Combat>(player.entity);
const auto& inventory = $world.get<Inventory>(player.entity);
$status_text = player_combat.hp > 0 ? "NOT DEAD" : "DEAD!!!!!!"; $status_text = player_combat.hp > 0 ? "NOT DEAD" : "DEAD!!!!!!";
std::vector<Element> log_list; std::vector<Element> log_list;
for(auto msg : $log.messages) { for(auto msg : $log.messages) {
log_list.push_back(text(msg)); log_list.push_back(text(msg));
} }
auto log_box = vbox(log_list) | yflex_grow | border; auto log_box = vbox(log_list) | yflex_grow | border;
return hbox({ return hbox({
hflow( hflow(
vbox( vbox(
text(format("HP: {: >3}", player_combat.hp)) | border, text(format("HP: {: >3} GOLD: {: >3}",
player_combat.hp, inventory.gold)) | border,
text($status_text) | border, text($status_text) | border,
separator(), separator(),
log_box log_box
@ -126,7 +129,9 @@ void GUI::handle_world_events() {
break; break;
case eGUI::LOOT: { case eGUI::LOOT: {
auto loot = $world.get<Loot>(entity); auto loot = $world.get<Loot>(entity);
$log.log(format("You found {} gold.", loot.amount)); auto inventory = $world.get<Inventory>(player.entity);
$log.log(format("You found {} gold. You have {} now.",
loot.amount, inventory.gold));
} }
break; break;
default: default:

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

@ -27,6 +27,7 @@ void save::to_file(fs::path path, DinkyECS::World &world, Map &map) {
extract<Combat>(world, save_data.combat); extract<Combat>(world, save_data.combat);
extract<Motion>(world, save_data.motion); extract<Motion>(world, save_data.motion);
extract<Tile>(world, save_data.tile); extract<Tile>(world, save_data.tile);
extract<Inventory>(world, save_data.inventory);
archive.save(save_data); archive.save(save_data);
std::string_view archive_view = archive.get_buffer(); std::string_view archive_view = archive.get_buffer();
@ -68,6 +69,7 @@ void save::from_file(fs::path path, DinkyECS::World &world_out, Map &map_out) {
inject<Combat>(world_out, save_data.combat); inject<Combat>(world_out, save_data.combat);
inject<Motion>(world_out, save_data.motion); inject<Motion>(world_out, save_data.motion);
inject<Tile>(world_out, save_data.tile); inject<Tile>(world_out, save_data.tile);
inject<Inventory>(world_out, save_data.inventory);
map_out = Map(save_data.map.input_map, map_out = Map(save_data.map.input_map,
save_data.map.walls, save_data.map.limit); save_data.map.walls, save_data.map.limit);

@ -33,8 +33,9 @@ namespace save {
std::map<DinkyECS::Entity, components::Motion> motion; std::map<DinkyECS::Entity, components::Motion> motion;
std::map<DinkyECS::Entity, components::Combat> combat; std::map<DinkyECS::Entity, components::Combat> combat;
std::map<DinkyECS::Entity, components::Tile> tile; std::map<DinkyECS::Entity, components::Tile> tile;
std::map<DinkyECS::Entity, components::Inventory> inventory;
DEFINE_SERIALIZABLE(SaveData, facts, map, position, motion, combat, tile); DEFINE_SERIALIZABLE(SaveData, facts, map, position, motion, combat, tile, inventory);
}; };
void to_file(fs::path path, DinkyECS::World &world, Map &map); void to_file(fs::path path, DinkyECS::World &world, Map &map);

@ -3,10 +3,18 @@ NOTES:
TODO: TODO:
* Event system could take additional data so that the events can be more coarse and simpler.
* Simplify the combat/collision system so that it's not a bunch of if-cases.
* Inventory needs to be better, but need some kinds of "weapons" or other loot to get and not just gold.
* Run the ansi_parser on the whole UI so I can use colors and other glyphs.
* Create a few more enemy types to fight.
* Devise a more complete map/world generator that can use the loot and enemies better.
* Maybe an LOS system, but the hearing version works pretty well so far.
* Probably a system for mapping collision types to sound effects, rather than having the GUI do it.
* Write a test that generates a ton of maps then confirms there's a path from one room to every other room? * Write a test that generates a ton of maps then confirms there's a path from one room to every other room?
* Lua integration? * Lua integration?
* BUG: If map is < 90 zome out crashes. * BUG: If map is < 90 zome out crashes.
* Simple loot system.
* Bring back sounds, check out SoLoud. * Bring back sounds, check out SoLoud.

@ -127,6 +127,11 @@ void System::combat(DinkyECS::World &world, Player &player) {
} }
} else if(world.has<Loot>(entity)) { } else if(world.has<Loot>(entity)) {
world.send<eGUI>(eGUI::LOOT, entity); world.send<eGUI>(eGUI::LOOT, entity);
auto &loot = world.get<Loot>(entity);
auto &loot_pos = world.get<Position>(entity);
auto &inventory = world.get<Inventory>(player.entity);
inventory.gold += loot.amount;
collider.remove(loot_pos.location);
} else { } else {
println("UNKNOWN COLLISION TYPE {}", entity); println("UNKNOWN COLLISION TYPE {}", entity);
} }

Loading…
Cancel
Save