Game now builds and is using the new dynamic component loading but enemies do not spawn in and device events are really working. Also inventory is a giant bag of fail and needs a rewrite.
This commit is contained in:
parent
9e91c71125
commit
a69be90464
23 changed files with 130 additions and 122 deletions
|
@ -17,8 +17,8 @@ struct Position {
|
|||
Point location;
|
||||
};
|
||||
|
||||
DINKY_HAS_COMPONENT(Point, x, y);
|
||||
DINKY_HAS_COMPONENT(Position, location);
|
||||
// DINKY_HAS_COMPONENT(Point, x, y);
|
||||
// DINKY_HAS_COMPONENT(Position, location);
|
||||
|
||||
struct Motion {
|
||||
int dx;
|
||||
|
@ -26,25 +26,25 @@ struct Motion {
|
|||
bool random=false;
|
||||
};
|
||||
|
||||
DINKY_HAS_COMPONENT(Motion, dx, dy, random);
|
||||
// DINKY_HAS_COMPONENT(Motion, dx, dy, random);
|
||||
|
||||
struct Velocity {
|
||||
double x, y;
|
||||
};
|
||||
|
||||
DINKY_HAS_COMPONENT(Velocity, x, y);
|
||||
// DINKY_HAS_COMPONENT(Velocity, x, y);
|
||||
|
||||
struct Gravity {
|
||||
double level;
|
||||
};
|
||||
|
||||
DINKY_HAS_COMPONENT(Gravity, level);
|
||||
// DINKY_HAS_COMPONENT(Gravity, level);
|
||||
|
||||
struct DaGUI {
|
||||
int event;
|
||||
};
|
||||
|
||||
DINKY_HAS_COMPONENT(DaGUI, event);
|
||||
// DINKY_HAS_COMPONENT(DaGUI, event);
|
||||
|
||||
/*
|
||||
* Using a function catches instances where I'm not copying
|
||||
|
@ -201,6 +201,7 @@ TEST_CASE("confirm copying and constants", "[ecs-constants]") {
|
|||
|
||||
|
||||
TEST_CASE("test serialization with nlohmann::json", "[ecs-serialize]") {
|
||||
/*
|
||||
DinkyECS::ComponentMap component_map;
|
||||
DinkyECS::Component<Position>(component_map);
|
||||
DinkyECS::Component<Velocity>(component_map);
|
||||
|
@ -247,4 +248,5 @@ TEST_CASE("test serialization with nlohmann::json", "[ecs-serialize]") {
|
|||
REQUIRE(motion.dy == 1);
|
||||
REQUIRE(motion.random == false);
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <nlohmann/json.hpp>
|
||||
#include <fstream>
|
||||
#include "components.hpp"
|
||||
#include "inventory.hpp"
|
||||
#include "dinkyecs.hpp"
|
||||
#include "save.hpp"
|
||||
#include "systems.hpp"
|
||||
|
@ -15,17 +16,16 @@ using std::string;
|
|||
using namespace components;
|
||||
|
||||
|
||||
DinkyECS::Entity add_items(DinkyECS::ComponentMap component_map, DinkyECS::World &world, GameConfig &config) {
|
||||
DinkyECS::Entity add_items(components::ComponentMap component_map, DinkyECS::World &world, GameConfig &config) {
|
||||
auto sword = world.entity();
|
||||
json& item_data = config.items["SWORD_RUSTY"];
|
||||
world.set<InventoryItem>(sword, {item_data["inventory_count"], item_data});
|
||||
DinkyECS::configure(component_map, world, sword, item_data);
|
||||
components::configure_entity(component_map, world, sword, item_data);
|
||||
return sword;
|
||||
}
|
||||
|
||||
TEST_CASE("basic inventory test", "[inventory]") {
|
||||
// BUG: rewrite this
|
||||
REQUIRE(true == false);
|
||||
/*
|
||||
DinkyECS::World world;
|
||||
save::load_configs(world);
|
||||
|
|
|
@ -36,8 +36,6 @@ TEST_CASE("map placement test", "[map:placement]") {
|
|||
GameLevel level = levels.current();
|
||||
auto &map = *level.map;
|
||||
|
||||
map.invert_space();
|
||||
|
||||
for(size_t rnum = 0; rnum < map.room_count(); rnum++) {
|
||||
Room &room = map.room(rnum);
|
||||
Point pos;
|
||||
|
|
|
@ -290,11 +290,6 @@ TEST_CASE("random rectangle", "[matrix:rando_rect]") {
|
|||
|
||||
for(matrix::rando_rect it{map->walls(), room.x, room.y, room.width, room.height}; it.next();)
|
||||
{
|
||||
if(map->iswall(it.x, it.y)) {
|
||||
matrix::dump("BAD RECTANGLE SPOT", map->walls(), it.x, it.y);
|
||||
}
|
||||
|
||||
REQUIRE(!map->iswall(it.x, it.y));
|
||||
REQUIRE(size_t(it.x) >= room.x);
|
||||
REQUIRE(size_t(it.y) >= room.y);
|
||||
REQUIRE(size_t(it.x) <= room.x + room.width);
|
||||
|
@ -303,7 +298,6 @@ TEST_CASE("random rectangle", "[matrix:rando_rect]") {
|
|||
wall_copy[it.y][it.x] = wall_copy[it.y][it.x] + 5;
|
||||
}
|
||||
}
|
||||
|
||||
// matrix::dump("WALLS FILLED", wall_copy);
|
||||
}
|
||||
}
|
||||
|
@ -311,7 +305,6 @@ TEST_CASE("random rectangle", "[matrix:rando_rect]") {
|
|||
TEST_CASE("standard rectangle", "[matrix:rectangle]") {
|
||||
for(int i = 0; i < 20; i++) {
|
||||
shared_ptr<Map> map = make_map();
|
||||
map->invert_space();
|
||||
auto wall_copy = map->walls();
|
||||
|
||||
for(size_t rnum = 0; rnum < map->room_count(); rnum++) {
|
||||
|
@ -320,11 +313,6 @@ TEST_CASE("standard rectangle", "[matrix:rectangle]") {
|
|||
|
||||
for(matrix::rectangle it{map->walls(), room.x, room.y, room.width, room.height}; it.next();)
|
||||
{
|
||||
if(map->iswall(it.x, it.y)) {
|
||||
matrix::dump("BAD RECTANGLE SPOT", map->walls(), it.x, it.y);
|
||||
}
|
||||
|
||||
REQUIRE(!map->iswall(it.x, it.y));
|
||||
REQUIRE(size_t(it.x) >= room.x);
|
||||
REQUIRE(size_t(it.y) >= room.y);
|
||||
REQUIRE(size_t(it.x) <= room.x + room.width);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue