Game now loads random enemies and items into rooms but in rudimentary way. Need to now randomize more of it and make it more robust so only changing the .json is needed to get new effects and enemies.
This commit is contained in:
parent
31e5eb7fce
commit
f2864a62ee
13 changed files with 119 additions and 76 deletions
59
main.cpp
59
main.cpp
|
@ -20,62 +20,6 @@ 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<GameConfig>();
|
||||
// configure a player as a fact of the world
|
||||
Player player{world.entity()};
|
||||
world.set_the<Player>(player);
|
||||
|
||||
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, {config.enemies["PLAYER_TILE"]["display"]});
|
||||
world.set<LightSource>(player.entity, {50,1.0});
|
||||
world.set<Inventory>(player.entity, {5});
|
||||
|
||||
auto sword = world.entity();
|
||||
auto pos = game_map.place_entity(1);
|
||||
world.set<Position>(sword, {pos.x+1, pos.y+1});
|
||||
world.set<Tile>(sword, {config.items["SWORD_RUSTY"]["display"]});
|
||||
world.set<InventoryItem>(sword, {1, config.items["SWORD_RUSTY"]});
|
||||
world.set<Weapon>(sword, {20});
|
||||
|
||||
auto torch = world.entity();
|
||||
pos = game_map.place_entity(2);
|
||||
world.set<Position>(torch, {pos.x+1, pos.y+1});
|
||||
world.set<Tile>(torch, {config.items["TORCH_BAD"]["display"]});
|
||||
world.set<InventoryItem>(torch, {1, config.items["TORCH_BAD"]});
|
||||
world.set<LightSource>(torch, {70,2.0f});
|
||||
|
||||
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, {config.enemies["UNICORN"]["display"]});
|
||||
|
||||
auto enemy2 = world.entity();
|
||||
world.set<Position>(enemy2, {game_map.place_entity(2)});
|
||||
world.set<Motion>(enemy2, {0,0});
|
||||
world.set<Combat>(enemy2, {20, 10});
|
||||
world.set<Tile>(enemy2, {config.enemies["SNAKE"]["display"]});
|
||||
world.set<LightSource>(enemy2, {60,0.2f});
|
||||
|
||||
auto gold = world.entity();
|
||||
world.set<Position>(gold, {game_map.place_entity(3)});
|
||||
world.set<Loot>(gold, {100});
|
||||
world.set<Tile>(gold, {config.items["CHEST_SMALL"]["display"]});
|
||||
world.set<InventoryItem>(gold, {1, config.items["CHEST_SMALL"]});
|
||||
|
||||
auto wall_torch = world.entity();
|
||||
world.set<Position>(wall_torch, {game_map.place_entity(4)});
|
||||
world.set<LightSource>(wall_torch, {90,3.0f});
|
||||
world.set<Tile>(wall_torch, {config.items["WALL_TORCH"]["display"]});
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
DinkyECS::World world;
|
||||
Map game_map(GAME_MAP_X, GAME_MAP_Y);
|
||||
|
@ -87,8 +31,7 @@ int main(int argc, char *argv[]) {
|
|||
save::from_file(save_path, world, game_map);
|
||||
} else {
|
||||
WorldBuilder builder(game_map);
|
||||
builder.generate();
|
||||
configure_world(world, game_map);
|
||||
builder.generate(world);
|
||||
}
|
||||
|
||||
SpatialMap collider;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue