From 44a42be2087b0d6e4b732596029d8f41d7ca6b40 Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Wed, 30 Nov 2016 21:11:32 -0500 Subject: Some more anim --- src/components.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/components.cpp') diff --git a/src/components.cpp b/src/components.cpp index eb9fb0e..b74555c 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -18,7 +18,14 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e en.each([dt](entityx::Entity entity, Position &position, Direction &direction) { position.x += direction.x * dt; position.y += direction.y * dt; - + + if (entity.has_component() && entity.has_component()) { + if (direction.x) { + entity.component().get()->sprite = entity.component().get()->nextFrame(); + } else { + entity.component().get()->sprite = entity.component().get()->firstFrame(); + } + } if (entity.has_component() && entity.component()->talking) { direction.x = 0; } else { @@ -73,6 +80,7 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, Render::worldShader.use(); en.each([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, @@ -89,10 +97,6 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0}; - - if (entity.has_component()) { - sprite.sprite = entity.component().get()->nextFrame(); - } for (auto &S : sprite.sprite) { float width = HLINES(S.first.size.x); @@ -265,7 +269,6 @@ std::vector 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(); } -- cgit v1.2.3