From: Clyne Sullivan Date: Thu, 1 Dec 2016 02:37:01 +0000 (-0500) Subject: fixed coalesce X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=e472a62b750e57724a26d299bb682b4f39405d05;p=clyne%2Fgamedev.git fixed coalesce --- e472a62b750e57724a26d299bb682b4f39405d05 diff --cc include/common.hpp index 7b98ea9,249b9eb..3caa083 --- a/include/common.hpp +++ b/include/common.hpp @@@ -58,11 -58,11 +58,7 @@@ typedef unsigned int uint #define BREAKPOINT __asm__("int $3") --template - inline const T * const& coalesce(const void * &p1, const void * &p2) -inline const T * const& coalesce(const T * const &p1, const T * const &p2) --{ - return ((p1 == nullptr) ? reinterpret_cast(p2) : p1); - return ((p1 == nullptr) ? p2 : p1); --} ++#define coalesce(v1, v2) ((v1 != nullptr) ? v1 : v2) /** * Creates a coordinate of integers. diff --cc src/components.cpp index a398bec,b74555c..612e522 --- a/src/components.cpp +++ b/src/components.cpp @@@ -18,7 -18,14 +18,14 @@@ void MovementSystem::update(entityx::En 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) { ++ 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 { @@@ -89,11 -97,7 +97,10 @@@ void RenderSystem::update(entityx::Enti 0.0, 1.0, 1.0, 1.0, 1.0, 0.0}; - + - if (entity.has_component()) { - sprite.sprite = entity.component().get()->nextFrame(); - } ++ if (entity.has_component()) ++ sprite.sprite = entity.component()->nextFrame(); + for (auto &S : sprite.sprite) { float width = HLINES(S.first.size.x); float height = HLINES(S.first.size.y);