summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2021-03-01 17:45:24 +0300
committerAleksey Veresov <aleksey@veresov.pro>2021-03-01 17:45:24 +0300
commitec583c67456efbfdb07bb2df43b0d0eee4f7b3e2 (patch)
treed770fe8563fc36d16494a37c08ddf13179c22b1d /src
parent59096860aa1b293e7bb8af6e372482b7277038a0 (diff)
downloadtakethis-ec583c67456efbfdb07bb2df43b0d0eee4f7b3e2.tar
takethis-ec583c67456efbfdb07bb2df43b0d0eee4f7b3e2.tar.xz
takethis-ec583c67456efbfdb07bb2df43b0d0eee4f7b3e2.zip
LENIN ZHIV!!!
Diffstat (limited to 'src')
-rw-r--r--src/game.c58
-rw-r--r--src/game.h2
-rw-r--r--src/map.c3
-rw-r--r--src/player.c18
-rw-r--r--src/player.h4
5 files changed, 84 insertions, 1 deletions
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;