walk displacment
This commit is contained in:
parent
361b28c6d6
commit
3a4bd50665
|
@ -41,8 +41,7 @@ void Effect::draw(int x, int y)
|
||||||
if(m_animation+1 == type.animationPhases) {
|
if(m_animation+1 == type.animationPhases) {
|
||||||
EffectPtr self = asEffect();
|
EffectPtr self = asEffect();
|
||||||
g_dispatcher.addEvent([self] {
|
g_dispatcher.addEvent([self] {
|
||||||
TilePtr tile = g_map.getTile(self->getPosition());
|
g_map.getTile(self->getPosition())->removeEffect(self);
|
||||||
tile->removeEffect(self);
|
|
||||||
});
|
});
|
||||||
m_finished = true;
|
m_finished = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ void Map::draw(const Rect& rect)
|
||||||
float verticalStretchFactor = rect.height() / (float)(MAP_VISIBLE_HEIGHT * NUM_TILE_PIXELS);
|
float verticalStretchFactor = rect.height() / (float)(MAP_VISIBLE_HEIGHT * NUM_TILE_PIXELS);
|
||||||
|
|
||||||
// draw player names and health bars
|
// draw player names and health bars
|
||||||
|
//TODO: this could be cached to improve framerate
|
||||||
for(int x = 0; x < MAP_VISIBLE_WIDTH; ++x) {
|
for(int x = 0; x < MAP_VISIBLE_WIDTH; ++x) {
|
||||||
for(int y = 0; y < MAP_VISIBLE_HEIGHT; ++y) {
|
for(int y = 0; y < MAP_VISIBLE_HEIGHT; ++y) {
|
||||||
Position tilePos = Position(m_centralPosition.x + (x - PLAYER_OFFSET_X + 1), m_centralPosition.y + (y - PLAYER_OFFSET_Y + 1), m_centralPosition.z);
|
Position tilePos = Position(m_centralPosition.x + (x - PLAYER_OFFSET_X + 1), m_centralPosition.y + (y - PLAYER_OFFSET_Y + 1), m_centralPosition.z);
|
||||||
|
|
|
@ -63,10 +63,12 @@ void Tile::draw(int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can render creatures in 3x3 range
|
// we can render creatures in 3x3 range
|
||||||
|
//TODO: this algorithm is slowing down render too much, but it could be cached to improve framerate
|
||||||
for(int xi = -1; xi <= 1; ++xi) {
|
for(int xi = -1; xi <= 1; ++xi) {
|
||||||
for(int yi = -1; yi <= 1; ++yi) {
|
for(int yi = -1; yi <= 1; ++yi) {
|
||||||
for(CreaturePtr creature : g_map.getTile(m_position + Position(xi, yi, 0))->getCreatures()) {
|
for(CreaturePtr creature : g_map.getTile(m_position + Position(xi, yi, 0))->getCreatures()) {
|
||||||
Rect creatureRect(x + xi*32 + creature->getWalkOffsetX(), y + yi*32 + creature->getWalkOffsetY(), 24, 24);
|
auto& type = creature->getType();
|
||||||
|
Rect creatureRect(x + xi*32 + creature->getWalkOffsetX() - type.xDisplacment, y + yi*32 + creature->getWalkOffsetY() - type.yDisplacment, 32, 32);
|
||||||
Rect thisTileRect(x, y, 32, 32);
|
Rect thisTileRect(x, y, 32, 32);
|
||||||
|
|
||||||
// only render creatures where bottom right is inside our rect
|
// only render creatures where bottom right is inside our rect
|
||||||
|
|
|
@ -35,7 +35,7 @@ void ProtocolGame::parseMessage(InputMessage& msg)
|
||||||
{
|
{
|
||||||
while(!msg.eof()) {
|
while(!msg.eof()) {
|
||||||
uint8 opt = msg.getU8();
|
uint8 opt = msg.getU8();
|
||||||
//dump << "protocol id:" << std::hex << (int)opt;
|
//dump << "protocol id:" << (int)opt;
|
||||||
|
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case Otc::GameServerInitGame:
|
case Otc::GameServerInitGame:
|
||||||
|
@ -663,8 +663,8 @@ void ProtocolGame::parsePlayerCancelAttack(InputMessage& msg)
|
||||||
void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
|
void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
|
||||||
{
|
{
|
||||||
msg.getU32(); // unkSpeak
|
msg.getU32(); // unkSpeak
|
||||||
msg.getString(); // name
|
std::string name = msg.getString(); // name
|
||||||
msg.getU16(); // level
|
uint16 level = msg.getU16(); // level
|
||||||
uint8 type = msg.getU8();
|
uint8 type = msg.getU8();
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
|
@ -692,7 +692,8 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.getString(); // message
|
std::string message = msg.getString(); // message
|
||||||
|
logDebug(name, "[", level, "]: ", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseChannelList(InputMessage& msg)
|
void ProtocolGame::parseChannelList(InputMessage& msg)
|
||||||
|
|
Loading…
Reference in New Issue