diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components.cpp | 23 | ||||
-rw-r--r-- | src/world.cpp | 22 |
2 files changed, 27 insertions, 18 deletions
diff --git a/src/components.cpp b/src/components.cpp index 140d02b..6f243a7 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -82,9 +82,21 @@ 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 float its = 0; + + float sz; + if (entity.has_component<Solid>()) { + sz = entity.component<Solid>()->width; + } + if(sprite.faceLeft) { + glm::mat4 scale = glm::scale(glm::mat4(1.0f), glm::vec3(-1.0f,1.0f,1.0f)); + glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f - sz - pos.x * 2.0f, 0.0f, 0.0f)); + + glm::mat4 mov = scale * translate; + glUniformMatrix4fv(Render::worldShader.uniform[WU_transform], 1, GL_FALSE, glm::value_ptr(mov)); + } + for (auto &S : sprite.sprite) { auto sp = S.first; auto size = sp.size * game::HLINE; @@ -99,13 +111,6 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, sp.offset_tex.x, sp.offset_tex.y + sp.size_tex.y, sp.offset_tex.x, sp.offset_tex.y}; - if(sprite.faceLeft) { - glm::mat4 scale = glm::scale(glm::mat4(1.0f), glm::vec3(-1.0f,1.0f,1.0f)); - glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f - size.x - pos.x * 2.0f, 0.0f, 0.0f)); - - glm::mat4 mov = scale * translate; - glUniformMatrix4fv(Render::worldShader.uniform[WU_transform], 1, GL_FALSE, glm::value_ptr(mov)); - } GLfloat coords[] = {loc.x, loc.y, visible.z + its, loc.x + size.x, loc.y, visible.z + its, @@ -132,11 +137,11 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, glVertexAttribPointer(Render::worldShader.tex, 2, GL_FLOAT, GL_FALSE, 0 ,tex_coord); glDrawArrays(GL_TRIANGLES, 0, 6); - glUniformMatrix4fv(Render::worldShader.uniform[WU_transform], 1, GL_FALSE, glm::value_ptr(glm::mat4(1.0f))); glUniform4f(Render::worldShader.uniform[WU_tex_color], 1.0, 1.0, 1.0, 1.0); its-=.01; } + glUniformMatrix4fv(Render::worldShader.uniform[WU_transform], 1, GL_FALSE, glm::value_ptr(glm::mat4(1.0f))); }); Render::worldShader.disable(); diff --git a/src/world.cpp b/src/world.cpp index b10edac..08426a8 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -338,9 +338,9 @@ void WorldSystem::load(const std::string& file) if (abcd->Attribute("value") != nullptr) dim = str2coord(abcd->StrAttribute("value")); else - dim = entity.component<Sprite>().get()->getSpriteSize() * game::HLINE; + dim = entity.component<Sprite>()->getSpriteSize(); - float cdat[2] = {dim.x, dim.y}; + float cdat[2] = {dim.x * game::HLINE, dim.y * game::HLINE}; entity.assign<Solid>(cdat[0], cdat[1]); } else if (tname == "Direction") { vec2 dir; @@ -384,13 +384,17 @@ void WorldSystem::load(const std::string& file) while (animx) { std::string animType = animx->Name(); if (animType == "movement") { - auto frames = developFrame(animx); - if (animx->UnsignedAttribute("changeID") != XML_NO_ERROR) - idtc = 0; - else - idtc = animx->UnsignedAttribute("changeID"); - for (uint i = 0; i < frames.size(); i++) { - entan->frame.push_back(std::make_pair(idtc, frames[i])); + auto limbx = animx->FirstChildElement(); + while (limbx) { + auto frames = developFrame(limbx); + if (limbx->UnsignedAttribute("changeID") != XML_NO_ERROR) + idtc = 0; + else + idtc = limbx->UnsignedAttribute("changeID"); + for (uint i = 0; i < frames.size(); i++) { + entan->frame.push_back(std::make_pair(idtc, frames[i])); + } + limbx = limbx->NextSiblingElement(); } } |