moved textures into their own classes, better tilemapping
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
#include "texturebase.cpp"
|
||||
#include "../tilemap.cpp"
|
||||
|
||||
namespace UwU {
|
||||
class TilemapTexture : public TextureBase<TilemapTexture> {
|
||||
private:
|
||||
Buffer buffer;
|
||||
Tilemap tilemap;
|
||||
|
||||
public:
|
||||
TilemapTexture(Tilemap tilemap, Buffer buffer) {
|
||||
this->buffer = buffer;
|
||||
this->tilemap = tilemap;
|
||||
}
|
||||
|
||||
Color texel(uint16_t u, uint16_t v) {
|
||||
Coord2 bitmapUV = tilemap.map(u, v);
|
||||
uint32_t index = (bitmapUV.y * buffer.stride) + (bitmapUV.x * 4);
|
||||
Color c = Color(buffer.pixels[index + 2], buffer.pixels[index + 1], buffer.pixels[index], buffer.pixels[index + 3]);
|
||||
return c;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user