Skip to content

Commit

Permalink
Bugfix: Hitting open chest still spawned loot
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwhitworth committed Jul 20, 2022
1 parent 22ae52b commit 00bcfab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions DungeonGame/treasure_chest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, name, position, sprite_groups, health):

self.health = health
self.visible_sprites = sprite_groups[0]
self.openned = False

#ROLL FOR LOOT TYPE TO SPAWN
self.contents = random.randrange(0,2)
Expand Down Expand Up @@ -51,14 +52,15 @@ def check_alive(self):
"""
IF HEALTH < 0: CHANGE SPRITE TO OPEN CHEST AND SPAWN LOOT BELOW CHEST
"""
if self.health <= 0:
if self.health <= 0 and not self.openned:
self.load_image("treasure_chest/open.png")
Treasure_Gem(
name = self.treasures[self.contents], #ART CREDIT https://pixel-boy.itch.io/ninja-adventure-asset-pack
position = (self.rect.x, self.rect.y+20),
sprite_groups = [self.visible_sprites]
)
pg.mixer.Sound.play(sound_bonus)
Treasure_Gem(
name = self.treasures[self.contents], #ART CREDIT https://pixel-boy.itch.io/ninja-adventure-asset-pack
position = (self.rect.x, self.rect.y+20),
sprite_groups = [self.visible_sprites]
)
pg.mixer.Sound.play(sound_bonus)
self.openned = True

def get_info(self):
data = {
Expand Down
Binary file modified Python_Dungeon_Game_JW.exe
Binary file not shown.

0 comments on commit 00bcfab

Please sign in to comment.