made lose con work
This commit is contained in:
parent
34535c1bd5
commit
65d51b66b4
@ -5,7 +5,7 @@
|
|||||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.11 (CNSA-266-FP)" jdkType="Python SDK" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
41
Main.py
41
Main.py
@ -21,7 +21,7 @@ SCREEN_TITLE = "Space Invaders"
|
|||||||
PLAYER_SPEED = 1
|
PLAYER_SPEED = 1
|
||||||
|
|
||||||
PLAYER_BOUNDS = 32
|
PLAYER_BOUNDS = 32
|
||||||
ALIEN_BOUNDS = 16
|
ALIEN_BOUNDS = 32
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -56,6 +56,7 @@ class MyGame(arcade.Window):
|
|||||||
self.current_texture_index = 0
|
self.current_texture_index = 0
|
||||||
|
|
||||||
self.player_sprite = None
|
self.player_sprite = None
|
||||||
|
self.level = 0
|
||||||
|
|
||||||
self.movePlayer = 0
|
self.movePlayer = 0
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
@ -82,7 +83,6 @@ class MyGame(arcade.Window):
|
|||||||
self.player_list = arcade.SpriteList()
|
self.player_list = arcade.SpriteList()
|
||||||
self.wall_list = arcade.SpriteList(use_spatial_hash=True)
|
self.wall_list = arcade.SpriteList(use_spatial_hash=True)
|
||||||
self.rend = 0
|
self.rend = 0
|
||||||
self.level = 0
|
|
||||||
self.score = None
|
self.score = None
|
||||||
# self.overlay_color = (0,255,0,128)
|
# self.overlay_color = (0,255,0,128)
|
||||||
self.player_sprite_death = None
|
self.player_sprite_death = None
|
||||||
@ -96,6 +96,7 @@ class MyGame(arcade.Window):
|
|||||||
self.player_sprite.center_y = (32 + 4) * SCREEN_SCALE
|
self.player_sprite.center_y = (32 + 4) * SCREEN_SCALE
|
||||||
self.player_list.append(self.player_sprite)
|
self.player_list.append(self.player_sprite)
|
||||||
|
|
||||||
|
self.level += 1
|
||||||
|
|
||||||
# Create Left Boundry
|
# Create Left Boundry
|
||||||
if DEBUG == True:
|
if DEBUG == True:
|
||||||
@ -236,17 +237,28 @@ class MyGame(arcade.Window):
|
|||||||
self.respawn()
|
self.respawn()
|
||||||
else:
|
else:
|
||||||
if DEBUG:
|
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()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
def update(self, delta_time):
|
def update(self, delta_time):
|
||||||
|
|
||||||
|
|
||||||
if True:
|
if True:
|
||||||
# Picking numbers to possibly spawn an alien bullet
|
# Picking numbers to possibly spawn an alien bullet
|
||||||
testx = random.randint(0, 5 + 100 - self.level)
|
testx = random.randint(0, 5 + 100 - self.level * 5)
|
||||||
testy = random.randint(0, 11 + 100 - self.level)
|
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
|
# Checking if player bullet is off-screen, if so, set bullet to None, else, update bullet
|
||||||
try:
|
try:
|
||||||
@ -264,6 +276,9 @@ class MyGame(arcade.Window):
|
|||||||
for alienx in self.aliens:
|
for alienx in self.aliens:
|
||||||
for alien in alienx:
|
for alien in alienx:
|
||||||
try:
|
try:
|
||||||
|
if alien.getY() - 8 * SCREEN_SCALE < self.player_sprite.center_y:
|
||||||
|
self.lives = 0
|
||||||
|
self.death()
|
||||||
alien.bullet.update()
|
alien.bullet.update()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
@ -284,22 +299,6 @@ class MyGame(arcade.Window):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
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
|
# Alien Movement
|
||||||
if self.Won == False:
|
if self.Won == False:
|
||||||
#Left - Right Movement
|
#Left - Right Movement
|
||||||
|
Loading…
Reference in New Issue
Block a user