From 1539bcc057c7b6e5a58ae833e3ff1736ddb21788 Mon Sep 17 00:00:00 2001 From: kleph Date: Thu, 10 Nov 2016 19:56:53 +0100 Subject: [PATCH] Fix overflow with room max height and width --- 02_dynamic_bsp_rooms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/02_dynamic_bsp_rooms.py b/02_dynamic_bsp_rooms.py index bd18e34..729029e 100644 --- a/02_dynamic_bsp_rooms.py +++ b/02_dynamic_bsp_rooms.py @@ -10,7 +10,7 @@ import random TILE_SIZE_X = 16 TILE_SIZE_Y = 16 -MIN_LEAF_SIZE = 7 +MIN_LEAF_SIZE = 8 class Leaf: @@ -71,8 +71,8 @@ class Leaf: def generate_room(self): x = random.randint(self.x+1, self.x+2) y = random.randint(self.y+1, self.y+2) - w = random.randint(3, self.width-1) - h = random.randint(3, self.height-1) + w = random.randint(MIN_LEAF_SIZE / 2, self.width - 2) + h = random.randint(MIN_LEAF_SIZE / 2, self.height - 2) return Room(x, y, w, h, self.id) def draw(self, ground):