Cereal works pretty well so I may use it, but there's one more library I want to try first called tser.

This commit is contained in:
Zed A. Shaw 2024-11-04 05:07:49 -05:00
parent ddf1ba955c
commit 713d400d17
9 changed files with 95 additions and 21 deletions

View file

@ -17,6 +17,7 @@ using namespace ftxui;
* system.
*/
void configure_world(DinkyECS::World &world, Map &game_map) {
const auto &config = world.get_the<MapConfig>();
// this sets up the gui event system
world.set_the<Events::GUI>(Events::GUI::START);
@ -30,13 +31,13 @@ void configure_world(DinkyECS::World &world, Map &game_map) {
world.set<Position>(player.entity, {game_map.place_entity(0)});
world.set<Motion>(player.entity, {0, 0});
world.set<Combat>(player.entity, {100, 10});
world.set<Tile>(player.entity, {PLAYER_TILE});
world.set<Tile>(player.entity, {config.PLAYER_TILE});
auto enemy = world.entity();
world.set<Position>(enemy, {game_map.place_entity(1)});
world.set<Motion>(enemy, {0,0});
world.set<Combat>(enemy, {20, 10});
world.set<Tile>(enemy, {ENEMY_TILE});
world.set<Tile>(enemy, {config.ENEMY_TILE});
auto enemy2 = world.entity();
world.set<Position>(enemy2, {game_map.place_entity(2)});
@ -57,6 +58,20 @@ int main() {
Config config("./assets/config.json");
world.set_the<Config>(config);
auto map = config["map"];
world.set_the<MapConfig>({
map["WALL_TILE"],
map["FLOOR_TILE"],
map["PLAYER_TILE"],
map["ENEMY_TILE"],
map["BG_TILE"]
});
auto enemy = config["enemy"];
world.set_the<EnemyConfig>({
enemy["HEARING_DISTANCE"]
});
Map game_map(GAME_MAP_X, GAME_MAP_Y);
game_map.generate();