summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-07-10 00:29:01 +0100
committerdavidovski <david@davidovski.xyz>2023-07-10 00:29:57 +0100
commitb87245927e08887af7746ce0f7a91d3f73af0572 (patch)
tree0c05b62e5de041e62f5373b747f292b348ce9491
parentab6501461a12894795661914096704451c343344 (diff)
cleanup project
-rw-r--r--atlas.png (renamed from tiled.png)bin875 -> 875 bytes
-rw-r--r--makefile4
-rw-r--r--src/tiled.c (renamed from tiled.c)2
-rw-r--r--src/tiledfile.c (renamed from tiledfile.c)27
-rw-r--r--src/tiledfile.h (renamed from tiledfile.h)0
-rwxr-xr-xtools/createmap.py (renamed from createmap.py)0
6 files changed, 18 insertions, 15 deletions
diff --git a/tiled.png b/atlas.png
index 455750a..455750a 100644
--- a/tiled.png
+++ b/atlas.png
Binary files differ
diff --git a/makefile b/makefile
index 4c0072f..43709b3 100644
--- a/makefile
+++ b/makefile
@@ -6,8 +6,8 @@ FLAGS=-lm -lraylib
install: tiled
cp tiled ${PREFIX}/bin/
-build: tiled.c tiledfile.c tiledfile.h
- ${CC} tiled.c tiledfile.c -o tiled ${FLAGS}
+build: src/*.c src/*.h
+ ${CC} src/*.c -o tiled ${FLAGS}
clean: tiled
rm tiled
diff --git a/tiled.c b/src/tiled.c
index 715a91d..2cb1cb0 100644
--- a/tiled.c
+++ b/src/tiled.c
@@ -15,7 +15,7 @@ int main() {
Texture2D tilemap = loadTileMap("map.tiles");
- Texture atlas = LoadTexture("tiled.png");
+ Texture atlas = LoadTexture("atlas.png");
RenderTexture2D target = LoadRenderTexture(SCREEN_W, SCREEN_H);
float resolution[2] = {SCREEN_W, SCREEN_H};
diff --git a/tiledfile.c b/src/tiledfile.c
index 8cb8dfa..c1ba42e 100644
--- a/tiledfile.c
+++ b/src/tiledfile.c
@@ -31,20 +31,23 @@ Texture2D processTilemapTexture(int * tilelayout, int width, int height) {
return checked;
}
-// read a big endian bytes from file
+//! read a big endian bytes from file
int readb(char *out, size_t noBytes, FILE *file) {
- int s = fread(out, (size_t)1, (size_t) noBytes, file);
-
- if (!is_bigendian()) {
- int tmp;
- // reverse byte order
- for(int i = 0; i < noBytes/2; i++) {
- tmp = out[i];
- out[i] = out[noBytes-i-1];
- out[noBytes-i-1] = tmp;
- }
+ if (!fread(out, (size_t)1, (size_t) noBytes, file))
+ return 1;
+
+ if (is_bigendian())
+ return 0;
+
+ int tmp;
+ // reverse byte order
+ for(int i = 0; i < noBytes/2; i++) {
+ tmp = out[i];
+ out[i] = out[noBytes-i-1];
+ out[noBytes-i-1] = tmp;
}
- return s;
+
+ return 0;
}
diff --git a/tiledfile.h b/src/tiledfile.h
index cf2980b..cf2980b 100644
--- a/tiledfile.h
+++ b/src/tiledfile.h
diff --git a/createmap.py b/tools/createmap.py
index 59fb315..59fb315 100755
--- a/createmap.py
+++ b/tools/createmap.py