2015-08-17 17:36:45 +02:00
|
|
|
#include "doorkeeper/components/pixelconv.hpp"
|
|
|
|
|
|
|
|
namespace dk {
|
2015-08-18 00:00:59 +02:00
|
|
|
PixelConvDiamond::PixelConvDiamond (const coords& parTileSize, bool parStaggered, bool parFirstReentrant) :
|
|
|
|
base_class(parStaggered ? MapType_IsometricStaggered : MapType_Isometric, parTileSize),
|
2015-08-17 23:14:08 +02:00
|
|
|
m_ratio(1),
|
|
|
|
m_first_reentr(parFirstReentrant ? 1 : 0),
|
|
|
|
m_staggered(parStaggered)
|
2015-08-17 17:36:45 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-08-18 00:00:59 +02:00
|
|
|
PixelConvDiamond::PixelConvDiamond (const coords& parTileSize, bool parStaggered, bool parFirstReentrant, const coords& parRatio) :
|
|
|
|
base_class(MapType_IsometricStaggered, parTileSize),
|
2015-08-17 23:14:08 +02:00
|
|
|
m_ratio(parRatio),
|
|
|
|
m_first_reentr(parFirstReentrant ? 1 : 0),
|
|
|
|
m_staggered(parStaggered)
|
2015-08-17 17:36:45 +02:00
|
|
|
{
|
2015-08-17 23:14:08 +02:00
|
|
|
DK_ASSERT(parRatio > 0);
|
2015-08-17 17:36:45 +02:00
|
|
|
}
|
|
|
|
|
2015-08-18 00:00:59 +02:00
|
|
|
auto PixelConvDiamond::to_pixel (const coords& parFrom) const -> coords {
|
2015-08-17 23:14:08 +02:00
|
|
|
if (m_staggered) {
|
|
|
|
const auto from(parFrom);
|
|
|
|
const CoordinateScalarType xoffs = m_first_reentr xor (from.y() bitand 1);
|
2015-08-18 00:00:59 +02:00
|
|
|
const auto& tile_size = this->tile_size();
|
2015-08-17 23:14:08 +02:00
|
|
|
|
2015-08-18 00:00:59 +02:00
|
|
|
return (from * tile_size + coords(xoffs * tile_size.x() / 2, 0)) / m_ratio;
|
2015-08-17 23:14:08 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
DK_ASSERT(false); //not implemented
|
|
|
|
return coords(0);
|
|
|
|
}
|
2015-08-17 17:36:45 +02:00
|
|
|
}
|
|
|
|
|
2015-08-18 00:00:59 +02:00
|
|
|
PixelConvHex::PixelConvHex (const coords& parTileSize, bool parFirstReentrant) :
|
|
|
|
base_class(MapType_Hex, parTileSize)
|
2015-08-17 17:36:45 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-08-18 00:00:59 +02:00
|
|
|
auto PixelConvHex::to_pixel (const coords& parFrom) const -> coords {
|
2015-08-17 17:36:45 +02:00
|
|
|
DK_ASSERT(false); //not implemented
|
|
|
|
return coords(0);
|
|
|
|
}
|
|
|
|
} //namespace dk
|