From ec583c67456efbfdb07bb2df43b0d0eee4f7b3e2 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Mon, 1 Mar 2021 17:45:24 +0300 Subject: LENIN ZHIV!!! --- src/game.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/game.h | 2 +- src/map.c | 3 +++ src/player.c | 18 ++++++++++++++++++ src/player.h | 4 ++++ 5 files changed, 84 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/game.c b/src/game.c index b39a140..4c6d0a6 100644 --- a/src/game.c +++ b/src/game.c @@ -52,6 +52,7 @@ static void step(int d) if (ttplayer.room == ttmap + 'L') { ttplayer.y -= 32; Mix_PlayMusic(lenin, -1); + magic = tt_mausoleum; } } } @@ -179,6 +180,7 @@ static void gotogulag() if (!roomchanged) { roomchanged = 1; ttplayer.room = ttmap + 'G'; + ttplayer.zhiv_lenin = 0; } SDL_SetRenderDrawColor(ttrdr, 0, 0, 0, 255 - (delta - 4200) * 256 / 800); @@ -216,6 +218,60 @@ static void gotogulag() ticks = SDL_GetTicks(); } +static void mausoleum() +{ + int newticks = SDL_GetTicks(); + while (!q && newticks < ticks + 14300) { + int delta = newticks - ticks; + SDL_Event e; + while (SDL_PollEvent(&e)) { + if (e.type == SDL_QUIT) q = 1; + else if (e.type == SDL_KEYDOWN) { + int code = e.key.keysym.scancode; + if (code == SDL_SCANCODE_W) keyw = 1; + else if (code == SDL_SCANCODE_S) keys = 1; + else if (code == SDL_SCANCODE_A) keya = 1; + else if (code == SDL_SCANCODE_D) keyd = 1; + else if (code == SDL_SCANCODE_UP) arru = 1; + else if (code == SDL_SCANCODE_RIGHT) arrr = 1; + else if (code == SDL_SCANCODE_DOWN) arrd = 1; + else if (code == SDL_SCANCODE_LEFT) arrl = 1; + } else if (e.type == SDL_KEYUP) { + int code = e.key.keysym.scancode; + if (code == SDL_SCANCODE_W) keyw = 0; + else if (code == SDL_SCANCODE_S) keys = 0; + else if (code == SDL_SCANCODE_A) keya = 0; + else if (code == SDL_SCANCODE_D) keyd = 0; + else if (code == SDL_SCANCODE_UP) arru = 0; + else if (code == SDL_SCANCODE_RIGHT) arrr = 0; + else if (code == SDL_SCANCODE_DOWN) arrd = 0; + else if (code == SDL_SCANCODE_LEFT) arrl = 0; + } + } + SDL_RenderClear(ttrdr); + tt_player_draw(); + { + int lenin_size = delta * (48 - 4 - 6) / 14300; + SDL_Rect src = { 32, 16 * 11 + 4, 32, lenin_size }; + SDL_Rect dst = { 14 + ttplayer.lenin_pos, + 14 + 32 + 96 - 8 - lenin_size * 2, + 64, lenin_size * 2 }; + SDL_RenderCopy(ttrdr, tttxr, &src, &dst); + } + { + SDL_Rect src = { 96, 16 * 11, 64, 48 }; + SDL_Rect dst = { 14 + ttplayer.lenin_pos - 32, + 110, 128, 96 }; + SDL_RenderCopy(ttrdr, tttxr, &src, &dst); + } + SDL_RenderPresent(ttrdr); + newticks = SDL_GetTicks(); + } + ttplayer.zhiv_lenin = 1; + magic = 0; + ticks = SDL_GetTicks(); +} + void tt_mainloop() { keyw = keya = keys = keyd = arru = arrr = arrd = arrl = 0; @@ -258,6 +314,8 @@ void tt_mainloop() gotofirstroom(); } else if (magic == tt_gotogulag) { gotogulag(); + } else if (magic == tt_mausoleum) { + mausoleum(); } } } diff --git a/src/game.h b/src/game.h index 7bccfad..25017b2 100644 --- a/src/game.h +++ b/src/game.h @@ -2,7 +2,7 @@ #define TT_INCLUDED_GAME -enum { tt_gotofirstroom = 1, tt_gotogulag }; +enum { tt_gotofirstroom = 1, tt_gotogulag, tt_mausoleum }; extern int magic; diff --git a/src/map.c b/src/map.c index 61c23a6..8e32da6 100644 --- a/src/map.c +++ b/src/map.c @@ -86,6 +86,9 @@ static void loadroom(tt_room *r, FILE *f) ttplayer.money = 0; ttplayer.keys = 0; ttplayer.the_key = 0; + ttplayer.lenin_pos = 32 * 9; + ttplayer.zhiv_lenin = 0; + ttplayer.lenin_rem = 0; ttplayer.variant = 0; ttplayer.tobein_gulag = 0; ttplayer.until_gulag = 5300; diff --git a/src/player.c b/src/player.c index 5809d95..edaa04f 100644 --- a/src/player.c +++ b/src/player.c @@ -23,6 +23,24 @@ void tt_player_draw() } } } + + if (ttplayer.zhiv_lenin) { + { + SDL_Rect src = { 32 + 32 * (ttplayer.lenin_rem / 100 % 2), + 16 * 11 + 4, 32, 38 }; + SDL_Rect dst = { 14 + ttplayer.lenin_pos, + 14 + 32 + 96 - 8 - 38 * 2, 64, 38 * 2 }; + SDL_RenderCopy(ttrdr, tttxr, &src, &dst); + } + { + SDL_Rect src = { 96 + 64 * (ttplayer.lenin_rem / 100 % 2), + 16 * 11, 64, 48 }; + SDL_Rect dst = { 14 + ttplayer.lenin_pos - 32, + 110, 128, 96 }; + SDL_RenderCopy(ttrdr, tttxr, &src, &dst); + } + } + for (i = 0; i != r->bodies_count; ++i) { tt_body *b = r->bodies + i; SDL_Rect s = { diff --git a/src/player.h b/src/player.h index 8504046..7c2fc56 100644 --- a/src/player.h +++ b/src/player.h @@ -20,6 +20,10 @@ typedef struct tt_player { int the_key; int tobein_gulag; int until_gulag; + + int lenin_pos; + int zhiv_lenin; + int lenin_rem; } tt_player; -- cgit v1.2.3