Correct formulas for random enumeration of a grid

This commit is contained in:
Charles Peyrat 2021-01-08 05:21:31 +01:00
parent 49e261557c
commit 20cbf546f9
1 changed files with 2 additions and 2 deletions

View File

@ -90,7 +90,7 @@ class Generator:
yxs = [i for i in range(len(room) * len(room[0]))]
shuffle(yxs)
for pos in yxs:
y, x = pos // len(room), pos % len(room)
y, x = pos // len(room[0]), pos % len(room[0])
if room[y][x] == Tile.EMPTY:
if room[y-dy][x-dx] == Tile.FLOOR:
build_here = True
@ -160,7 +160,7 @@ class Generator:
positions = [i for i in range()]
shuffle(positions)
for pos in positions:
y, x = pos // height, pos % width
y, x = pos // width, pos % width
if self.room_fits(level, y, x, room, door_y, door_x, dy, dx):
self.place_room(level, y, x, door_y, door_x, room)