From d0d970922e54d1fdfd63563b29d83bba072ccc28 Mon Sep 17 00:00:00 2001 From: raandoom Date: Sat, 20 Dec 2014 22:37:13 +0000 Subject: [PATCH] 2048: - scale 2x for tile font TODO: - optimize tile drawing: maybe separate canvas for every tile git-svn-id: svn://kolibrios.org@5252 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/games/2048/paint.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/programs/games/2048/paint.c b/programs/games/2048/paint.c index e27ebdb7ea..131c9057b2 100644 --- a/programs/games/2048/paint.c +++ b/programs/games/2048/paint.c @@ -71,9 +71,6 @@ void canvas_draw_rect(rect *r, __u32 color) void canvas_draw_text(rect* r, char* txt, __u32 len, __u32 color) { - __u16 x = r->x + (r->width - len * FONT_WIDTH - len) / 2 - canvas.area.x; - __u16 y = r->y + (r->height - FONT_HEIGHT) / 2 - canvas.area.y; - __u32 w; __u32 h; char* mem; @@ -94,6 +91,9 @@ void canvas_draw_text(rect* r, char* txt, __u32 len, __u32 color) "S"(len), "D"((__u32)(mem))); + __u16 x = r->x + (r->width - (len * FONT_WIDTH + len) * 2) / 2 - canvas.area.x; + __u16 y = r->y + (r->height - FONT_HEIGHT * 2) / 2 - canvas.area.y; + int row = 0; int column = 0; __u32* __mem = (__u32*)(mem + 8); @@ -104,7 +104,11 @@ void canvas_draw_text(rect* r, char* txt, __u32 len, __u32 color) __u32 c = __mem[column + row * w]; if (c & 0xFF000000) { - canvas.image[canvas_index(row + y,column + x)] = *((rgb*)&c); + canvas.image[canvas_index(row * 2 + y,column * 2 + x)] = *((rgb*)&c); + canvas.image[canvas_index(row * 2 + y,column * 2 + 1 + x)] = *((rgb*)&c); + + canvas.image[canvas_index(row * 2 + 1 + y,column * 2 + x)] = *((rgb*)&c); + canvas.image[canvas_index(row * 2 + 1 + y,column * 2 + 1 + x)] = *((rgb*)&c); } } }