Fix enemies appear in walls
This commit is contained in:
parent
d1e3187a12
commit
5a6d1ae458
1 changed files with 3 additions and 3 deletions
6
utils.py
6
utils.py
|
@ -76,14 +76,14 @@ def enemy_placement(carte):
|
||||||
for room in carte[1:]:
|
for room in carte[1:]:
|
||||||
retry = 0
|
retry = 0
|
||||||
while len(positions) < 3 and retry < 20:
|
while len(positions) < 3 and retry < 20:
|
||||||
posx = room[2][0] + randint(padding_h, room_side-padding_h)
|
posx = randint(padding_h, room_side-padding_h)
|
||||||
posy = room[2][1] + randint(padding_v, room_side-padding_v)
|
posy = randint(padding_v, room_side-padding_v)
|
||||||
|
|
||||||
if room[1].overlap(enemy_mask, (posx-enemy_center[0],posy-enemy_center[1])):
|
if room[1].overlap(enemy_mask, (posx-enemy_center[0],posy-enemy_center[1])):
|
||||||
retry+=1
|
retry+=1
|
||||||
else:
|
else:
|
||||||
#print(f'New enemy at {posx,posy}')
|
#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)
|
carte_positions.append(positions)
|
||||||
positions = []
|
positions = []
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue