aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-06-10 22:00:42 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-06-10 22:00:42 +0200
commit14d315712d372932b27a118171865118a6b415c7 (patch)
tree49cd20d3712b3ce134190efe1b48c10332ba98c9
parent9546c8c8afe2fb710b12222a77273f879f90c6da (diff)
downloaddungeon_game-14d315712d372932b27a118171865118a6b415c7.tar.xz
Tweak dungeon room generation
-rw-r--r--plugins/game/game.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/plugins/game/game.c b/plugins/game/game.c
index b87d5b4..40bfa51 100644
--- a/plugins/game/game.c
+++ b/plugins/game/game.c
@@ -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))