81 lines
2.6 KiB
C++
81 lines
2.6 KiB
C++
/* Copyright 2015, Michele Santullo
|
|
* This file is part of DoorKeeper.
|
|
*
|
|
* DoorKeeper is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* DoorKeeper is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with DoorKeeper. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
namespace dk {
|
|
template <CoordinateScalarType DivX, CoordinateScalarType DivY>
|
|
PixelConvDiamond<DivX, DivY>::PixelConvDiamond (const coords& parTileSize, bool parStaggered, bool parFirstReentrant) :
|
|
base_class(parStaggered ? MapType_IsometricStaggered : MapType_Isometric, parTileSize),
|
|
m_first_reentr(parFirstReentrant ? 1 : 0),
|
|
m_staggered(parStaggered)
|
|
{
|
|
}
|
|
|
|
template <CoordinateScalarType DivX, CoordinateScalarType DivY>
|
|
auto PixelConvDiamond<DivX, DivY>::to_pixel (const coords& parFrom) const -> coords {
|
|
if (m_staggered) {
|
|
const auto from(parFrom);
|
|
const CoordinateScalarType xoffs = m_first_reentr xor (from.y() bitand 1);
|
|
const auto& tile_size = this->tile_size();
|
|
|
|
const auto retval(from * tile_size + coords(xoffs * tile_size.x() / 2, 0));
|
|
return coords(retval.x() / DivX, retval.y() / DivY);
|
|
}
|
|
else {
|
|
DK_ASSERT(false); //not implemented
|
|
return coords(0);
|
|
}
|
|
}
|
|
|
|
template <CoordinateScalarType DivX, CoordinateScalarType DivY>
|
|
auto PixelConvDiamond<DivX, DivY>::pick_tile (const coords& parPixelPoint) const -> coords {
|
|
DK_ASSERT(false); //not implemented
|
|
return coords(0);
|
|
}
|
|
|
|
template <uint32_t D>
|
|
PixelConv<D>::PixelConv (MapTypes parType, const coords& parTileSize) :
|
|
m_tile_size(parTileSize),
|
|
m_map_type(parType)
|
|
{
|
|
}
|
|
|
|
template <uint32_t D>
|
|
MapTypes PixelConv<D>::map_type() const {
|
|
return m_map_type;
|
|
}
|
|
|
|
template <uint32_t D>
|
|
auto PixelConv<D>::tile_size() const -> const coords& {
|
|
return m_tile_size;
|
|
}
|
|
|
|
template <uint32_t D>
|
|
PixelConvSquare<D>::PixelConvSquare (const coords& parTileSize) :
|
|
base_class(MapType_Orthogonal, parTileSize)
|
|
{
|
|
}
|
|
|
|
template <uint32_t D>
|
|
auto PixelConvSquare<D>::to_pixel (const coords& parFrom) const -> coords {
|
|
return parFrom * this->tile_size();
|
|
}
|
|
|
|
template <uint32_t D>
|
|
auto PixelConvSquare<D>::pick_tile (const coords& parPixelPoint) const -> coords {
|
|
return parPixelPoint / this->tile_size();
|
|
}
|
|
} //namespace dk
|