diff options
-rw-r--r-- | intermediate/rooms.bmp | bin | 2538 -> 2538 bytes | |||
-rw-r--r-- | map.c | 32 |
2 files changed, 32 insertions, 0 deletions
diff --git a/intermediate/rooms.bmp b/intermediate/rooms.bmp Binary files differindex b9562e4..a0bf456 100644 --- a/intermediate/rooms.bmp +++ b/intermediate/rooms.bmp @@ -147,6 +147,37 @@ void generate_doors(Map* m) { #undef check #undef place +void generate_enemies(const Map* m, World* w) { +#define check \ + (m->collision[x + y * map_w] == 1 && \ + m->collision[x + (y - 1) * map_w] == 0) + int x, y, ex = map_w - 1, ey = map_h - 1; + for (y = 1; y < ey; y++) { + for (x = 1; x < ex; x++) { + int plat = -1; + for (; x < ex; x++) + if (check) { + plat = 0; + break; + } + if (!plat) + for (; check && x < ex; x++, plat++); + if (plat >= 3) { + Enemy* e; + int sx = x - (plat >> 1); + e = inst_enemy( + w, + enemy_demon, + (sx * map_tile_size) << fbits, + ((y - 1) * map_tile_size) << fbits + ); + e->face = get_r() & 1; + } + for (; check && x < ex; x++); + } + } +} + void generate_floor(Map* m, World* w) { Player* p = &w->player; generate_room(m); @@ -154,6 +185,7 @@ void generate_floor(Map* m, World* w) { generate_doors(m); generate_floors(m); generate_collision(m); + generate_enemies(m, w); p->x = (map_w >> 1) << fbits; p->y = (map_h - 2) << fbits; p->x *= map_tile_size; |