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>
|
|
|
|
|
|
|
|
ThingAttributes::ThingAttributes()
|
|
|
|
{
|
|
|
|
group = THING_GROUP_NONE;
|
|
|
|
blockSolid = false;
|
|
|
|
hasHeight = false;
|
|
|
|
blockPathFind = false;
|
|
|
|
blockProjectile = false;
|
|
|
|
alwaysOnTop = false;
|
|
|
|
alwaysOnTopOrder = 0;
|
|
|
|
stackable = false;
|
|
|
|
useable = false;
|
|
|
|
moveable = true;
|
|
|
|
pickupable = false;
|
|
|
|
rotable = false;
|
|
|
|
readable = false;
|
|
|
|
lookThrough = false;
|
|
|
|
speed = 0;
|
|
|
|
lightLevel = 0;
|
|
|
|
lightColor = 0;
|
|
|
|
isVertical = false;
|
|
|
|
isHorizontal = false;
|
|
|
|
isHangable = false;
|
|
|
|
miniMapColor = 0;
|
|
|
|
hasMiniMapColor = false;
|
|
|
|
subParam07 = 0;
|
|
|
|
subParam08 = 0;
|
|
|
|
width = 0;
|
|
|
|
height = 0;
|
|
|
|
blendframes = 0;
|
|
|
|
xdiv = 0;
|
|
|
|
ydiv = 0;
|
|
|
|
zdiv = 0;
|
|
|
|
animcount = 0;
|
|
|
|
xOffset = 0;
|
|
|
|
yOffset = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Thing::Thing()
|
|
|
|
{
|
|
|
|
m_type = TYPE_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
if(spriteTex->isEmpty())
|
2011-08-15 16:11:24 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
int offsetX = 0, offsetY = 0;
|
2011-08-15 21:15:49 +02:00
|
|
|
if(attributes.hasHeight) {
|
|
|
|
offsetX = attributes.xOffset;
|
|
|
|
offsetY = attributes.xOffset; // << look to xoffset
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
|
|
|
|
2011-08-15 21:15:49 +02:00
|
|
|
g_graphics.drawTexturedRect(Rect((x - xi*32) - offsetX, (y - yi*32) - offsetY, 32, 32), spriteTex, Rect(0, 0, 32, 32));
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|