summaryrefslogtreecommitdiff
path: root/game.c
diff options
context:
space:
mode:
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 21a8c29..c98cc78 100644
--- a/game.c
+++ b/game.c
@@ -5,6 +5,7 @@
#include "game.h"
#include "domino.h"
+#include "characters.h"
#include "assets/white_and_blue_dominoes.h"
#include "assets/red_and_peach_dominoes.h"
@@ -117,6 +118,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;
@@ -170,5 +205,9 @@ void render(struct image canvas) {
if (has_active) {
draw(canvas, red_and_peach_dominoes[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
+
}