summaryrefslogtreecommitdiff
path: root/src/player.c
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2021-03-02 14:52:14 +0300
committerAleksey Veresov <aleksey@veresov.pro>2021-03-02 14:52:14 +0300
commit8889468f6af3ad184acfc39e0beaff503b10e3c1 (patch)
treef96071472318cd61db8818d37bf3a5e62c19dd90 /src/player.c
parent31f5b4cb47f0ac3d2b1f94979725d48340b5c57b (diff)
downloadtakethis-8889468f6af3ad184acfc39e0beaff503b10e3c1.tar
takethis-8889468f6af3ad184acfc39e0beaff503b10e3c1.tar.xz
takethis-8889468f6af3ad184acfc39e0beaff503b10e3c1.zip
The UI!
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c122
1 files changed, 121 insertions, 1 deletions
diff --git a/src/player.c b/src/player.c
index d0ab5b1..a1c7dfc 100644
--- a/src/player.c
+++ b/src/player.c
@@ -24,7 +24,7 @@ void tt_player_draw()
}
}
- if (ttplayer.zhiv_lenin) {
+ if (ttplayer.lenin_zhiv) {
{
SDL_Rect src = { 32 + 32 * (ttplayer.lenin_rem / 200 % 2),
16 * 12 + 4, 32, 38 };
@@ -81,4 +81,124 @@ void tt_player_draw()
64, 96 };
SDL_RenderCopy(ttrdr, tttxr, &s, &d);
}
+
+ {
+ SDL_Rect src = { 0, 16 * 11, 16, 16 };
+ SDL_Rect d = { 20 + TT_ROOM_W * 32 + 32,
+ 12 + 32,
+ 64, 64 };
+ SDL_RenderCopy(ttrdr, tttxr, &src, &d);
+ int count = ttplayer.keys[0];
+ int digits = 1;
+ while (count / 10) {
+ ++digits;
+ count /= 10;
+ }
+ char *text = malloc(3 + digits);
+ text[0] = 'x';
+ text[1] = ' ';
+ int i;
+ count = ttplayer.keys[0];
+ 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 + 32,
+ s->w * 2, s->h * 2 };
+ SDL_RenderCopy(ttrdr, t, 0, &dst);
+ 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);
+ }
}