improv animation draw
This commit is contained in:
parent
1a080dbf15
commit
427dd91d79
|
@ -36,7 +36,6 @@ Creature::Creature() : Thing(Otc::Creature)
|
||||||
m_walking = false;
|
m_walking = false;
|
||||||
m_walkOffsetX = 0;
|
m_walkOffsetX = 0;
|
||||||
m_walkOffsetY = 0;
|
m_walkOffsetY = 0;
|
||||||
m_lastWalkAnim = 1;
|
|
||||||
|
|
||||||
m_informationFont = g_fonts.getFont("tibia-12px-rounded");
|
m_informationFont = g_fonts.getFont("tibia-12px-rounded");
|
||||||
}
|
}
|
||||||
|
@ -127,12 +126,11 @@ void Creature::draw(int x, int y)
|
||||||
|
|
||||||
int walkOffset = std::max(std::abs(m_walkOffsetX), std::abs(m_walkOffsetY));
|
int walkOffset = std::max(std::abs(m_walkOffsetX), std::abs(m_walkOffsetY));
|
||||||
if(walkOffset % (int)std::ceil(32 / (float)attributes.animationPhases) == 0) {
|
if(walkOffset % (int)std::ceil(32 / (float)attributes.animationPhases) == 0) {
|
||||||
if(m_lastWalkAnim+1 == attributes.animationPhases)
|
if((m_animation+1) % attributes.animationPhases == 0)
|
||||||
m_lastWalkAnim = 1;
|
m_animation = 1;
|
||||||
else
|
else
|
||||||
m_lastWalkAnim++;
|
m_animation++;
|
||||||
}
|
}
|
||||||
m_animation = m_lastWalkAnim;
|
|
||||||
|
|
||||||
if(((m_walkOffsetX == 0 && m_walkOffsetY == 0) && m_walkOffsetX != m_walkOffsetY) ||
|
if(((m_walkOffsetX == 0 && m_walkOffsetY == 0) && m_walkOffsetX != m_walkOffsetY) ||
|
||||||
((m_walkOffsetX == 0 || m_walkOffsetY == 0) && m_walkOffsetX == m_walkOffsetY)) {
|
((m_walkOffsetX == 0 || m_walkOffsetY == 0) && m_walkOffsetX == m_walkOffsetY)) {
|
||||||
|
|
|
@ -93,7 +93,6 @@ private:
|
||||||
Color m_informationColor;
|
Color m_informationColor;
|
||||||
|
|
||||||
int m_lastTicks;
|
int m_lastTicks;
|
||||||
int m_lastWalkAnim;
|
|
||||||
bool m_walking;
|
bool m_walking;
|
||||||
float m_walkTimePerPixel;
|
float m_walkTimePerPixel;
|
||||||
Position m_walkingFromPosition;
|
Position m_walkingFromPosition;
|
||||||
|
|
|
@ -38,11 +38,7 @@ void Item::draw(int x, int y)
|
||||||
|
|
||||||
if(attributes.animationPhases > 1) {
|
if(attributes.animationPhases > 1) {
|
||||||
if(g_platform.getTicks() - m_lastTicks > 500) {
|
if(g_platform.getTicks() - m_lastTicks > 500) {
|
||||||
if(m_animation+1 == attributes.animationPhases)
|
|
||||||
m_animation = 0;
|
|
||||||
else
|
|
||||||
m_animation++;
|
m_animation++;
|
||||||
|
|
||||||
m_lastTicks = g_platform.getTicks();
|
m_lastTicks = g_platform.getTicks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,26 +42,26 @@ void Thing::setPosition(const Position& position)
|
||||||
|
|
||||||
void Thing::internalDraw(int x, int y, int layers, Otc::SpriteMask mask)
|
void Thing::internalDraw(int x, int y, int layers, Otc::SpriteMask mask)
|
||||||
{
|
{
|
||||||
const ThingAttributes& attributes = getAttributes();
|
const ThingAttributes& type = getAttributes();
|
||||||
|
|
||||||
for(int yi = 0; yi < attributes.height; yi++) {
|
for(int yi = 0; yi < type.height; yi++) {
|
||||||
for(int xi = 0; xi < attributes.width; xi++) {
|
for(int xi = 0; xi < type.width; xi++) {
|
||||||
int sprIndex = xi +
|
int sprIndex = ((((((m_animation % type.animationPhases)
|
||||||
yi * attributes.width +
|
* type.zPattern + m_zPattern)
|
||||||
layers * attributes.width * attributes.height +
|
* type.yPattern + m_yPattern)
|
||||||
m_xPattern * attributes.width * attributes.height * attributes.layers +
|
* type.xPattern + m_xPattern)
|
||||||
m_yPattern * attributes.width * attributes.height * attributes.layers * attributes.xPattern +
|
* type.layers + layers)
|
||||||
m_zPattern * attributes.width * attributes.height * attributes.layers * attributes.xPattern * attributes.yPattern +
|
* type.height + yi)
|
||||||
m_animation * attributes.width * attributes.height * attributes.layers * attributes.xPattern * attributes.yPattern * attributes.zPattern;
|
* type.width + xi;
|
||||||
|
|
||||||
int spriteId = attributes.sprites[sprIndex];
|
int spriteId = type.sprites[sprIndex];
|
||||||
if(!spriteId)
|
if(!spriteId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
TexturePtr spriteTex = g_sprites.getSpriteTexture(spriteId, mask);
|
TexturePtr spriteTex = g_sprites.getSpriteTexture(spriteId, mask);
|
||||||
|
|
||||||
Rect drawRect((x - xi*32) - attributes.xDisplacment,
|
Rect drawRect((x - xi*32) - type.xDisplacment,
|
||||||
(y - yi*32) - attributes.yDisplacment,
|
(y - yi*32) - type.yDisplacment,
|
||||||
32, 32);
|
32, 32);
|
||||||
g_graphics.drawTexturedRect(drawRect, spriteTex);
|
g_graphics.drawTexturedRect(drawRect, spriteTex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue