aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2017-01-06 08:52:56 -0500
committerClyne Sullivan <tullivan99@gmail.com>2017-01-06 08:52:56 -0500
commit1358acea95c821729f3770ea5968d9476b621936 (patch)
treeb0636f49c5a444390de54ac5dc7a508cf17bc057 /src
parentefcf1a88cd0d0bee3973705b5975827be97f5a3a (diff)
parent37426dbe5fccd6702f1c98fb8a0e25910eeacb70 (diff)
Merge branch 'master' of https://github.com/tcsullivan/gamedev
Diffstat (limited to 'src')
-rw-r--r--src/components.cpp23
-rw-r--r--src/world.cpp22
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 6cce2b0..6f31a5b 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -347,9 +347,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;
@@ -393,13 +393,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();
}
}