Fix enemies appear in walls

This commit is contained in:
grisel-davy 2020-05-09 01:29:23 -04:00
parent d1e3187a12
commit 5a6d1ae458

View file

@ -76,14 +76,14 @@ def enemy_placement(carte):
for room in carte[1:]:
retry = 0
while len(positions) < 3 and retry < 20:
posx = room[2][0] + randint(padding_h, room_side-padding_h)
posy = room[2][1] + randint(padding_v, room_side-padding_v)
posx = randint(padding_h, room_side-padding_h)
posy = randint(padding_v, room_side-padding_v)
if room[1].overlap(enemy_mask, (posx-enemy_center[0],posy-enemy_center[1])):
retry+=1
else:
#print(f'New enemy at {posx,posy}')
positions.append((posx,posy))
positions.append((room[2][0] + posx,room[2][1] + posy))
carte_positions.append(positions)
positions = []