aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-11-30 21:37:01 -0500
committerClyne Sullivan <tullivan99@gmail.com>2016-11-30 21:37:01 -0500
commite472a62b750e57724a26d299bb682b4f39405d05 (patch)
tree6c9a722c6840d1f7446edec2be3290da20be5db6 /src
parentcc2a768ff19e9fc83661a51d4cb4fef9b354ff30 (diff)
parent44a42be2087b0d6e4b732596029d8f41d7ca6b40 (diff)
fixed coalesce
Diffstat (limited to 'src')
-rw-r--r--src/components.cpp14
-rw-r--r--src/world.cpp29
2 files changed, 27 insertions, 16 deletions
diff --git a/src/components.cpp b/src/components.cpp
index a398bec..612e522 100644
--- a/src/components.cpp
+++ b/src/components.cpp
@@ -19,6 +19,13 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e
position.x += direction.x * dt;
position.y += direction.y * dt;
+ if (entity.has_component<Animate>() && entity.has_component<Sprite>()) {
+ if (direction.x) {
+ entity.component<Sprite>().get()->sprite = entity.component<Animate>().get()->nextFrame();
+ } else {
+ entity.component<Sprite>().get()->sprite = entity.component<Animate>().get()->firstFrame();
+ }
+ }
if (entity.has_component<Dialog>() && entity.component<Dialog>()->talking) {
direction.x = 0;
} else {
@@ -73,6 +80,7 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev,
Render::worldShader.use();
en.each<Visible, Sprite, Position>([dt](entityx::Entity entity, Visible &visible, Sprite &sprite, Position &pos) {
+ (void)entity;
// Verticies and shit
GLfloat tex_coord[] = {0.0, 0.0,
1.0, 0.0,
@@ -90,9 +98,8 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev,
1.0, 1.0,
1.0, 0.0};
- if (entity.has_component<Animate>()) {
- sprite.sprite = entity.component<Animate>().get()->nextFrame();
- }
+ if (entity.has_component<Animate>())
+ sprite.sprite = entity.component<Animate>()->nextFrame();
for (auto &S : sprite.sprite) {
float width = HLINES(S.first.size.x);
@@ -270,7 +277,6 @@ std::vector<Frame> developFrame(XMLElement* xml)
std::string sname = sxml->Name();
if (sname == "src") {
tmpf.push_back(std::make_pair(SpriteData(sxml->GetText(), vec2(0,0)), vec2(0,0)));
- std::cout << tmpf.back().first.pic << std::endl;
}
sxml = sxml->NextSiblingElement();
}
diff --git a/src/world.cpp b/src/world.cpp
index 68b8f34..4a7e284 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -1043,19 +1043,22 @@ void WorldSystem::render(void)
static const auto blackTex = Texture::genColor(Color(0, 0, 0));
static const float sheight = static_cast<float>(SCREEN_HEIGHT);
+
if (offset.x + world.startX > s) {
glBindTexture(GL_TEXTURE_2D, blackTex);
glUniform1f(Render::worldShader.uniform[WU_light_impact], 0.0f);
+ auto off = offset.y - static_cast<float>(SCREEN_HEIGHT) / 2.0f;
+
GLfloat blackBarLeft[] = {
- s, 0.0f, -3.5f, 0.0f, 0.0f,
- world.startX, 0.0f, -3.5f, 1.0f, 0.0f,
- world.startX, sheight, -3.5f, 1.0f, 1.0f,
+ s, 0.0f + off, -3.5f, 0.0f, 0.0f,
+ world.startX, 0.0f + off, -3.5f, 1.0f, 0.0f,
+ world.startX, sheight + off, -3.5f, 1.0f, 1.0f,
- world.startX, sheight, -3.5f, 1.0f, 1.0f,
- s, sheight, -3.5f, 0.0f, 1.0f,
- s, 0.0f, -3.5f, 0.0f, 0.0f
+ world.startX, sheight + off, -3.5f, 1.0f, 1.0f,
+ s, sheight + off, -3.5f, 0.0f, 1.0f,
+ s, 0.0f + off, -3.5f, 0.0f, 0.0f
};
glVertexAttribPointer(Render::worldShader.coord, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 5, &blackBarLeft[0]);
@@ -1066,15 +1069,17 @@ void WorldSystem::render(void)
if (offset.x - world.startX < e) {
glBindTexture(GL_TEXTURE_2D, blackTex);
glUniform1f(Render::worldShader.uniform[WU_light_impact], 0.0f);
+
+ auto off = offset.y - static_cast<float>(SCREEN_HEIGHT) / 2.0f;
GLfloat blackBarRight[] = {
- -(world.startX), 0.0f, -3.5f, 0.0f, 0.0f,
- e, 0.0f, -3.5f, 1.0f, 0.0f,
- e, sheight, -3.5f, 1.0f, 1.0f,
+ -(world.startX), 0.0f + off, -3.5f, 0.0f, 0.0f,
+ e, 0.0f + off, -3.5f, 1.0f, 0.0f,
+ e, sheight + off, -3.5f, 1.0f, 1.0f,
- e, sheight, -3.5f, 1.0f, 1.0f,
- -(world.startX), sheight, -3.5f, 0.0f, 1.0f,
- -(world.startX), 0.0f, -3.5f, 0.0f, 0.0f
+ e, sheight + off, -3.5f, 1.0f, 1.0f,
+ -(world.startX), sheight + off, -3.5f, 0.0f, 1.0f,
+ -(world.startX), 0.0f + off, -3.5f, 0.0f, 0.0f
};
glVertexAttribPointer(Render::worldShader.coord, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 5, &blackBarRight[0]);