tibia-client/src/map.cpp

42 lines
1.3 KiB
C++
Raw Normal View History

2011-08-11 07:52:30 +02:00
#include "map.h"
#include "game.h"
2011-08-12 04:04:28 +02:00
#include <graphics/graphics.h>
2011-08-11 07:52:30 +02:00
2011-08-12 02:06:01 +02:00
void Map::draw(int x, int y)
2011-08-11 07:52:30 +02:00
{
2011-08-12 03:38:54 +02:00
if(!m_framebuffer)
m_framebuffer = FrameBufferPtr(new FrameBuffer(19*32, 15*32));
m_framebuffer->bind();
2011-08-11 07:52:30 +02:00
Position playerPos = g_game.getPlayer()->getPosition();
for(int ix = 0; ix < 19; ++ix) {
for(int iy = 0; iy < 15; ++iy) {
if(playerPos.getZ() >= 7) {
for(int iz = 7; iz > 0; --iz) {
2011-08-12 02:06:01 +02:00
m_map[ix][iy][iz].draw(x+ix, y+iy, iz);
2011-08-11 07:52:30 +02:00
}
}
}
}
2011-08-12 03:38:54 +02:00
m_framebuffer->unbind();
2011-08-12 04:04:28 +02:00
m_framebuffer->draw(0, 0, g_graphics.getScreenSize().width(), g_graphics.getScreenSize().height());
2011-08-11 07:52:30 +02:00
}
void Map::addThing(Thing *thing, const Position& pos)
{
Position playerPos = g_game.getPlayer()->getPosition();
Position relativePos = Position(pos.getX() - playerPos.getX() + 8, pos.getY() - playerPos.getY() + 6, pos.getZ());
if(relativePos.getX() >= 18)
logDebug("relativePos is invalid.");
if(relativePos.getY() >= 14)
logDebug("relativePos is invalid.");
if(relativePos.getZ() >= 15)
logDebug("relativePos is invalid.");
2011-08-12 02:06:01 +02:00
//logDebug("x: ", (int)relativePos.getX(), " y: ", (int)relativePos.getY(), " z: ", (int)relativePos.getZ());
2011-08-11 07:52:30 +02:00
m_map[relativePos.getX()][relativePos.getY()][relativePos.getZ()].addThing(thing);
}