got respawning working a bit

This commit is contained in:
EggMan 2024-04-29 15:55:10 -04:00
parent 262df318f3
commit b10f67e0af

40
Main.py
View File

@ -76,7 +76,7 @@ class MyGame(arcade.Window):
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.lives = 3 self.lives = 3
self.level = 0 self.level = 50
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
@ -162,19 +162,19 @@ class MyGame(arcade.Window):
elif key == arcade.key.RIGHT and self.movePlayer == PLAYER_SPEED * SCREEN_SCALE: elif key == arcade.key.RIGHT and self.movePlayer == PLAYER_SPEED * SCREEN_SCALE:
self.movePlayer = 0 self.movePlayer = 0
def load_death_animation(self): # def load_death_animation(self):
self.death_textures = [] # self.death_textures = []
for i in range(0,5): # for i in range(0,5):
#
texture = arcade.load_texture("assets/Sprites/Player/PlayerDeath1.png") # texture = arcade.load_texture("assets/Sprites/Player/PlayerDeath1.png")
self.death_textures.append(texture) # self.death_textures.append(texture)
texture = arcade.load_texture("assets/Sprites/Player/PlayerDeath2.png") # texture = arcade.load_texture("assets/Sprites/Player/PlayerDeath2.png")
self.death_textures.append(texture) # self.death_textures.append(texture)
#
def play_death_animation(self): # def play_death_animation(self):
if self.current_texture_index < len(self.death_textures): # if self.current_texture_index < len(self.death_textures):
self.player_sprite.set_texture(self.current_texture_index) # self.player_sprite.set_texture(self.current_texture_index)
self.current_texture_index += 1 # self.current_texture_index += 1
def on_draw(self): def on_draw(self):
self.clear() self.clear()
@ -217,16 +217,16 @@ class MyGame(arcade.Window):
self.activeBullet = False self.activeBullet = False
def respawn(self): def respawn(self):
# for alienRow in self.aliens: for alienRow in self.aliens:
# for alien in alienRow: for alien in alienRow:
# alien.bullet = None alien.bullet = None
self.player_sprite.center_x = 32*SCREEN_SCALE self.player_sprite.center_x = 32*SCREEN_SCALE
time.sleep(2) time.sleep(2)
def death(self): def death(self):
if self.lives > 0: if self.lives > 0:
self.somethingalsi = False self.somethingalsi = False
self.load_death_animation() # self.load_death_animation()
self.play_death_animation() # self.play_death_animation()
self.respawn() self.respawn()
else: else:
if DEBUG: if DEBUG:
@ -236,7 +236,7 @@ class MyGame(arcade.Window):
def update(self, delta_time): def update(self, delta_time):
if self.somethingalsi: 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)
testy = random.randint(0, 11 + 100 - self.level) testy = random.randint(0, 11 + 100 - self.level)