/* 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 . */ #include "doorkeeper/components/pixelconv.hpp" namespace dk { PixelConvDiamond::PixelConvDiamond (const coords& parTileSize, bool parStaggered, bool parFirstReentrant) : base_class(parStaggered ? MapType_IsometricStaggered : MapType_Isometric, parTileSize), m_ratio(1), m_first_reentr(parFirstReentrant ? 1 : 0), m_staggered(parStaggered) { } PixelConvDiamond::PixelConvDiamond (const coords& parTileSize, bool parStaggered, bool parFirstReentrant, const coords& parRatio) : base_class(MapType_IsometricStaggered, parTileSize), m_ratio(parRatio), m_first_reentr(parFirstReentrant ? 1 : 0), m_staggered(parStaggered) { DK_ASSERT(parRatio > 0); } auto PixelConvDiamond::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(); return (from * tile_size + coords(xoffs * tile_size.x() / 2, 0)) / m_ratio; } else { DK_ASSERT(false); //not implemented return coords(0); } } auto PixelConvDiamond::pick_tile (const coords& parPixelPoint) const -> coords { DK_ASSERT(false); //not implemented return coords(0); } PixelConvHex::PixelConvHex (const coords& parTileSize, bool parFirstReentrant) : base_class(MapType_Hex, parTileSize), m_first_reentr(parFirstReentrant ? 1 : 0) { } auto PixelConvHex::to_pixel (const coords& parFrom) const -> coords { DK_ASSERT(false); //not implemented return coords(0); } auto PixelConvHex::pick_tile (const coords& parPixelPoint) const -> coords { DK_ASSERT(false); //not implemented return coords(0); } } //namespace dk