#include "gui.hpp" #include "dinkyecs.hpp" #include "systems.hpp" #include "events.hpp" #include "components.hpp" #include "constants.hpp" #include "dbc.hpp" #include "collider.hpp" #include "render.hpp" #include "save.hpp" #include "lights.hpp" #include "worldbuilder.hpp" #include "ftxui/screen/terminal.hpp" // for SetColorSupport, Color, TrueColor #include #include using namespace ftxui; using namespace components; using lighting::LightSource; namespace fs = std::filesystem; /* * This needs to be turned into a real world generator * system. */ void configure_world(DinkyECS::World &world, Map &game_map) { auto &config = world.get_the(); // configure a player as a fact of the world Player player{world.entity()}; world.set_the(player); world.set(player.entity, {game_map.place_entity(0)}); world.set(player.entity, {0, 0}); world.set(player.entity, {100, 10}); world.set(player.entity, {config.enemies["PLAYER_TILE"]["display"]}); world.set(player.entity, {5}); world.set(player.entity, {70,1.0}); auto enemy = world.entity(); world.set(enemy, {game_map.place_entity(1)}); world.set(enemy, {0,0}); world.set(enemy, {20, 10}); world.set(enemy, {config.enemies["UNICORN"]["display"]}); auto enemy2 = world.entity(); world.set(enemy2, {game_map.place_entity(2)}); world.set(enemy2, {0,0}); world.set(enemy2, {20, 10}); world.set(enemy2, {config.enemies["SNAKE"]["display"]}); world.set(enemy2, {60,0.2f}); auto gold = world.entity(); world.set(gold, {game_map.place_entity(3)}); world.set(gold, {100}); world.set(gold, {config.items["CHEST"]["display"]}); auto wall_torch = world.entity(); world.set(wall_torch, {game_map.place_entity(4)}); world.set(wall_torch, {90,3.0f}); world.set(wall_torch, {config.items["WALL_TORCH"]["display"]}); auto torch = world.entity(); Point at = game_map.place_entity(2); world.set(torch, {{at.x+1, at.y+1}}); world.set(torch, {{0}}); world.set(torch, {70,1.5f}); world.set(torch, {config.items["TORCH"]["display"]}); auto sword = world.entity(); at = game_map.place_entity(1); world.set(sword, {at.x+1, at.y+1}); world.set(sword, {.damage=20}); world.set(sword, {{0}}); world.set(sword, {config.items["SWORD"]["display"]}); } int main(int argc, char *argv[]) { DinkyECS::World world; Map game_map(GAME_MAP_X, GAME_MAP_Y); save::load_configs(world); if(argc == 2) { fmt::println("Loading save file {}", argv[1]); fs::path save_path{argv[1]}; save::from_file(save_path, world, game_map); } else { WorldBuilder builder(game_map); builder.generate(); configure_world(world, game_map); } spatial_map collider; world.set_the(collider); System::init_positions(world); GUI gui(world, game_map); return gui.main(); }