summaryrefslogtreecommitdiff
path: root/tiled.c
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-04-23 03:38:03 +0100
committerdavidovski <david@davidovski.xyz>2023-04-23 03:38:03 +0100
commit50a8424269b868bc89be72fe19756bab8f6d12e9 (patch)
treea2ace5a6e1d2f29b100c9a2e2dae737fea05c920 /tiled.c
parentbb3034a4cb0f793e31608ebee4eff2ef8c1f8379 (diff)
Render map based on passed tilemap
Diffstat (limited to 'tiled.c')
-rw-r--r--tiled.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/tiled.c b/tiled.c
index f3e34f2..0c9954e 100644
--- a/tiled.c
+++ b/tiled.c
@@ -1,17 +1,19 @@
#include <raylib.h>
+#include <wctype.h>
#define SCREEN_W 1280
#define SCREEN_H 720
-#define MAP_W 4
+#define MAP_W 8
#define MAP_H 4
const int tilemap[MAP_H][MAP_W] = {
- {0, 0, 0, 0},
- {0, 0, 3, 3},
- {3, 3, 1, 1},
- {1, 1, 2, 2}
+ {0, 0, 0, 0, 0, 0, 3, 3},
+ {0, 3, 3, 0, 0, 3, 1, 1},
+ {3, 1, 1, 3, 3, 1, 2, 2},
+ {1, 2, 2, 1, 1, 2, 4, 4}
};
+const int atlasSize[2] = {2, 2};
int main() {
@@ -26,14 +28,13 @@ int main() {
float zoom = 1.0f;
Texture atlas = LoadTexture("tiles.png");
// size of the tile atlas grid in tiles
- int atlasSize[2] = {2, 2};
int resolutionLoc = GetShaderLocation(shader, "resolution");
int locationLoc = GetShaderLocation(shader, "offset");
int zoomLoc = GetShaderLocation(shader, "zoom");
int atlasSizeLoc = GetShaderLocation(shader, "atlasSize");
- int tilemapLoc[MAP_W][MAP_H]= {};
+ int tilemapLoc[MAP_H][MAP_W]= {};
for (int x = 0; x < MAP_W; x++) {
for (int y = 0; y < MAP_H; y++) {
tilemapLoc[y][x] = GetShaderLocation(shader, TextFormat("tilemap[%d][%d]", y, x));