Add prototype for create_random_room; change return value of attach_doors and create_circular_room so we have info on door direction; minor syntax change
This commit is contained in:
		@@ -69,8 +69,8 @@ class Generator:
 | 
			
		||||
 | 
			
		||||
        yxs = [i for i in range(len(room) * len(room[0]))]
 | 
			
		||||
        shuffle(xys)
 | 
			
		||||
        for POS in yxs:
 | 
			
		||||
            y, x = POS // len(room), POS % len(room)
 | 
			
		||||
        for pos in yxs:
 | 
			
		||||
            y, x = pos // len(room), pos % len(room)
 | 
			
		||||
            if room[y][x] == Tile.EMPTY:
 | 
			
		||||
                if room[y-dy][x-dx] == Tile.FLOOR:
 | 
			
		||||
                    build_here = True
 | 
			
		||||
@@ -82,7 +82,7 @@ class Generator:
 | 
			
		||||
                        for i in range(l):
 | 
			
		||||
                            room[y+i*dy][x+i*dx] == Tile.FLOOR
 | 
			
		||||
                        break
 | 
			
		||||
        return y+l*dy, x+l*dx
 | 
			
		||||
        return y+l*dy, x+l*dx, dy, dx
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def create_circular_room(self):
 | 
			
		||||
@@ -110,10 +110,13 @@ class Generator:
 | 
			
		||||
                else:
 | 
			
		||||
                    room[-1].append(Tile.EMPTY)
 | 
			
		||||
 | 
			
		||||
        door_y, door_x = self.attach_doors(room, h_sup, w_sup, h_off, w_off)
 | 
			
		||||
        door_y, door_x, dy, dx = self.attach_doors(room, h_sup, w_sup, h_off, w_off)
 | 
			
		||||
 | 
			
		||||
        return room, doory, doorx
 | 
			
		||||
        return room, doory, doorx, dy, dx
 | 
			
		||||
 | 
			
		||||
    def create_random_room(self):
 | 
			
		||||
        return create_circular_room(self)
 | 
			
		||||
    
 | 
			
		||||
    def run(self):
 | 
			
		||||
        height, width = self.params["height"], self.params["width"]
 | 
			
		||||
        level = [[Tile.EMPTY for i in range(width)] for j in range(height)]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user