diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2016-11-30 21:11:32 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2016-11-30 21:11:32 -0500 |
commit | 44a42be2087b0d6e4b732596029d8f41d7ca6b40 (patch) | |
tree | 3c5ee20a47fcc55173b7026ebc8139d02810494d /src/components.cpp | |
parent | 1024fe8305e5b0a7bb1f660a1cee077172d84534 (diff) |
Some more anim
Diffstat (limited to 'src/components.cpp')
-rw-r--r-- | src/components.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
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<Position, Direction>([dt](entityx::Entity entity, Position &position, Direction &direction) { 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, @@ -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<Animate>()) { - sprite.sprite = entity.component<Animate>().get()->nextFrame(); - } for (auto &S : sprite.sprite) { float width = HLINES(S.first.size.x); @@ -265,7 +269,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(); } |