added basic mappers
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
|
||||
namespace UwU {
|
||||
template <class MapperT>
|
||||
class MapperBase {
|
||||
public:
|
||||
Coord2 map(uint16_t x, uint16_t y) {
|
||||
return static_cast<MapperT*>(this)->map(x, y);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "mapperbase.cpp"
|
||||
#include "nullmapper.cpp"
|
||||
#include "offsetmapper.cpp"
|
||||
#include "tilemapper.cpp"
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "mapperbase.cpp"
|
||||
|
||||
namespace UwU {
|
||||
class NullMapper : public MapperBase<NullMapper> {
|
||||
public:
|
||||
NullMapper() {}
|
||||
|
||||
Coord2 map(uint16_t x, uint16_t y) {
|
||||
return Coord2(x, y);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "mapperbase.cpp"
|
||||
|
||||
namespace UwU {
|
||||
class OffsetMapper : public MapperBase<OffsetMapper> {
|
||||
public:
|
||||
OffsetMapper(uint16_t x0, uint16_t y0) {
|
||||
this->x0 = x0;
|
||||
this->y0 = y0;
|
||||
}
|
||||
uint16_t x0, y0;
|
||||
|
||||
Coord2 map(uint16_t x, uint16_t y) {
|
||||
uint16_t u = x -x0;
|
||||
uint16_t v = y -y0;
|
||||
return Coord2(u, v);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "mapperbase.cpp"
|
||||
|
||||
namespace UwU {
|
||||
class TileMapper : public MapperBase<TileMapper> { // not actually tilemapping yet
|
||||
public:
|
||||
TileMapper(uint16_t x0, uint16_t y0) {
|
||||
this->x0 = x0;
|
||||
this->y0 = y0;
|
||||
}
|
||||
uint16_t x0, y0;
|
||||
|
||||
Coord2 map(uint16_t x, uint16_t y) {
|
||||
uint16_t u = x -x0;
|
||||
uint16_t v = y -y0;
|
||||
return Coord2(u, v);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user