Adding the concept of layers.
Deferring the data loading task to lower level classes. test_tiler removed as Tyler won't require the user to derive from it anymore.
This commit is contained in:
parent
369caf503d
commit
1e5f4fd2f0
9 changed files with 115 additions and 69 deletions
17
src/main.cpp
17
src/main.cpp
|
@ -1,9 +1,20 @@
|
|||
#include <iostream>
|
||||
#include "test/test_tiler.hpp"
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include "doorkeeper.hpp"
|
||||
|
||||
int main() {
|
||||
TestTiler simpleMap(TestTiler::coords(200, 150), "test.map");
|
||||
typedef dk::Tyler<2> Tiler;
|
||||
|
||||
std::cout << "Total tiles: " << simpleMap.tiles_count() << "\n";
|
||||
Tiler tiler(Tiler::coords(200, 150));
|
||||
|
||||
tiler.push_layer<int>(
|
||||
dk::Layer<int, 2>::streamer_type(std::unique_ptr<std::ifstream>(new std::ifstream("test.map")))
|
||||
);
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
std::cout << "Map size: " << tiler.map_size() << '\n';
|
||||
#endif
|
||||
std::cout << "Total tiles: " << tiler.tiles_count() << '\n';
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "test/test_tiler.hpp"
|
||||
|
||||
typedef dk::TileStreamer<int, 2> TileStreamerType;
|
||||
|
||||
///----------------------------------------------------------------------------
|
||||
///----------------------------------------------------------------------------
|
||||
TestTiler::TestTiler (const coords& parSize, const std::string&& parPath) :
|
||||
parent_type(parSize, TileStreamerType(TileStreamerType::StreamPtr(new std::ifstream(parPath))))
|
||||
{
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------
|
||||
///----------------------------------------------------------------------------
|
||||
bool TestTiler::batch_load (const std::vector<int>& parLoad) {
|
||||
std::cout << "Would batch-load " << parLoad.size() << " elements\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------
|
||||
///----------------------------------------------------------------------------
|
||||
bool TestTiler::single_load (const int&) {
|
||||
std::cout << "Would load 1 element\n";
|
||||
return true;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef idDD0A66B75FF546FCAF01C65E980DF224
|
||||
#define idDD0A66B75FF546FCAF01C65E980DF224
|
||||
|
||||
#include "doorkeeper.hpp"
|
||||
|
||||
class TestTiler : public dk::Tyler<int, 2> {
|
||||
typedef dk::Tyler<int, 2> parent_type;
|
||||
public:
|
||||
typedef parent_type::coords coords;
|
||||
|
||||
TestTiler ( const coords& parSize, const std::string&& parPath );
|
||||
|
||||
virtual ~TestTiler ( void ) noexcept = default;
|
||||
|
||||
virtual bool batch_load ( const std::vector<int>& parLoad );
|
||||
virtual bool single_load ( const int& parLoad );
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue