modified the way alien rows are deleted to make them more stable

This commit is contained in:
EggMan 2024-04-29 16:12:16 -04:00
parent b10f67e0af
commit 6c011f11a7

19
Main.py
View File

@ -281,6 +281,18 @@ class MyGame(arcade.Window):
if self.alienCounterY < 0: if self.alienCounterY < 0:
# Reset the X and Y counter variables # Reset the X and Y counter variables
self.alienCounterY = len(self.aliens) - 1 self.alienCounterY = len(self.aliens) - 1
if self.alienCounterY < 0:
# Reset the X and Y counter variables
self.alienCounterY = len(self.aliens) - 1
if self.alienCounterY < 0:
# Reset the X and Y counter variables
self.alienCounterY = len(self.aliens) - 1
if self.alienCounterY < 0:
# Reset the X and Y counter variables
self.alienCounterY = len(self.aliens) - 1
if self.alienCounterY < 0:
# Reset the X and Y counter variables
self.alienCounterY = len(self.aliens) - 1
self.alienCounterX = 0 self.alienCounterX = 0
# Alien Movement # Alien Movement
if self.Won == False: if self.Won == False:
@ -344,7 +356,7 @@ class MyGame(arcade.Window):
self.alienChangeDir = 0 self.alienChangeDir = 0
# if DEBUG: # if DEBUG:
# print(e) # print(e)
if len(self.aliens) == 0: if len(self.aliens) < 1 :
self.Won = True self.Won = True
# except Exception as e: # except Exception as e:
# if DEBUG: # if DEBUG:
@ -353,8 +365,9 @@ class MyGame(arcade.Window):
print("You Won!") print("You Won!")
sys.exit() sys.exit()
# Check to see if any aliens are colliding with a player's bullet # Check to see if any aliens are colliding with a player's bullet
for alienRow in self.aliens: for index, alienRow in enumerate(self.aliens):
if alienRow == []: length = len(self.aliens)
if alienRow == [] and index == length - 1 and length > 0:
self.aliens.remove(alienRow) self.aliens.remove(alienRow)
for alien in alienRow: for alien in alienRow:
try: try: