From 7fbb9c444057fe3f30da0bac4d52fd8c6e8ba59b Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Mon, 1 Mar 2021 12:47:01 +0300 Subject: O_o --- Makefile | 2 +- data/map/0 | 8 ++++---- data/map/1 | 50 ++++++++++++++++++++++++-------------------------- data/map/@ | 32 ++++++++++++++++---------------- data/map/G | 19 +++++++++++++++++++ data/txr.bmp | Bin 196746 -> 213130 bytes src/game.c | 10 ++++++++-- src/map.c | 37 +++++++++++++++++++++++++------------ src/player.c | 21 +++++++++++++-------- src/player.h | 2 ++ src/room.h | 1 - 11 files changed, 112 insertions(+), 70 deletions(-) create mode 100644 data/map/G diff --git a/Makefile b/Makefile index 977ea63..69c10cb 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ else CFLAGS += -O3 endif # Use SDL: -LFLAGS = -lSDL2 -lSDL2_ttf -lSDL2_mixer +LFLAGS = -lSDL2 -lSDL2_ttf -lSDL2_mixer -lm # Directories definitions: BUILD = build diff --git a/data/map/0 b/data/map/0 index 719c8ff..5d16e33 100644 --- a/data/map/0 +++ b/data/map/0 @@ -6,10 +6,10 @@ #7. . ^1. . . . . . . . . . . . . . . #5 #7. . . . . . . . . . . . . . . . . . #5 #7. . . . . . . . . . . . . . . $ . . #5 -#7. . . . . . . . . . . . . . . . . . #5 -#7. . . $1. . . . . . . . . . . . . . X2 -#7. . . . . . . . . . . . . . . . . . X3 -#7. . . . . . . . . . . . . . . . . . #5 +#7. . . . . . . . . . . . . . . . . . #a +#7. . . $1. . . . . . . . . . . . . . .0 +#7. . . . . . . . . . . . . . . . . . .0 +#7. . . . . . . . . . . . . . . . . . #8 #7. . . . . . . . . . . . . . . . . . #5 #7. . $ . . . . . . . . . . . . . . . #5 #7. . . . . . . . . ^2. . . ^1. . . . #5 diff --git a/data/map/1 b/data/map/1 index 93ee8bd..0963d94 100644 --- a/data/map/1 +++ b/data/map/1 @@ -1,27 +1,25 @@ -0 +5 .230 -#0#4#4#4#4#4#4#4#4#4#4#4#4#4#4#4#4#4#4#1 -#7. . . . . . . . . . . . . . . . . . #5 -#7. . $ . . . . . ^ . . . . . . . $ . #5 -#7. . . . . . . . . . . . . . ^ . . . #5 -#7. . . . . $ . . . . . . $ . . . . . #5 -#7. . . . . . . . . . . . . . . . . . #5 -#7. . . $ . . ^3^ ^1^ ^2^ . . . . . . #5 -X7. . . . . . . . . . . ^3. . . . . . X2 -X6. . . . . . . . . . . ^1. . . ^2. . X3 -#7. . . . ^ . $ . . . . ^ . . . . . . #5 -#7. . . . ^2. . . . . . . . $ . . . . #5 -#7. . $ . ^3. . . . . . . . . . . . . #5 -#7. . . . . . . . . $ . . . ^1. . . . #5 -#7. . . . . . . . . . . . . . . ^ . . #5 -#7. . . . . . . . . . . . . . . . . . #5 -#2#6#6#6#6#6#6#6#6X4X5#6#6#6#6#6#6#6#6#3 -+030+050 --050+100 -+065-054 -+052-045 --098+034 -+000+000 -+040-023 --047-073 --034-078 +.3.3.3#0#4#4#4#4#4#4#4#4#4#4#4#4#1.3.3.3 +.3.7.3#7^3^1^0. . . . . . . ^2^1#5.3.7.3 +.3.3.3#7. . . . . . . . . . . ^0#5.3.3.3 +#0#4#4#b. . . . . $ . . . . . . #a#4#4#1 +#7^0^3. . . . . . . . . . . . . . . ^2#5 +#7. . . . . #8#6#6#6#6#6#6#9. . . . ^0#5 +#b. . . = #8#3.3.3.3.3.3.3#2#9. . . . #a +.6. . . = #5.3.3.3.3.3.3.3.3#7. . . . .6 +.6. . . = #5.3.3.3.3.3.3.3.3#7. . . . .6 +#9. . . = #a#1.3.3.3.3.3.3#0#b. . . . #8 +#7^1. . . . #a#4#4#4#4#4#4#b. . $1. . #5 +#7^2. . . . . . . . . . . . . . . . ^2#5 +#2#6#6#9. . $ . . . . . . . . . #8#6#6#3 +.3.3.3#7^1. . . . . . . . . . ^2#5.3.3.3 +.3.7.3#7^0^3^0. . . . . . . . ^2#5.3.7.3 +.3.3.3#2#6#6#6#6#9.6.6#8#6#6#6#6#3.3.3.3 ++094-097 ++000+000= USSR ZHIVI ++000+000= FOREVER! ++000+000= -- some GRIB on this ++000+000= MXII syezd of KPSS +-094+097 ++094+097 diff --git a/data/map/@ b/data/map/@ index 4ae3c97..2a22f05 100644 --- a/data/map/@ +++ b/data/map/@ @@ -1,21 +1,21 @@ 5 .... -#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#> -#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#> -#>#>#0#4#4#4#4#4#4#4#4#4#4#4#4#4#1#>#>#> -#>#>#7.6. . . . . . . . . . . .6#5#>#>#> -#>#>#7.6= . . . . . . . . . . .6#5#>#>#> -#>#>#7.6. . . = . . . . . . . .6#5#>#>#> -#>#>#7.6. . * . . &6. . * . . .6#5#>#>#> -#>#>#7.6. . . . . . . . . . . .6#5#>#>#> -#>#>#7.6. . . . . M . . . . . .6#5#>#>#> -#>#>#7.6. . . . . . . . . . . .6#5#>#>#> -#>#>#7.6. . . . . . . . . . . .6#5#>#>#> -#>#>#7.6. . . . . @ . . . . . .6#5#>#>#> -#>#>#7.6. . . . . . . . . . . .6#5#>#>#> -#>#>#2#6#6#6#6#6#6#6#6#6#6#6#6#6#3#>#>#> -#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#> -#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#> +#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f +#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f +#f#f#0#4#4#4#4#4#4#4#4#4#4#4#4#4#1#f#f#f +#f#f#7.6. . . . . . . . . . . .6#5#f#f#f +#f#f#7.6= . . . . . . . . . . .6#5#f#f#f +#f#f#7.6. . . = . . . . . . . .6#5#f#f#f +#f#f#7.6. . * . . &6. . * . . .6#5#f#f#f +#f#f#7.6. . . . . . . . . . . .6#5#f#f#f +#f#f#7.6. . . . . M . . . . . .6#5#f#f#f +#f#f#7.6. . . . . . . . . . . .6#5#f#f#f +#f#f#7.6. . . . . . . . . . . .6#5#f#f#f +#f#f#7.6. . . . . @ . . . . . .6#5#f#f#f +#f#f#7.6. . . . . . . . . . . .6#5#f#f#f +#f#f#2#6#6#6#6#6#6#6#6#6#6#6#6#6#3#f#f#f +#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f +#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f#f +000+000=IT'S DANGEROUS TO GO ALONE! +000+000=TAKE THIS. +000+000 diff --git a/data/map/G b/data/map/G new file mode 100644 index 0000000..0dbd7bf --- /dev/null +++ b/data/map/G @@ -0,0 +1,19 @@ +5 +GGGG +.3.3.3#0#4#4#4#4#b.6.6#a#4#4#4#4#1.3.3.3 +.3.7.3#7^3^1^0. . . . . . . ^2^1#5.3.7.3 +.3.3.3#7. . . . . . . . . . . ^0#5.3.3.3 +#0#4#4#b. . . . . . . . . . . . #a#4#4#1 +#7^0^3. . . . . . . . . . . . . . . ^2#5 +#7. . . . . #8#6#6#6#6#6#6#9. . . . ^0#5 +#b. . . . #8#3.3.3.3.3.3.3#2#9. . . . #a +.6. . . = #5.3.3.3.3.3.3.3.3#7. . . . .6 +.6. . . . #5.3.3.3.3.3.3.3.3#7. . . . .6 +#9. . . . #a#1.3.3.3.3.3.3#0#b. . . . #8 +#7^1. . . . #a#4#4#4#4#4#4#b. . . . . #5 +#7^2. . . . . . . . . . . . . . . . ^2#5 +#2#6#6#9. . . . . . . . . . . . #8#6#6#3 +.3.3.3#7^1. . . . . . . . . . ^2#5.3.3.3 +.3.7.3#7^0^3^0. . . . . . . . ^2#5.3.7.3 +.3.3.3#2#6#6#6#6#9.6.6#8#6#6#6#6#3.3.3.3 ++000+000= GULAG HAS YOU diff --git a/data/txr.bmp b/data/txr.bmp index 8864f88..67972ff 100644 Binary files a/data/txr.bmp and b/data/txr.bmp differ 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