summaryrefslogtreecommitdiff
path: root/game.c
diff options
context:
space:
mode:
authorSilas Gramlich <udyvp@student.kit.edu>2025-10-14 22:09:59 +0200
committerSilas Gramlich <udyvp@student.kit.edu>2025-10-14 22:09:59 +0200
commit57542da0daca2b74494fbdc7f68e6f5207eb7e48 (patch)
tree8c3389a1bb36992bc91795897aa4d8640849e765 /game.c
parente01184ed595423e03664db4c645fb7794dddc193 (diff)
added WIP-version of draw_character
Diffstat (limited to 'game.c')
-rw-r--r--game.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/game.c b/game.c
index 752b32b..21ff5b5 100644
--- a/game.c
+++ b/game.c
@@ -6,6 +6,7 @@
#include "game.h"
#include "domino.h"
#include "assets/dominos.h"
+#include "characters.h"
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
@@ -107,6 +108,40 @@ draw(
}
}
+void
+draw_character(
+ struct image canvas,
+ char character,
+ size_t xpos, size_t ypos
+) {
+ const int character_width = 5;
+ const int character_height = 6;
+ struct image texture;
+ texture.width = character_height;
+ texture.height = character_width;
+ texture.buf = (uint32_t[30]) {0};
+ const uint32_t bitmask = characters[character - ' '];
+
+ for (size_t i = 0; i < character_width; i++) {
+ for (size_t j = 0; j < character_height; j++) {
+ if (bitmask >> ((character_height - j - 1) * character_width + (character_width - i + 1)) & 1) {
+ // (0b101101 >> ((height - y - 1) * width + (width - x + 1))) & 1
+ texture.color[j*character_width + i] = (struct color){255, 255, 255, 0};
+ }
+ //else {
+ // texture.color[j*character_width + i] = (struct color){0, 0, 0, 255};
+ //};
+
+ }
+ }
+ draw(canvas, texture, xpos, ypos);
+}
+
+//void
+//draw_text(
+//
+//)
+
void render(struct image canvas) {
for (size_t i = 0; i < canvas.bufsize; i++) canvas.buf[i] = i;
@@ -128,5 +163,9 @@ void render(struct image canvas) {
if (has_active) {
draw(canvas,domino[active.back.val][active.front.val], CLAMP(mouse_x + active.front.x, 0, canvas.width), CLAMP(mouse_y + active.front.y, 0, canvas.height));
}
+
+ // character
+ draw_character(canvas, 'D', 50, 20); // debugging
+
}