improve walk animation on low end hardware
This commit is contained in:
parent
8cef6463b3
commit
72f569c250
|
@ -54,6 +54,7 @@ Creature::Creature() : Thing()
|
||||||
m_emblem = Otc::EmblemNone;
|
m_emblem = Otc::EmblemNone;
|
||||||
m_nameCache.setFont(g_fonts.getFont("verdana-11px-rounded"));
|
m_nameCache.setFont(g_fonts.getFont("verdana-11px-rounded"));
|
||||||
m_nameCache.setAlign(Fw::AlignTopCenter);
|
m_nameCache.setAlign(Fw::AlignTopCenter);
|
||||||
|
m_footStep = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -82,6 +83,7 @@ void Creature::draw(const Point& dest, float scaleFactor, bool animate)
|
||||||
}
|
}
|
||||||
|
|
||||||
internalDrawOutfit(dest + animationOffset * scaleFactor, scaleFactor, animate, animate, m_direction);
|
internalDrawOutfit(dest + animationOffset * scaleFactor, scaleFactor, animate, animate, m_direction);
|
||||||
|
m_footStepDrawn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::internalDrawOutfit(const Point& dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction)
|
void Creature::internalDrawOutfit(const Point& dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction)
|
||||||
|
@ -304,10 +306,15 @@ void Creature::updateWalkAnimation(int totalPixelsWalked)
|
||||||
if(m_outfit.getCategory() != ThingsType::Creature)
|
if(m_outfit.getCategory() != ThingsType::Creature)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(totalPixelsWalked == 32 || totalPixelsWalked == 0 || getAnimationPhases() <= 1)
|
int footAnimPhases = getAnimationPhases() - 1;
|
||||||
|
if(totalPixelsWalked == 32 || footAnimPhases == 0)
|
||||||
m_walkAnimationPhase = 0;
|
m_walkAnimationPhase = 0;
|
||||||
else if(getAnimationPhases() > 1)
|
else if(m_footStepDrawn && m_footTimer.ticksElapsed() >= m_walkAnimationInterval / 4 ) {
|
||||||
m_walkAnimationPhase = 1 + ((totalPixelsWalked * 4) / Otc::TILE_PIXELS) % (getAnimationPhases() - 1);
|
m_footStep++;
|
||||||
|
m_walkAnimationPhase = 1 + (m_footStep % footAnimPhases);
|
||||||
|
m_footStepDrawn = false;
|
||||||
|
m_footTimer.restart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::updateWalkOffset(int totalPixelsWalked)
|
void Creature::updateWalkOffset(int totalPixelsWalked)
|
||||||
|
|
|
@ -129,11 +129,14 @@ protected:
|
||||||
|
|
||||||
// walk related
|
// walk related
|
||||||
int m_walkAnimationPhase;
|
int m_walkAnimationPhase;
|
||||||
|
int m_footStep;
|
||||||
Timer m_walkTimer;
|
Timer m_walkTimer;
|
||||||
|
Timer m_footTimer;
|
||||||
TilePtr m_walkingTile;
|
TilePtr m_walkingTile;
|
||||||
int m_walkInterval;
|
int m_walkInterval;
|
||||||
int m_walkAnimationInterval;
|
int m_walkAnimationInterval;
|
||||||
Boolean<false> m_walking;
|
Boolean<false> m_walking;
|
||||||
|
Boolean<false> m_footStepDrawn;
|
||||||
ScheduledEventPtr m_walkUpdateEvent;
|
ScheduledEventPtr m_walkUpdateEvent;
|
||||||
Point m_walkOffset;
|
Point m_walkOffset;
|
||||||
Otc::Direction m_walkTurnDirection;
|
Otc::Direction m_walkTurnDirection;
|
||||||
|
|
Loading…
Reference in New Issue