From 7fbb9c444057fe3f30da0bac4d52fd8c6e8ba59b Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Mon, 1 Mar 2021 12:47:01 +0300 Subject: O_o --- src/game.c | 10 ++++++++-- src/map.c | 37 +++++++++++++++++++++++++------------ src/player.c | 21 +++++++++++++-------- src/player.h | 2 ++ src/room.h | 1 - 5 files changed, 48 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/game.c b/src/game.c index 444f9ff..a4b4924 100644 --- a/src/game.c +++ b/src/game.c @@ -10,11 +10,17 @@ static int ticks; static void step(int d) { - int xw = ttplayer.xwalk * 137; - int yw = ttplayer.ywalk * 137; + int xw = ttplayer.xwalk * 200; + int yw = ttplayer.ywalk * 200; if (xw || yw) { ttplayer.rem += d; } + if (ttplayer.tobein_gulag && ttplayer.until_gulag > 0) { + ttplayer.until_gulag -= d; + if (ttplayer.until_gulag <= 0) { + ttplayer.room = ttmap + 'G'; + } + } if (xw && yw) { ttplayer.xrem += (double)(xw * d) / sqrt(2); ttplayer.yrem += (double)(yw * d) / sqrt(2); diff --git a/src/map.c b/src/map.c index 13894d6..d0575fb 100644 --- a/src/map.c +++ b/src/map.c @@ -31,6 +31,17 @@ static SDL_Rect *newtile(int row, int col) static void do_nothing(tt_body *b) {} +static void togulag(tt_body *b) +{ + ttplayer.tobein_gulag = 1; + b->collision_act = do_nothing; + b->anim = 1; + b->txrrow = 0; + b->txrcol = 15; + b->msg = 0; + b->msglen = 0; +} + static void gribtake(tt_body *b) { Mix_PlayMusic(ponpon, -1); @@ -38,6 +49,9 @@ static void gribtake(tt_body *b) b->anim = 1; b->txrrow = 0; b->txrcol = 15; + b->msg = 0; + b->msglen = 0; + ttplayer.variant = 1; magic = tt_gotofirstroom; } @@ -56,10 +70,10 @@ static void loadroom(tt_room *r, FILE *f) int id = fgetc(f); int c = id; if (id == ' ') id = '0'; - id -= '0'; + if (id < 'a') id -= '0'; + else id = id - 'a' + 10; r->floor[i][j] = 0; r->walls[i][j] = 0; - r->roof[i][j] = 0; if (type == '@') { ttplayer.room = r; ttplayer.x = j * 32; @@ -72,7 +86,9 @@ static void loadroom(tt_room *r, FILE *f) ttplayer.money = 0; ttplayer.keys = 0; ttplayer.the_key = 0; - ttplayer.variant = 1; + ttplayer.variant = 0; + ttplayer.tobein_gulag = 0; + ttplayer.until_gulag = 5300; r->floor[i][j] = newtile(0, default_floor_id); } else if (type == '#') { r->walls[i][j] = malloc(sizeof(tt_body)); @@ -104,7 +120,7 @@ static void loadroom(tt_room *r, FILE *f) b->xvel = 0; b->yvel = 0; b->rem = 0; - b->txrrow = 8; + b->txrrow = 7; b->txrcol = id; b->anim = 4; b->rate = 150 + (rand() % 50 - 25); @@ -122,7 +138,7 @@ static void loadroom(tt_room *r, FILE *f) b->xvel = 0; b->yvel = 0; b->rem = 0; - b->txrrow = 8; + b->txrrow = 7; b->txrcol = id; b->anim = 4; b->rate = 150 + (rand() % 50 - 25); @@ -140,7 +156,7 @@ static void loadroom(tt_room *r, FILE *f) b->xvel = 0; b->yvel = 0; b->rem = 0; - b->txrrow = 10; + b->txrrow = 9; b->txrcol = id; b->anim = 1; b->rate = 100; @@ -159,16 +175,13 @@ static void loadroom(tt_room *r, FILE *f) b->xvel = 0; b->yvel = 0; b->rem = 0; - b->txrrow = 9; + b->txrrow = 8; b->txrcol = id; b->anim = 4; b->rate = 150 + (rand() % 50 - 25); b->collision_act = do_nothing; b->msg = 0; b->msglen = 0; - } else if (type == 'X') { - r->floor[i][j] = newtile(0, default_floor_id); - r->roof[i][j] = newtile(5, id); } else if (type == '=') { r->floor[i][j] = newtile(0, default_floor_id); r->bodies_count++; @@ -196,11 +209,11 @@ static void loadroom(tt_room *r, FILE *f) b->xrem = 0; b->yrem = 0; b->rem = 0; - b->txrrow = 7; + b->txrrow = 6; b->txrcol = id; b->anim = 4; b->rate = 100 + (rand() % 50 - 25); - b->collision_act = 0; /* todo: kill */ + b->collision_act = togulag; } } fgetc(f); diff --git a/src/player.c b/src/player.c index 10d5c5f..daf4a96 100644 --- a/src/player.c +++ b/src/player.c @@ -1,5 +1,6 @@ #include "player.h" +#include #include "globals.h" @@ -46,16 +47,20 @@ void tt_player_draw() if (ttplayer.xwalk == 1) dir = 6; else if (ttplayer.xwalk == -1) dir = 2; else if (ttplayer.ywalk == -1) dir = 4; - SDL_Rect s = { 16 * (dir + (ttplayer.rem / 100 % 2)), - 16 * (5 + ttplayer.variant), + SDL_Rect s = { 16 * (8 * ttplayer.variant + + dir + (ttplayer.rem / 100 % 2)), + 16 * 5, 16, 16 }; SDL_RenderCopy(ttrdr, tttxr, &s, &d); - for (i = 0; i != TT_ROOM_H; ++i) { - for (j = 0; j != TT_ROOM_W; ++j) { - SDL_Rect d = { 14 + j * 32, 14 + i * 32, 32, 32 }; - SDL_Rect *roof = r->roof[i][j]; - if (roof) SDL_RenderCopy(ttrdr, tttxr, roof, &d); - } + if (ttplayer.until_gulag > 0) { + double r = ttplayer.until_gulag / 10; + double f = (double)(ttplayer.until_gulag) / 3000 * + 2 * 3.14159265358979323846; + SDL_Rect s = { 0, 16 * 11, 16, 32 }; + SDL_Rect d = { ttplayer.x + r * cos(f), + ttplayer.y - 16 + r * sin(f), + 32, 64 }; + SDL_RenderCopy(ttrdr, tttxr, &s, &d); } } diff --git a/src/player.h b/src/player.h index cc224ba..8504046 100644 --- a/src/player.h +++ b/src/player.h @@ -18,6 +18,8 @@ typedef struct tt_player { int money; int keys; int the_key; + int tobein_gulag; + int until_gulag; } tt_player; diff --git a/src/room.h b/src/room.h index b4567f2..f1f9ba2 100644 --- a/src/room.h +++ b/src/room.h @@ -12,7 +12,6 @@ typedef struct tt_room { SDL_Rect *floor[TT_ROOM_H][TT_ROOM_W]; tt_body *walls[TT_ROOM_H][TT_ROOM_W]; - SDL_Rect *roof[TT_ROOM_H][TT_ROOM_W]; tt_body *bodies; int bodies_count; struct tt_room *neighbours[4]; -- cgit v1.2.3