#include "doorkeeper.hpp" #include "doorkeepertestConfig.h" #include "platform.h" #include "platformstrings.h" #include "helpers/asciimapsource.hpp" #include "mapreaders/mapstreamraw.hpp" #include #include #include #include template struct LayerWithData { std::unique_ptr> tilemap; std::unique_ptr device; dk::Layer* layer; std::string path; }; namespace { template void createLayer ( dk::Tyler<2>& parTiler, LayerWithData& parOut ); void printWelcome ( void ); void addLayer ( dk::Tyler<2>& parTiler, LayerWithData& parLayerInfo, const char* parPath ); void printViewport ( const dk::Viewport<2>& parView, const dk::Layer& parLayer ); } //unnamed namespace int main() { typedef dk::Tyler<2>::coords coords2; using dk::TileMapData; using dkh::AsciiMapSource; printWelcome(); dk::Tyler<2> tiler(coords2(10, 6), coords2(64)); LayerWithData bottomLayer; addLayer(tiler, bottomLayer, DATA_PATH"/test.map"); LayerWithData topLayer; addLayer(tiler, topLayer, DATA_PATH"/test_2.map"); printViewport(dk::Viewport<2>(tiler, coords2(10, 6), coords2(0)), *bottomLayer.layer); printViewport(dk::Viewport<2>(tiler, coords2(4, 4), coords2(0)), *bottomLayer.layer); #if !defined(NDEBUG) std::cout << "Map size: " << tiler.map_size() << '\n'; #endif std::cout << "Total tiles: " << tiler.tiles_count() << '\n'; return 0; } namespace { template void createLayer (dk::Tyler<2>& parTiler, LayerWithData& parOut) { } void printWelcome() { std::cout << "Welcome to " << APP_NAME << ' ' << DK_DEVICE_STRING << " version for " << DK_OS_STRING << ' ' << DK_ARCH_STRING << ' ' << DK_BIT_STRING; #if defined(DK_ARM) std::cout << ' ' << DK_ARM_FAMILY_STRING << ' ' << DK_ARM_ARCH_STRING; #endif std::cout << '\n'; } void addLayer (dk::Tyler<2>& parTiler, LayerWithData& parLayerInfo, const char* parPath) { parLayerInfo.path = parPath; parLayerInfo.device = std::unique_ptr(new dkh::AsciiMapSource(parLayerInfo.path)); std::unique_ptr> stream(new dk::MapStreamRaw(*parLayerInfo.device)); parLayerInfo.tilemap = std::unique_ptr>(new dk::TileMapData(std::move(stream))); parLayerInfo.layer = &parTiler.push_layer(*parLayerInfo.tilemap); } void printViewport (const dk::Viewport<2>& parView, const dk::Layer& parLayer) { int col = 0; const auto tilecount = parView.count(); for (auto itTile = parView.begin(parLayer), itTileEND = parView.end(parLayer); itTile != itTileEND; ++itTile) { std::cout << *itTile; ++col; if (col == tilecount.x()) { col = 0; std::cout << '\n'; } } } } //unnamed namespace