git.fiddlerwoaroof.com
Browse code

fixing negative indexes

Ed L authored on 26/07/2012 21:35:58
Showing 1 changed files
... ...
@@ -151,6 +151,7 @@ class MazeGen(AutomataEngine):
151 151
 
152 152
 			cx, cy = point
153 153
 			lx, ty = cx-left_offset, cy-up_offset
154
+
154 155
 			if lx < 0:
155 156
 				max_width += lx
156 157
 				lx = 0
... ...
@@ -160,10 +161,11 @@ class MazeGen(AutomataEngine):
160 161
 			w, h = random.randrange(1,max_width+1), random.randrange(1, max_height+1)
161 162
 
162 163
 			if lx + w >= self.width:
163
-				lx -= (lx+w) - self.width
164
+				w -= (lx+w) - self.width
164 165
 			if ty + h >= self.height:
165
-				ty -= (ty+h) - self.height
166
+				h -= (ty+h) - self.height
166 167
 
168
+			print '(',lx,ty, ')', w, h
167 169
 			room = Rect(lx,ty, w,h)
168 170
 			success = True
169 171
 			for o_room in self.rooms: