diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2021-03-02 12:10:42 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2021-03-02 12:10:42 +0300 |
commit | 51415eee3deaed9e0440855735de6f98a107438c (patch) | |
tree | 31d5392d0022173a0fa96ba0445a4e48537110a6 /src/map.c | |
parent | cb2b1a0a64ab44a17b67c480f277bbac71ae4fdc (diff) | |
download | takethis-51415eee3deaed9e0440855735de6f98a107438c.tar takethis-51415eee3deaed9e0440855735de6f98a107438c.tar.xz takethis-51415eee3deaed9e0440855735de6f98a107438c.zip |
Save on F5, Load on F6!
Diffstat (limited to 'src/map.c')
-rw-r--r-- | src/map.c | 77 |
1 files changed, 39 insertions, 38 deletions
@@ -28,32 +28,6 @@ static SDL_Rect *newtile(int row, int col) return r; } -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(grib, -1); - b->collision_act = do_nothing; - b->anim = 1; - b->txrrow = 0; - b->txrcol = 15; - b->msg = 0; - b->msglen = 0; - ttplayer.variant = 1; - magic = tt_gotofirstroom; -} static void loadroom(tt_room *r, FILE *f) { @@ -84,8 +58,8 @@ static void loadroom(tt_room *r, FILE *f) ttplayer.ywalk = 0; ttplayer.rem = 0; ttplayer.money = 0; - ttplayer.keys = 0; - ttplayer.the_key = 0; + ttplayer.keys[0] = 0; + ttplayer.keys[1] = 0; ttplayer.lenin_pos = 32 * 9; ttplayer.lenin_pos_rem = 0; ttplayer.zhiv_lenin = 0; @@ -109,7 +83,7 @@ static void loadroom(tt_room *r, FILE *f) b->txrcol = id; b->anim = 1; b->rate = 1; - b->collision_act = do_nothing; + b->collision_act = 0; b->msg = 0; b->msglen = 0; } else if (type == 'b') { @@ -126,7 +100,7 @@ static void loadroom(tt_room *r, FILE *f) b->txrcol = id; b->anim = 1; b->rate = 1; - b->collision_act = do_nothing; + b->collision_act = 0; b->msg = 0; b->msglen = 0; } else if (type == 'r') { @@ -143,7 +117,7 @@ static void loadroom(tt_room *r, FILE *f) b->txrcol = id; b->anim = 1; b->rate = 1; - b->collision_act = do_nothing; + b->collision_act = 0; b->msg = 0; b->msglen = 0; } else if (type == 'g') { @@ -163,7 +137,7 @@ static void loadroom(tt_room *r, FILE *f) b->txrcol = id; b->anim = 4; b->rate = 150 + (rand() % 50 - 25); - b->collision_act = gribtake; + b->collision_act = colact_grib; b->msg = 0; b->msglen = 0; } else if (type == '^') { @@ -181,7 +155,7 @@ static void loadroom(tt_room *r, FILE *f) b->txrcol = id; b->anim = 4; b->rate = 150 + (rand() % 50 - 25); - b->collision_act = do_nothing; + b->collision_act = 0; b->msg = 0; b->msglen = 0; } else if (type == ';') { @@ -199,7 +173,7 @@ static void loadroom(tt_room *r, FILE *f) b->txrcol = id; b->anim = 1; b->rate = 100; - b->collision_act = do_nothing; + b->collision_act = 0; b->msg = 0; b->msglen = 0; } else if (type == '.') { @@ -218,7 +192,7 @@ static void loadroom(tt_room *r, FILE *f) b->txrcol = id; b->anim = 4; b->rate = 150 + (rand() % 50 - 25); - b->collision_act = do_nothing; + b->collision_act = 0; b->msg = 0; b->msglen = 0; } else if (type == '=') { @@ -236,7 +210,7 @@ static void loadroom(tt_room *r, FILE *f) b->txrcol = 15; b->anim = 1; b->rate = 100; - b->collision_act = do_nothing; + b->collision_act = 0; } else if (type == '$') { r->floor[i][j] = newtile(0, default_floor_id); r->bodies_count++; @@ -252,7 +226,7 @@ static void loadroom(tt_room *r, FILE *f) b->txrcol = id; b->anim = 4; b->rate = 100 + (rand() % 50 - 25); - b->collision_act = togulag; + b->collision_act = colact_gulag; } } fgetc(f); @@ -286,6 +260,21 @@ void tt_map_load() if (roomf) { loadroom(ttmap + r, roomf); fclose(roomf); + } else { + int m = r; + int i, j; + for (i = 0; i != TT_ROOM_H; ++i) { + for (j = 0; j != TT_ROOM_W; ++j) { + ttmap[m].floor[i][j] = 0; + ttmap[m].walls[i][j] = 0; + } + } + ttmap[m].bodies_count = 0; + ttmap[m].bodies = 0; + ttmap[m].neighbours[0] = ttmap + '.'; + ttmap[m].neighbours[1] = ttmap + '.'; + ttmap[m].neighbours[2] = ttmap + '.'; + ttmap[m].neighbours[3] = ttmap + '.'; } ++r; } @@ -294,5 +283,17 @@ void tt_map_load() void tt_map_free() { - return; + int i; + for (i = '0'; i != '~'; ++i) { + int p, q; + for (p = 0; p != TT_ROOM_H; ++p) { + for (q = 0; q != TT_ROOM_W; ++q) { + void *x = ttmap[i].floor[p][q]; + if (x) free(x); + x = ttmap[i].walls[p][q]; + if (x) free(x); + } + } + if (ttmap[i].bodies) free(ttmap[i].bodies); + } } |