From 72412a01bd5e4fc319979de9c0f63b968b3f8ac5 Mon Sep 17 00:00:00 2001 From: JailDoctor Date: Fri, 3 Dec 2021 20:07:46 +0100 Subject: [PATCH] [BUG]only using last defined colors [BUG]print(str,x,y) never reached 0 --- ascii.cpp | 9 +++++---- game.lua | 12 ++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ascii.cpp b/ascii.cpp index f01f65e..bdeba24 100644 --- a/ascii.cpp +++ b/ascii.cpp @@ -106,8 +106,9 @@ int main(int argc,char*argv[]) { for (int y=0; y> 4]; + const uint8_t chr_color = COLSCR(x,y); + const uint32_t ink_color = palette[chr_color & 0x0f]; + const uint32_t paper_color = palette[chr_color >> 4]; const uint8_t chr = CHRSCR(x,y); for (int l=0; l<8; ++l) { const uint8_t line = font[chr*8+l]; @@ -156,8 +157,8 @@ void locate(uint8_t x, uint8_t y) { } void print(const char *str, int x, int y) { - if (x > 0) cursor_x = min(x, screen_width-1); - if (y > 0) cursor_y = min(y, screen_height-1); + if (x >= 0) cursor_x = min(x, screen_width-1); + if (y >= 0) cursor_y = min(y, screen_height-1); int len = SDL_strlen(str); if ((cursor_x+len) > screen_width) len -= ((cursor_x+len) - screen_width); for (int i=0; i < len; ++i) { diff --git a/game.lua b/game.lua index 0ee7cc7..7957221 100644 --- a/game.lua +++ b/game.lua @@ -5,6 +5,7 @@ function init() end function update() + paper(COLOR_BLACK) cls() x = x + dx y = y + dy @@ -14,6 +15,13 @@ function update() if y == 29 or y == 0 then dy = -dy end - locate(x, y) - print("\224") + locate(2, 2) + paper(COLOR_GREEN) + ink(COLOR_BLACK) + print("HOLA!") + + --locate(x, y) + ink(COLOR_RED) + paper(COLOR_YELLOW) + print("\224", x, y) end \ No newline at end of file