From c618f87f2f00f94e02411eb2d5f0007a54a8b14e Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Tue, 2 Mar 2021 19:18:35 +0300 Subject: Fix of fix of fix. --- src/game.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/game.c b/src/game.c index 068dbc7..09b7316 100644 --- a/src/game.c +++ b/src/game.c @@ -979,6 +979,7 @@ void changeroom(int out) SDL_Rect d = { 0, 14 + TT_ROOM_H * 32, 950, 540 }; SDL_RenderFillRect(ttrdr, &d); } + { SDL_Rect src = { 0, 16 * 11, 16, 16 }; SDL_Rect d = { 20 + TT_ROOM_W * 32 + 32, 12 + 32, 64, 64 }; @@ -1008,6 +1009,93 @@ void changeroom(int out) SDL_DestroyTexture(t); SDL_FreeSurface(s); } + { + SDL_Rect src = { 16, 16 * 11, 16, 16 }; + SDL_Rect d = { 20 + TT_ROOM_W * 32 + 32, 12 + 96, 64, 64 }; + SDL_RenderCopy(ttrdr, tttxr, &src, &d); + int count = ttplayer.keys[1]; + int digits = 1; + while (count / 10) { + ++digits; + count /= 10; + } + char *text = malloc(3 + digits); + text[0] = 'x'; + text[1] = ' '; + int i; + count = ttplayer.keys[1]; + for (i = digits + 1; i != 1; --i) { + text[i] = count % 10 + '0'; + count /= 10; + } + text[digits + 2] = 0; + SDL_Color c = { 255, 255, 255, 255 }; + SDL_Surface *s = TTF_RenderText_Blended(ttfont, text, c); + SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s); + SDL_Rect dst = { 50 + 32 * TT_ROOM_W + 64, 20 + 96, s->w * 2, + s->h * 2 }; + SDL_RenderCopy(ttrdr, t, 0, &dst); + SDL_DestroyTexture(t); + SDL_FreeSurface(s); + } + { + int count = ttplayer.money; + int digits = 1; + while (count / 10) { + ++digits; + count /= 10; + } + char *text = malloc(4 + digits); + text[0] = '$'; + text[1] = ' '; + text[2] = ttplayer.money < 0 ? '-' : ' '; + int i; + count = ttplayer.money * (ttplayer.money < 0 ? -1 : 1); + for (i = digits + 2; i != 2; --i) { + text[i] = count % 10 + '0'; + count /= 10; + } + text[digits + 3] = 0; + SDL_Color c = { 255, 255, 255, 255 }; + SDL_Surface *s = TTF_RenderText_Blended(ttfont, text, c); + SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s); + SDL_Rect dst = { 50 + 32 * TT_ROOM_W + 16, 20 + 96 + 96, s->w * 2, + s->h * 2 }; + SDL_RenderCopy(ttrdr, t, 0, &dst); + SDL_DestroyTexture(t); + SDL_FreeSurface(s); + } + if (ttplayer.lenin_rem) { + int count = ttplayer.lenin_rem / 1000; + int digits = 1; + while (count / 10) { + ++digits; + count /= 10; + } + char *text = malloc(7 + digits); + text[0] = 'T'; + text[1] = 'i'; + text[2] = 'm'; + text[3] = 'e'; + text[4] = ':'; + text[5] = ' '; + int i; + count = ttplayer.lenin_rem / 1000; + for (i = digits + 5; i != 5; --i) { + text[i] = count % 10 + '0'; + count /= 10; + } + text[digits + 6] = 0; + SDL_Color c = { 255, 255, 255, 255 }; + SDL_Surface *s = TTF_RenderText_Blended(ttfont, text, c); + SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s); + SDL_Rect dst = { 50 + 32 * TT_ROOM_W + 16, 20 + 96 + 96 + 96, + s->w * 2, s->h * 2 }; + SDL_RenderCopy(ttrdr, t, 0, &dst); + SDL_DestroyTexture(t); + SDL_FreeSurface(s); + } + SDL_RenderPresent(ttrdr); newticks = SDL_GetTicks(); } -- cgit v1.2.3