summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2024-01-11 10:06:57 +0100
committerkdx <kikoodx@paranoici.org>2024-01-11 10:06:57 +0100
commite6fb7a17425d49b4cc19c6df660a448478238925 (patch)
tree7a6ca5e5448186796728eb600a6b94889f480d8d
parente6c2cd08a7b3b4d3bf7d5ddfa6ef3b669d66b0b8 (diff)
download008-e6fb7a17425d49b4cc19c6df660a448478238925.tar.gz
draw player
-rw-r--r--inc/__.h1
-rw-r--r--inc/player.h4
-rw-r--r--res/tset.bmpbin2186 -> 3210 bytes
-rw-r--r--res/world/0.csv4
-rw-r--r--src/main.c2
-rw-r--r--src/player.c22
6 files changed, 31 insertions, 2 deletions
diff --git a/inc/__.h b/inc/__.h
index f16960e..110212c 100644
--- a/inc/__.h
+++ b/inc/__.h
@@ -8,3 +8,4 @@
#include "point.h"
#include "matrix.h"
#include "mesh.h"
+#include "player.h"
diff --git a/inc/player.h b/inc/player.h
new file mode 100644
index 0000000..1e869de
--- /dev/null
+++ b/inc/player.h
@@ -0,0 +1,4 @@
+#pragma once
+
+void player_reset(void);
+void player_draw(f64 x, f64 y);
diff --git a/res/tset.bmp b/res/tset.bmp
index 7d0b431..8103453 100644
--- a/res/tset.bmp
+++ b/res/tset.bmp
Binary files differ
diff --git a/res/world/0.csv b/res/world/0.csv
index 8226164..4df35c3 100644
--- a/res/world/0.csv
+++ b/res/world/0.csv
@@ -1,7 +1,7 @@
16,16
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
-1,0,0,0,0,0,0,0,0,0,0,0,2,2,2,1
+1,0,0,0,0,0,0,0,0,0,0,0,2,2,4,1
1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1
1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1
1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1
@@ -13,5 +13,5 @@
1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1
1,0,0,0,2,0,0,0,0,0,0,0,0,1,1,1
1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1
-1,0,0,0,1,1,1,2,2,2,0,0,0,2,2,1
+1,0,3,0,1,1,1,2,2,2,0,0,0,2,2,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 \ No newline at end of file
diff --git a/src/main.c b/src/main.c
index a43cc2d..c85dbb5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -30,6 +30,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
defer(input_deinit);
world_init("res/world/world.csv", "res/world/%d.csv");
defer(world_deinit);
+ player_reset();
TZR_MainLoop(_main_loop, nullptr);
return 0;
}
@@ -73,6 +74,7 @@ _main_loop([[maybe_unused]] void *udata)
TZR_BlendMode(SDL_BLENDMODE_ADD);
world_draw(x, y);
+ player_draw(x, y);
assert(TZR_DrawEnd() == 0);
return 0;
diff --git a/src/player.c b/src/player.c
new file mode 100644
index 0000000..6048bc7
--- /dev/null
+++ b/src/player.c
@@ -0,0 +1,22 @@
+static Point pos;
+
+void
+player_reset(void)
+{
+ const auto spawn = world_find(2);
+ pos = point(spawn.x, spawn.y, 0);
+}
+
+void
+player_draw(f64 x, f64 y)
+{
+ extern Mesh *g_cube;
+
+ Mat4 m = mat4_identity();
+ m = mat4_dot(m, mat4_scaling(0.7, 0.7, 0.7 * 16));
+ m = mat4_dot(m, mat4_translating(-7.5 + pos.x - x,
+ -7.5 + pos.y - y,
+ -256));
+ TZR_DrawSetColor(0, 1, 0);
+ mesh_draw(g_cube, m);
+}