aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components.cpp8
-rw-r--r--src/ui.cpp10
-rw-r--r--src/window.cpp8
-rw-r--r--src/world.cpp21
4 files changed, 26 insertions, 21 deletions
diff --git a/src/components.cpp b/src/components.cpp
index 19ba0fb..644d504 100644
--- a/src/components.cpp
+++ b/src/components.cpp
@@ -53,12 +53,12 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e
if (entity.has_component<Aggro>()) {
auto ppos = game::engine.getSystem<PlayerSystem>()->getPosition();
if (ppos.x > position.x && ppos.x < position.x + entity.component<Solid>()->width) {
- //auto& h = entity.component<Health>()->health;
- //if (h > 0) {
+ auto& h = entity.component<Health>()->health;
+ if (h > 0) {
fight = true;
toFight = entity;
- // h = 0;
- //}
+ h = 0;
+ }
} else
direction.x = (ppos.x > position.x) ? .05 : -.05;
} else if (entity.has_component<Wander>()) {
diff --git a/src/ui.cpp b/src/ui.cpp
index b9c2119..58a6b97 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -1103,14 +1103,6 @@ namespace ui {
auto SCREEN_WIDTH = game::SCREEN_WIDTH;
auto SCREEN_HEIGHT = game::SCREEN_HEIGHT;
- std::vector<GLubyte> bgr (SCREEN_WIDTH * SCREEN_HEIGHT * 3, 0);
-
- for(unsigned int x = 0; x < SCREEN_WIDTH*SCREEN_HEIGHT*3; x+=3) {
- bgr[x] = pixels[x+2];
- bgr[x+1] = pixels[x+1];
- bgr[x+2] = pixels[x];
- }
-
time_t epoch = time(nullptr);
struct tm* timen = localtime(&epoch);
@@ -1161,7 +1153,7 @@ namespace ui {
fwrite(&bmfh, 1,sizeof(BITMAPFILEHEADER),bmp);
fwrite(&bmih, 1,sizeof(BITMAPINFOHEADER),bmp);
- fwrite(&bgr, 1,3*SCREEN_WIDTH*SCREEN_HEIGHT,bmp);
+ fwrite(pixels, 1,3*SCREEN_WIDTH*SCREEN_HEIGHT*sizeof(GLubyte),bmp);
delete[] pixels;
diff --git a/src/window.cpp b/src/window.cpp
index 049ee69..7d8f8e7 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -97,14 +97,10 @@ void WindowSystem::render(void)
if (doScreenshot.load()) {
doScreenshot.store(false);
// Make the BYTE array, factor of 3 because it's RBG.
- static GLubyte* pixels;
int count = 3 * game::SCREEN_WIDTH * game::SCREEN_HEIGHT;
- pixels = new GLubyte[count];
- glReadPixels(0, 0, game::SCREEN_WIDTH, game::SCREEN_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels);
- //for(int i = 0; i < count; i++)
- // pixels[i] = 255;
+ GLubyte* pixels = new GLubyte[count];
+ glReadPixels(0, 0, game::SCREEN_WIDTH, game::SCREEN_HEIGHT, GL_BGR, GL_UNSIGNED_BYTE, pixels);
ui::takeScreenshot(pixels);
- std::cout << "Triggered\n";
}
SDL_GL_SwapWindow(window);
diff --git a/src/world.cpp b/src/world.cpp
index 5d6202d..6c58515 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -157,10 +157,27 @@ static std::vector<entityx::Entity::Id> savedEntities;
void WorldSystem::fight(entityx::Entity entity)
{
- savedEntities.clear();
+ std::string exit = currentXMLFile;
+
savedEntities.emplace_back(entity.id());
load(entity.component<Aggro>()->arena);
+ savedEntities.clear();
+
+ entity.component<Health>()->health = entity.component<Health>()->maxHealth;
entity.remove<Aggro>();
+
+ auto door = game::entities.create();
+ door.assign<Position>(0, 100);
+ door.assign<Grounded>();
+ door.assign<Visible>(-5);
+ door.assign<Portal>(exit);
+
+ auto sprite = door.assign<Sprite>();
+ Texture dtex ("assets/style/classic/door.png");
+ sprite->addSpriteSegment(SpriteData(dtex), 0);
+
+ auto dim = sprite->getSpriteSize();
+ door.assign<Solid>(dim.x, dim.y);
}
void WorldSystem::load(const std::string& file)
@@ -173,7 +190,7 @@ void WorldSystem::load(const std::string& file)
if (file.empty())
return;
- // insert smiley face showing teeth as if we're doing something bad
+ // save the current world's data
save();
// load file data to string