map tile render rework, not done yet

master
Henrique 13 years ago
parent 033f14780d
commit 9b112b1daf

@ -29,9 +29,9 @@ void Creature::draw(int x, int y)
outfitColorId = m_outfit.head;
else if(mask == SpriteMaskRed)
outfitColorId = m_outfit.body;
else if(mask == SpriteMaskBlue)
else if(mask == SpriteMaskGreen)
outfitColorId = m_outfit.legs;
else if(mask == SpriteMaskGreen)
else if(mask == SpriteMaskBlue)
outfitColorId = m_outfit.feet;
g_graphics.bindColor(OutfitColors[outfitColorId]);

@ -169,12 +169,13 @@ void DatManager::parseThingAttributesOpt(std::stringstream& fin, ThingAttributes
break;
case 0x18: // Thing must be drawed with offset
thingAttributes.hasHeight = true;
thingAttributes.xOffset = fw::getu8(fin);
thingAttributes.yOffset = fw::getu8(fin);
thingAttributes.drawOffset = fw::getu8(fin);
fw::getu8(fin);
fw::getu16(fin);
break;
case 0x19: // pixels characters height
fw::getu16(fin);
thingAttributes.drawNextOffset = fw::getu8(fin);
fw::getu8(fin);
break;
case 0x1A:
//thingAttributes.hasHeight = true;

@ -17,10 +17,25 @@ void Map::draw(int x, int y)
Position playerPos = g_game.getLocalPlayer()->getPosition();
// player is above 7
if(playerPos.z <= 7) {
// player pos it 8-6. check if we can draw upper floors.
int drawFloorStop = 0;
// if there is a window on north, east, south or west
//Position direction[4] = {Position(0, -1, 0), Position(1, 0, 0), Position(0, 1, 0), Position(-1, 0, 0)};
for(int d = 0; d < 4; ++d) {
/*if(const TilePtr& tile = m_tiles[playerPos+direction[d]]) {
const ThingAttributes& thingAttributes = thing->getAttributes();
if(thingAttributes.lookThrough) {
drawFloorStop = playerPos.z - 1;
break;
}
}*/
}
// if we have something covering us, dont show floors above.
for(int jz = 6; jz >= 0; --jz) {
Position coverPos = Position(playerPos.x+(7-jz)-1, playerPos.y+(7-jz)-1, jz);
if(const TilePtr& tile = m_tiles[coverPos]) {
@ -35,13 +50,17 @@ void Map::draw(int x, int y)
if(iz == drawFloorStop)
break;
// +1 in draws cause 64x64 items may affect view.
for(int step = 0; step < 4; ++step) {
// +1 in draws cause 64x64 items may affect view.
for(int ix = -7+(playerPos.z-iz); ix < + 8+7; ++ix) {
for(int iy = -5+(playerPos.z-iz); iy < + 6+7; ++iy) {
Position itemPos = Position(playerPos.x + ix, playerPos.y + iy, iz);
if(const TilePtr& tile = m_tiles[itemPos])
tile->draw((ix + 7 - (playerPos.z-iz))*32, (iy + 5 - (playerPos.z-iz))*32);
for(int ix = -7+(playerPos.z-iz); ix < + 8+7; ++ix) {
for(int iy = -5+(playerPos.z-iz); iy < + 6+7; ++iy) {
Position itemPos = Position(playerPos.x + ix, playerPos.y + iy, iz);
if(const TilePtr& tile = m_tiles[itemPos])
tile->draw((ix + 7 - (playerPos.z-iz))*32, (iy + 5 - (playerPos.z-iz))*32, step);
}
}
}
}

@ -26,8 +26,8 @@ void Thing::internalDraw(int x, int y, int blendframes, int xdiv, int ydiv, int
TexturePtr spriteTex = g_sprites.getSpriteTexture(spriteId, mask);
Rect drawRect((x - xi*32) - attributes.xOffset,
(y - yi*32) - attributes.xOffset,
Rect drawRect((x - xi*32) - attributes.drawOffset,
(y - yi*32) - attributes.drawOffset,
32, 32);
g_graphics.drawTexturedRect(drawRect, spriteTex);
}

@ -37,13 +37,13 @@ struct ThingAttributes
ydiv = 0;
zdiv = 0;
animcount = 0;
xOffset = 0;
yOffset = 0;
drawOffset = 0;
drawNextOffset = 0;
}
bool stackable, alwaysOnTop, useable, readable, moveable, blockSolid, blockProjectile, blockPathFind, pickupable,
isHangable, isHorizontal, isVertical, rotable, hasHeight, lookThrough, hasMiniMapColor;
uint8 alwaysOnTopOrder, width, height, blendframes, xdiv, ydiv, zdiv, animcount, xOffset, yOffset;
uint8 alwaysOnTopOrder, width, height, blendframes, xdiv, ydiv, zdiv, animcount, drawOffset, drawNextOffset;
uint16 speed, subParam07, subParam08, lightLevel, lightColor, miniMapColor;
std::vector<int> sprites;

@ -2,28 +2,97 @@
#include "item.h"
#include "datmanager.h"
#include "map.h"
#include "game.h"
#include "localplayer.h"
#include <framework/graphics/fontmanager.h>
Tile::Tile()
{
m_drawNextOffset = 0;
}
void Tile::draw(int x, int y)
void Tile::draw(int x, int y, int step)
{
if(m_ground)
m_ground->draw(x, y);
// STEP 0 = draw ground, top 1
// STEP 1 = top 2
// STEP 2 = top 3
// STEP 3 = bottom, creatures, names, etc
FontPtr font = g_fonts.getDefaultFont();
if(step == 0 && m_drawNextOffset != 0) {
logDebug("error with tile offset.");
return;
}
for(const ThingPtr& thing : m_itemsTop)
thing->draw(x, y);
if(step == 0) {
if(m_ground)
m_ground->draw(x, y);
for(const ThingPtr& thing : m_itemsBottom)
thing->draw(x, y);
for(const ThingPtr& thing : m_itemsTop) {
const ThingAttributes& thingAttributes = thing->getAttributes();
for(const ThingPtr& thing : m_creatures)
thing->draw(x, y);
if(thingAttributes.alwaysOnTopOrder == 1) {
thing->draw(x - m_drawNextOffset, y - m_drawNextOffset);
//font->renderText("T1", Rect(x + 5, y+5, 100, 100));
for(const ThingPtr& thing : m_effects)
thing->draw(x, y);
m_drawNextOffset += thingAttributes.drawNextOffset;
}
}
for(const ThingPtr& thing : m_itemsTop) {
const ThingAttributes& thingAttributes = thing->getAttributes();
if(thingAttributes.alwaysOnTopOrder == 2) {
thing->draw(x - m_drawNextOffset, y - m_drawNextOffset);
//font->renderText("T2", Rect(x + 5, y+5, 100, 100));
m_drawNextOffset += thingAttributes.drawNextOffset;
}
}
for(const ThingPtr& thing : m_itemsBottom) {
const ThingAttributes& thingAttributes = thing->getAttributes();
thing->draw(x - m_drawNextOffset, y - m_drawNextOffset);
//font->renderText("B0", Rect(x + 5, y+5, 100, 100));
m_drawNextOffset += thingAttributes.drawNextOffset;
}
for(const ThingPtr& thing : m_creatures) {
const ThingAttributes& thingAttributes = thing->getAttributes();
thing->draw(x - m_drawNextOffset, y - m_drawNextOffset);
m_drawNextOffset += thingAttributes.drawNextOffset;
}
for(const ThingPtr& thing : m_itemsTop) {
const ThingAttributes& thingAttributes = thing->getAttributes();
if(thingAttributes.alwaysOnTopOrder == 3) {
thing->draw(x - m_drawNextOffset, y - m_drawNextOffset);
//font->renderText("T3", Rect(x + 5, y+5, 100, 100));
m_drawNextOffset += thingAttributes.drawNextOffset;
}
}
for(const ThingPtr& thing : m_effects) {
thing->draw(x - m_drawNextOffset, y - m_drawNextOffset);
}
m_drawNextOffset = 0;
}
else if(step == 1) {
}
else if(step == 2) {
}
else if(step == 3) {
}
}
void Tile::addThing(ThingPtr thing, uint8 stackpos)
@ -31,6 +100,22 @@ void Tile::addThing(ThingPtr thing, uint8 stackpos)
if(!thing)
return;
//8308
//2526
//5296
const ThingAttributes& item1 = g_dat.getItemAttributes(8308);
const ThingAttributes& item2 = g_dat.getItemAttributes(2526);
const ThingAttributes& item3 = g_dat.getItemAttributes(5296);
int j = item1.alwaysOnTopOrder + item2.alwaysOnTopOrder + item3.alwaysOnTopOrder;
j++;
if(thing->getPosition() == g_game.getLocalPlayer()->getPosition() + Position(-1, 0, 0) && thing->getAttributes().alwaysOnTop) {
logDebug((int)thing->getId());
}
const ThingAttributes& thingAttributes = thing->getAttributes();
if(thing->asItem()) {
@ -38,16 +123,16 @@ void Tile::addThing(ThingPtr thing, uint8 stackpos)
m_ground = thing;
else {
if(thingAttributes.alwaysOnTop)
m_itemsTop.push_back(thing);
m_itemsTop.push_front(thing);
else
m_itemsBottom.push_back(thing);
m_itemsBottom.push_front(thing);
}
}
else if(thing->asCreature()) {
m_creatures.push_back(thing);
m_creatures.push_front(thing);
}
else if(thing->asEffect()) {
m_effects.push_back(thing);
m_effects.push_front(thing);
}
}

@ -4,12 +4,17 @@
#include "declarations.h"
#include <framework/luascript/luaobject.h>
enum RenderStep
{
};
class Tile : public LuaObject
{
public:
Tile();
void draw(int x, int y);
void draw(int x, int y, int step);
void addThing(ThingPtr thing, uint8 stackpos);
ThingPtr getThing(uint8 stackpos);
@ -28,6 +33,8 @@ private:
std::deque<ThingPtr> m_creatures;
std::deque<ThingPtr> m_itemsTop;
std::deque<ThingPtr> m_effects;
int m_drawNextOffset;
};
#endif

Loading…
Cancel
Save