diff options
Diffstat (limited to 'game.c')
| -rw-r--r-- | game.c | 41 |
1 files changed, 20 insertions, 21 deletions
@@ -121,35 +121,34 @@ draw( void draw_character( struct image canvas, - char character, + 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}; + struct image texture = { + .width = 5, + .height = 6, + .bufsize = 5 * 6, + .buf = (uint32_t[30]) {0} + }; + + for (size_t i = 0; character[i]; i++) { + const uint32_t bitmask = characters[character[i] - ' ']; + texture.buf = (uint32_t[30]) {0}; + + for (size_t y = 0; y < texture.height; y++) { + for (size_t x = 0; x < texture.width; x++) { + if ((bitmask >> ((texture.height - y - 1) * texture.width + (texture.width - x - 1))) & 1) { + texture.buf[y * texture.width + x] = -1; + } } - //else { - // texture.color[j*character_width + i] = (struct color){0, 0, 0, 255}; - //}; - } + draw(canvas, texture, xpos + i * texture.width, ypos); } - draw(canvas, texture, xpos, ypos); } //void //draw_text( -// +// //) void render(struct image canvas) { @@ -207,7 +206,7 @@ void render(struct image canvas) { } // character - draw_character(canvas, 'D', 50, 20); // debugging + draw_character(canvas, "Hallo Welt", 50, 20); // debugging } |
