]> git.lizzy.rs Git - dungeon_game.git/commitdiff
Tweak dungeon room generation
authorElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 10 Jun 2021 20:00:42 +0000 (22:00 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 10 Jun 2021 20:00:42 +0000 (22:00 +0200)
plugins/game/game.c

index b87d5b4c4f8707fe8f3309316a9ccee5f0011a55..40bfa51121da41e844ddc9cfad7f21f76389f2e5 100644 (file)
@@ -250,14 +250,6 @@ static void player_damage(struct entity *self, int damage)
 
 /* Mapgen */
 
-static bool check_direction(int x, int y, enum direction dir)
-{
-       if (dir % 2 == 0)
-               return is_solid(x + 1, y) && is_solid(x - 1, y) && (is_solid(x, y + 1) || rand() % 3 > 1) && (is_solid(x, y - 1) || rand() % 3 > 1);
-       else
-               return is_solid(x, y + 1) && is_solid(x, y - 1) && (is_solid(x + 1, y) || rand() % 3 > 1) && (is_solid(x - 1, y) || rand() % 3 > 1);
-}
-
 static void mapgen_set_air(int x, int y)
 {
        if (is_outside(x, y))
@@ -275,8 +267,8 @@ static void mapgen_set_air(int x, int y)
 
 static void generate_room(int origin_x, int origin_y)
 {
-       int left = 5 + rand() % 15;
-       int right = 5 + rand() % 15;
+       int left = 5 + rand() % 10;
+       int right = 5 + rand() % 10;
 
        int up = 0;
        int down = 0;
@@ -295,6 +287,14 @@ static void generate_room(int origin_x, int origin_y)
        }
 }
 
+static bool check_direction(int x, int y, enum direction dir)
+{
+       if (dir % 2 == 0)
+               return is_solid(x + 1, y) && is_solid(x - 1, y) && (is_solid(x, y + 1) || rand() % 3 > 1) && (is_solid(x, y - 1) || rand() % 3 > 1);
+       else
+               return is_solid(x, y + 1) && is_solid(x, y - 1) && (is_solid(x + 1, y) || rand() % 3 > 1) && (is_solid(x - 1, y) || rand() % 3 > 1);
+}
+
 static void generate_corridor(int lx, int ly, enum direction ldir)
 {
        if (is_outside(lx, ly))