aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-10-21 06:59:01 -0500
committerClyne Sullivan <tullivan99@gmail.com>2016-10-21 06:59:01 -0500
commit4b1bee70774aae35c302636c8632e75bd6e23e5e (patch)
treefc2b269c1877a9133dfb7a17f26b08fc03a05d20 /src/world.cpp
parent17b4275fae1f6c5642156c73784622772d235c42 (diff)
something...
Diffstat (limited to 'src/world.cpp')
-rw-r--r--src/world.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/world.cpp b/src/world.cpp
index 4b5bb2d..5f696b5 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -299,6 +299,23 @@ void WorldSystem::load(const std::string& file)
game::time::setTickCount(std::stoi(wxml->GetText()));
}
+ else if (tagName == "entity") {
+ auto str2coord = [](std::string s) -> vec2 {
+ auto cpos = s.find(',');
+ s[cpos] = '\0';
+ return vec2 (std::stof(s), std::stof(s.substr(cpos + 1)));
+ };
+
+ auto entity = game::entities.create();
+
+ auto loc = wxml->Attribute("loc");
+ if (loc != nullptr) {
+ auto locVec = str2coord(loc);
+ float locDat[2] = {locVec.x, locVec.y};
+ entity.assign<Position>(locVec.x, locVec.y);
+ }
+ }
+
// hill creation
/*else if (tagName == "hill") {
addHill(ivec2 { wxml->IntAttribute("peakx"), wxml->IntAttribute("peaky") }, wxml->UnsignedAttribute("width"));
@@ -930,13 +947,12 @@ void WorldSystem::update(entityx::EntityManager &en, entityx::EventManager &ev,
void WorldSystem::detect(entityx::TimeDelta dt)
{
- game::entities.each<Position, Direction, Health, Solid>(
- [&](entityx::Entity e, Position &loc, Direction &vel, Health &health, Solid &dim) {
-
+ game::entities.each<Position, Direction, Solid>(
+ [&](entityx::Entity e, Position &loc, Direction &vel, Solid &dim) {
(void)e;
- if (health.health <= 0)
- UserError("die mofo");
+ //if (health.health <= 0)
+ // UserError("die mofo");
// get the line the entity is on
int line = std::clamp(static_cast<int>((loc.x + dim.width / 2 - world.startX) / game::HLINE),