Effects now use x and y pattern, fixes #433

master
Sam 10 years ago
parent d7dfa2220e
commit cbfeef39bc

@ -24,7 +24,7 @@
#include "map.h" #include "map.h"
#include <framework/core/eventdispatcher.h> #include <framework/core/eventdispatcher.h>
void Effect::draw(const Point& dest, float scaleFactor, bool animate, LightView *lightView) void Effect::draw(const Point& dest, float scaleFactor, bool animate, int offsetX, int offsetY, LightView *lightView)
{ {
if(m_id == 0) if(m_id == 0)
return; return;
@ -32,7 +32,16 @@ void Effect::draw(const Point& dest, float scaleFactor, bool animate, LightView
int animationPhase = 0; int animationPhase = 0;
if(animate) if(animate)
animationPhase = std::min<int>((int)(m_animationTimer.ticksElapsed() / m_phaseDuration), getAnimationPhases() - 1); animationPhase = std::min<int>((int)(m_animationTimer.ticksElapsed() / m_phaseDuration), getAnimationPhases() - 1);
rawGetThingType()->draw(dest, scaleFactor, 0, 0, 0, 0, animationPhase, lightView);
int xPattern = offsetX % getNumPatternX();
if(xPattern < 0)
xPattern += getNumPatternX();
int yPattern = offsetY % getNumPatternY();
if(yPattern < 0)
yPattern += getNumPatternY();
rawGetThingType()->draw(dest, scaleFactor, 0, xPattern, yPattern, 0, animationPhase, lightView);
} }
void Effect::onAppear() void Effect::onAppear()

@ -35,7 +35,7 @@ class Effect : public Thing
}; };
public: public:
void draw(const Point& dest, float scaleFactor, bool animate, LightView *lightView = nullptr); void draw(const Point& dest, float scaleFactor, bool animate, int offsetX = 0, int offsetY = 0, LightView *lightView = nullptr);
void setId(uint32 id); void setId(uint32 id);
uint32 getId() { return m_id; } uint32 getId() { return m_id; }

@ -155,7 +155,7 @@ void Tile::draw(const Point& dest, float scaleFactor, int drawFlags, LightView *
// effects // effects
if(drawFlags & Otc::DrawEffects) if(drawFlags & Otc::DrawEffects)
for(const EffectPtr& effect : m_effects) for(const EffectPtr& effect : m_effects)
effect->draw(dest - m_drawElevation*scaleFactor, scaleFactor, animate, lightView); effect->draw(dest - m_drawElevation*scaleFactor, scaleFactor, animate, m_position.x - g_map.getCentralPosition().x, m_position.y - g_map.getCentralPosition().y, lightView);
// top items // top items
if(drawFlags & Otc::DrawOnTop) if(drawFlags & Otc::DrawOnTop)

Loading…
Cancel
Save