aboutsummaryrefslogtreecommitdiffstats
path: root/src/systems
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2017-10-17 22:21:52 -0400
committerClyne Sullivan <tullivan99@gmail.com>2017-10-17 22:21:52 -0400
commitd79f4a7f4b5aff5931ef86edd2537ef5e3620fd4 (patch)
tree2ad2d8a9ed9ffee36474fb111f4654511f0717b4 /src/systems
parent03246da32a8452e6a76ccf2f7f97cda4472d1d29 (diff)
arrow rotation... kinda
Diffstat (limited to 'src/systems')
-rw-r--r--src/systems/render.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/systems/render.cpp b/src/systems/render.cpp
index ce79522..a25b152 100644
--- a/src/systems/render.cpp
+++ b/src/systems/render.cpp
@@ -76,6 +76,16 @@ void RenderSystem::render(void)
loc.x, loc.y + size.y, visible.z + its, sp.offset_tex.x, sp.offset_tex.y + sp.size_tex.y
};
+ if (S.first.veltate) {
+ auto vel = entity.component<Direction>();
+ float angle = static_cast<float>(std::atan(vel->y / vel->x)) * 180 / 3.14f;
+ auto toOrigin = glm::translate(glm::mat4(1.0f), glm::vec3(-pos.x, -pos.y, 0.0f));
+ auto rotation = glm::rotate(glm::mat4(1.0f), angle, glm::vec3(0.0f, 0.0f, 1.0f));
+ auto toBack = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, pos.y, 0.0f));
+ auto fine = toBack * rotation * toOrigin;
+ glUniformMatrix4fv(Render::worldShader.uniform[WU_transform], 1, GL_FALSE, glm::value_ptr(fine));
+ }
+
sp.tex.use();
glUniform1i(Render::worldShader.uniform[WU_texture], 0);