tibia-client/src/otclient/core/thing.cpp

36 lines
1.4 KiB
C++
Raw Normal View History

2011-08-15 16:11:24 +02:00
#include "thing.h"
2011-08-15 21:15:49 +02:00
#include "spritemanager.h"
2011-08-15 16:11:24 +02:00
#include <framework/graphics/graphics.h>
2011-08-16 02:30:31 +02:00
Thing::Thing(ThingType type) : m_id(0), m_type(type)
{
}
2011-08-15 16:11:24 +02:00
void Thing::internalDraw(int x, int y, int blendframes, int xdiv, int ydiv, int zdiv, int anim)
{
2011-08-15 21:15:49 +02:00
const ThingAttributes& attributes = getAttributes();
for(int yi = 0; yi < attributes.height; yi++) {
for(int xi = 0; xi < attributes.width; xi++) {
int sprIndex = xi +
yi * attributes.width +
blendframes * attributes.width * attributes.height +
xdiv * attributes.width * attributes.height * attributes.blendframes +
ydiv * attributes.width * attributes.height * attributes.blendframes * attributes.xdiv +
zdiv * attributes.width * attributes.height * attributes.blendframes * attributes.xdiv * attributes.ydiv +
anim * attributes.width * attributes.height * attributes.blendframes * attributes.xdiv * attributes.ydiv * attributes.zdiv;
int spriteId = attributes.sprites[sprIndex];
if(!spriteId)
continue;
2011-08-15 16:11:24 +02:00
2011-08-15 21:15:49 +02:00
TexturePtr spriteTex = g_sprites.getSpriteTexture(spriteId);
2011-08-15 23:02:52 +02:00
Rect drawRect((x - xi*32) - attributes.xOffset,
(y - yi*32) - attributes.yOffset,
32, 32);
2011-08-15 16:11:24 +02:00
2011-08-15 23:02:52 +02:00
g_graphics.drawTexturedRect(drawRect, spriteTex);
2011-08-15 16:11:24 +02:00
}
}
}