summaryrefslogtreecommitdiff
path: root/src/tiled.c
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-07-23 15:30:42 +0200
committerdavidovski <david@davidovski.xyz>2023-07-23 15:30:42 +0200
commit0d78ec0e53d9824a029840e74bf0721ed2187e6a (patch)
tree74781baff855e3f3760730c9897e932994f3a8a4 /src/tiled.c
parent5ec62c0a2a0357a79f92b8bb37f67272e7f910ff (diff)
add chunk caching
Diffstat (limited to 'src/tiled.c')
-rw-r--r--src/tiled.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/tiled.c b/src/tiled.c
index f490d6a..0628523 100644
--- a/src/tiled.c
+++ b/src/tiled.c
@@ -48,15 +48,25 @@ Vector2 translateTiledScreenPosition(Tiled tiled, Vector2 tiledPos) {
};
}
+void redrawTile(Tiled tiled, int x, int y) {
+ BeginTextureMode(tiled.tilemapTexture);
+ unsigned char v = getChunkedTile(&tiled.tiledMap, x, y);
+ Color c = (Color){
+ v, 0, 0, 255
+ };
+ DrawPixel(x, tiled.mapSize[1] - y - 1, c);
+ EndTextureMode();
+}
+
void redrawTiledMap(Tiled tiled) {
BeginTextureMode(tiled.tilemapTexture);
for (int y = 0; y < tiled.mapSize[1]; y++) {
for (int x = 0; x < tiled.mapSize[0]; x++) {
- unsigned char v = getChunkedTile(tiled.tiledMap, x, tiled.mapSize[1] - y - 1);
+ unsigned char v = getChunkedTile(&tiled.tiledMap, x, y);
Color c = (Color){
v, 0, 0, 255
};
- DrawPixel(x, y, c);
+ DrawPixel(x, tiled.mapSize[1] - y - 1, c);
}
}
EndTextureMode();
@@ -64,7 +74,7 @@ void redrawTiledMap(Tiled tiled) {
}
-Tiled initTiled(ChunkedTiledMap tiledMap) {
+Tiled initTiled(TiledMap tiledMap) {
Tiled tiled;
tiled.tiledMap = tiledMap;