improv animation draw

master
Eduardo Bart 13 years ago
parent 1a080dbf15
commit 427dd91d79

@ -36,7 +36,6 @@ Creature::Creature() : Thing(Otc::Creature)
m_walking = false;
m_walkOffsetX = 0;
m_walkOffsetY = 0;
m_lastWalkAnim = 1;
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));
if(walkOffset % (int)std::ceil(32 / (float)attributes.animationPhases) == 0) {
if(m_lastWalkAnim+1 == attributes.animationPhases)
m_lastWalkAnim = 1;
if((m_animation+1) % attributes.animationPhases == 0)
m_animation = 1;
else
m_lastWalkAnim++;
m_animation++;
}
m_animation = m_lastWalkAnim;
if(((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;
int m_lastTicks;
int m_lastWalkAnim;
bool m_walking;
float m_walkTimePerPixel;
Position m_walkingFromPosition;

@ -38,11 +38,7 @@ void Item::draw(int x, int y)
if(attributes.animationPhases > 1) {
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();
}
}

@ -42,26 +42,26 @@ void Thing::setPosition(const Position& position)
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 xi = 0; xi < attributes.width; xi++) {
int sprIndex = xi +
yi * attributes.width +
layers * attributes.width * attributes.height +
m_xPattern * attributes.width * attributes.height * attributes.layers +
m_yPattern * attributes.width * attributes.height * attributes.layers * attributes.xPattern +
m_zPattern * attributes.width * attributes.height * attributes.layers * attributes.xPattern * attributes.yPattern +
m_animation * attributes.width * attributes.height * attributes.layers * attributes.xPattern * attributes.yPattern * attributes.zPattern;
for(int yi = 0; yi < type.height; yi++) {
for(int xi = 0; xi < type.width; xi++) {
int sprIndex = ((((((m_animation % type.animationPhases)
* type.zPattern + m_zPattern)
* type.yPattern + m_yPattern)
* type.xPattern + m_xPattern)
* type.layers + layers)
* type.height + yi)
* type.width + xi;
int spriteId = attributes.sprites[sprIndex];
int spriteId = type.sprites[sprIndex];
if(!spriteId)
continue;
TexturePtr spriteTex = g_sprites.getSpriteTexture(spriteId, mask);
Rect drawRect((x - xi*32) - attributes.xDisplacment,
(y - yi*32) - attributes.yDisplacment,
Rect drawRect((x - xi*32) - type.xDisplacment,
(y - yi*32) - type.yDisplacment,
32, 32);
g_graphics.drawTexturedRect(drawRect, spriteTex);
}

Loading…
Cancel
Save