summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--game.c2
-rwxr-xr-ximg2map21
-rw-r--r--map.c14
-rw-r--r--map.pngbin0 -> 314 bytes
5 files changed, 26 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index cb8837c..b34cf93 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,7 @@ all: game
clean:
rm -f game
rm -f $(OBJ)
+ rm -f map.c
game: $(OBJ)
$(CC) $^ `pkg-config --libs sdl3` -lm -o $@
@@ -16,4 +17,7 @@ game: $(OBJ)
%.o: %.c
$(CC) $< `pkg-config --cflags sdl3` -c -o $@
+map.c: map.png img2map
+ ./img2map map.png > map.c
+
.PHONY: all clean
diff --git a/game.c b/game.c
index fdf0125..692f076 100644
--- a/game.c
+++ b/game.c
@@ -6,7 +6,7 @@
#include "dat.h"
-#define SPEED 100
+#define SPEED 250
static EntityCollisionProc bulletcollproc;
static EntityUpdateProc playerproc;
diff --git a/img2map b/img2map
new file mode 100755
index 0000000..d9e7e78
--- /dev/null
+++ b/img2map
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+import sys
+from PIL import Image
+
+img = Image.open(sys.argv[1]).convert('1')
+width, height = img.size
+
+print(f"int map_width = {width};")
+print(f"int map_height = {height};")
+print("char map_data[] = {")
+
+for y in range(height):
+ linha = []
+ for x in range(width):
+ pixel = img.getpixel((x, y))
+ valor = '0' if pixel == 0 else '1'
+ linha.append(valor)
+ print(f" {', '.join(linha)},")
+
+print("};")
diff --git a/map.c b/map.c
deleted file mode 100644
index 8c12514..0000000
--- a/map.c
+++ /dev/null
@@ -1,14 +0,0 @@
-int map_width = 8;
-int map_height = 8;
-
-char map_data[] = {
- 1, 0, 0, 0, 0, 0, 0, 0,
- 0, 1, 1, 0, 0, 0, 0, 0,
- 0, 1, 1, 0, 0, 0, 0, 0,
- 0, 1, 1, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 1, 1, 0,
- 0, 0, 0, 0, 0, 1, 1, 0,
- 0, 0, 0, 0, 0, 1, 1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
diff --git a/map.png b/map.png
new file mode 100644
index 0000000..6a14ca1
--- /dev/null
+++ b/map.png
Binary files differ