Fix formulas in place_room and room_fits

This commit is contained in:
Charles Peyrat 2021-01-08 05:14:32 +01:00
parent 05ccd0e339
commit abbad0f352
1 changed files with 4 additions and 4 deletions

View File

@ -36,8 +36,8 @@ class Generator:
rh, rw = len(room), len(room[0]) rh, rw = len(room), len(room[0])
for ry in range(rh): for ry in range(rh):
for rx in range(rw): for rx in range(rw):
if room[y][x] == Tile.FLOOR: if room[ry][rx] == Tile.FLOOR:
ly, lx = ry - door_y, rx - door_x ly, lx = y + ry - door_y, x + rx - door_x
if not(0 <= ly <= rh and 0 <= lx <= rw) or \ if not(0 <= ly <= rh and 0 <= lx <= rw) or \
level[ly][lx] == Tile.FLOOR: level[ly][lx] == Tile.FLOOR:
return False return False
@ -50,8 +50,8 @@ class Generator:
level[door_y][door_x] = Tile.FLOOR level[door_y][door_x] = Tile.FLOOR
for ry in range(rh): for ry in range(rh):
for rx in range(rw): for rx in range(rw):
if room[y][x] == Tile.FLOOR: if room[ry][rx] == Tile.FLOOR:
level[y-door_y][y-door_x] = Tile.FLOOR level[y-door_y+ry][y-door_x+rx] = Tile.FLOOR
@staticmethod @staticmethod
def place_walls(level): def place_walls(level):