touch brice.dat
$(EXEC): $(CXXOUTDIR)/$(CXXOBJ) main.cpp
- #g++ -I. -std=c++11 -c entityx/help/Pool.cc -o out/Pool.o
- #g++ -I. -std=c++11 -c entityx/help/Timer.cc -o out/Timer.o
- #g++ -I. -std=c++11 -c entityx/Event.cc -o out/Event.o
- #g++ -I. -std=c++11 -c entityx/Entity.cc -o out/Entity.o
- #g++ -I. -std=c++11 -c entityx/System.cc -o out/System.o
+ g++ -I. -std=c++11 -c entityx/help/Pool.cc -o out/Pool.o
+ g++ -I. -std=c++11 -c entityx/help/Timer.cc -o out/Timer.o
+ g++ -I. -std=c++11 -c entityx/Event.cc -o out/Event.o
+ g++ -I. -std=c++11 -c entityx/Entity.cc -o out/Entity.o
+ g++ -I. -std=c++11 -c entityx/System.cc -o out/System.o
@echo " CXX/LD main"
@$(CXX) $(CXXFLAGS) $(CXXINC) $(CXXWARN) -o $(EXEC) main.cpp out/*.o $(LIBS)
// signature?
save << "831998 ";
+ game::entities.lock();
game::entities.each<Position>([&](entityx::Entity entity, Position& pos) {
// save position
save << "p " << pos.x << ' ' << pos.y << ' ';
if (entity.has_component<Dialog>())
save << "d " << entity.component<Dialog>()->index << ' ';
});
+ game::entities.unlock();
save.close();
return true;
world.toLeft = world.toRight = "";
currentXMLFile = file;
+ game::entities.lock();
game::entities.reset();
game::engine.getSystem<PlayerSystem>()->create();
}
game::events.emit<BGMToggleEvent>();
+ game::entities.unlock();
}
/*
void WorldSystem::detect(entityx::TimeDelta dt)
{
+ game::entities.lock();
game::entities.each<Grounded, Position, Solid>(
[&](entityx::Entity e, Grounded &g, Position &loc, Solid &dim) {
- (void)e;
- if (!g.grounded) {
- // get the line the entity is on
- int line = std::clamp(static_cast<int>((loc.x + dim.width / 2 - world.startX) / game::HLINE),
- 0,
- static_cast<int>(world.data.size()));
-
+ (void)e;
+ if (!g.grounded) {
+ // get the line the entity is on
+ int line = std::clamp(static_cast<int>((loc.x + dim.width / 2 - world.startX) / game::HLINE),
+ 0, static_cast<int>(world.data.size()));
// make sure entity is above ground
- const auto& data = world.data;
- if (loc.y != data[line].groundHeight) {
- loc.y = data[line].groundHeight;
- e.remove<Grounded>();
- }
+ const auto& data = world.data;
+ if (loc.y != data[line].groundHeight) {
+ loc.y = data[line].groundHeight;
+ e.remove<Grounded>();
}
-
- });
+ }
+ });
game::entities.each<Direction, Physics>(
[&](entityx::Entity e, Direction &vel, Physics &phys) {
- (void)e;
- // handle gravity
- if (vel.y > -2.0f)
- vel.y -= (GRAVITY_CONSTANT * phys.g) * dt;
- });
+ (void)e;
+ // handle gravity
+ if (vel.y > -2.0f)
+ vel.y -= (GRAVITY_CONSTANT * phys.g) * dt;
+ });
game::entities.each<Position, Direction, Solid>(
[&](entityx::Entity e, Position &loc, Direction &vel, Solid &dim) {
// get the line the entity is on
int line = std::clamp(static_cast<int>((loc.x + dim.width / 2 - world.startX) / game::HLINE),
- 0,
- static_cast<int>(world.data.size()));
+ 0, static_cast<int>(world.data.size()));
// make sure entity is above ground
const auto& data = world.data;
loc.x = -(static_cast<int>(world.startX)) - dim.width - game::HLINE;
}
});
+ game::entities.unlock();
}
void WorldSystem::goWorldRight(Position& p, Solid &d)
p.x = world.outdoorCoords.x; // ineffective, player is regen'd
p.y = world.outdoorCoords.y;
} else {
+ game::entities.lock();
game::entities.each<Position, Solid, Portal>(
[&](entityx::Entity entity, Position& loc, Solid &dim, Portal &portal) {
- (void)entity;
- if (!(portal.toFile.empty()) && p.x > loc.x && p.x < loc.x + dim.width) {
- file = portal.toFile;
- world.outdoor = currentXMLFile;
- world.outdoorCoords = vec2(loc.x + dim.width / 2, 100);
- return;
- }
+ (void)entity;
+ if (!(portal.toFile.empty()) && p.x > loc.x && p.x < loc.x + dim.width) {
+ file = portal.toFile;
+ world.outdoor = currentXMLFile;
+ world.outdoorCoords = vec2(loc.x + dim.width / 2, 100);
+ return;
}
- );
+ });
+ game::entities.unlock();
}
if (!file.empty()) {