made lose con work

This commit is contained in:
eggman20339 2024-05-05 21:20:21 -04:00
parent 34535c1bd5
commit 65d51b66b4
2 changed files with 21 additions and 22 deletions

View File

@ -5,7 +5,7 @@
<excludeFolder url="file://$MODULE_DIR$/.venv" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.11 (CNSA-266-FP)" jdkType="Python SDK" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

41
Main.py
View File

@ -21,7 +21,7 @@ SCREEN_TITLE = "Space Invaders"
PLAYER_SPEED = 1
PLAYER_BOUNDS = 32
ALIEN_BOUNDS = 16
ALIEN_BOUNDS = 32
@ -56,6 +56,7 @@ class MyGame(arcade.Window):
self.current_texture_index = 0
self.player_sprite = None
self.level = 0
self.movePlayer = 0
if DEBUG:
@ -82,7 +83,6 @@ class MyGame(arcade.Window):
self.player_list = arcade.SpriteList()
self.wall_list = arcade.SpriteList(use_spatial_hash=True)
self.rend = 0
self.level = 0
self.score = None
# self.overlay_color = (0,255,0,128)
self.player_sprite_death = None
@ -96,6 +96,7 @@ class MyGame(arcade.Window):
self.player_sprite.center_y = (32 + 4) * SCREEN_SCALE
self.player_list.append(self.player_sprite)
self.level += 1
# Create Left Boundry
if DEBUG == True:
@ -236,17 +237,28 @@ class MyGame(arcade.Window):
self.respawn()
else:
if DEBUG:
print(str(self.Score))
print("\n" * 100)
print("You scored: " + str(self.Score))
print("You died on level: " + str(self.level))
sys.exit()
def update(self, delta_time):
if True:
# Picking numbers to possibly spawn an alien bullet
testx = random.randint(0, 5 + 100 - self.level)
testy = random.randint(0, 11 + 100 - self.level)
testx = random.randint(0, 5 + 100 - self.level * 5)
testy = random.randint(0, 11 + 100 - self.level * 5)
testx = 500
testy = 500
if self.alienCounterY < 0:
# Reset the X and Y counter variables
self.alienCounterY = len(self.aliens) - 1
self.alienCounterX = 0
# Checking if player bullet is off-screen, if so, set bullet to None, else, update bullet
try:
@ -264,6 +276,9 @@ class MyGame(arcade.Window):
for alienx in self.aliens:
for alien in alienx:
try:
if alien.getY() - 8 * SCREEN_SCALE < self.player_sprite.center_y:
self.lives = 0
self.death()
alien.bullet.update()
except Exception as e:
pass
@ -284,22 +299,6 @@ class MyGame(arcade.Window):
except Exception as e:
pass
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
if self.alienCounterY < 0:
# Reset the X and Y counter variables
self.alienCounterY = len(self.aliens) - 1
self.alienCounterX = 0
# Alien Movement
if self.Won == False:
#Left - Right Movement