Skip to content

Commit

Permalink
added sfx when big mario is damaged and fixed 2 bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mx0c committed Nov 2, 2020
1 parent 326dd86 commit 4f73f51
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 40 deletions.
1 change: 1 addition & 0 deletions classes/Sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self):
self.brick_bump = mixer.Sound("./sfx/brick-bump.ogg")
self.powerup = mixer.Sound('./sfx/powerup.ogg')
self.powerup_appear = mixer.Sound('./sfx/powerup_appears.ogg')
self.pipe = mixer.Sound('./sfx/pipe.ogg')

def play_sfx(self, sfx):
if self.allowSFX:
Expand Down
29 changes: 0 additions & 29 deletions entities/Koopa.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ def update(self, camera):
self.checkEntityCollision()
elif self.alive == "shellBouncing":
self.shellBouncing(camera)
elif self.alive is False:
self.die(camera)

def drawKoopa(self, camera):
if self.leftrightTrait.direction == -1:
Expand All @@ -59,33 +57,6 @@ def shellBouncing(self, camera):
self.drawKoopa(camera)
self.leftrightTrait.update()

def die(self, camera):
if self.timer == 0:
self.textPos = Vec2D(self.rect.x + 3, self.rect.y - 32)
if self.timer < self.timeAfterDeath:
self.textPos.y += -0.5
self.textPos = Vec2D(self.rect.x + 3, self.rect.y - 32)
self.dashboard.drawText("100", self.textPos.x + camera.x, self.textPos.y, 8)
self.vel.y -= 0.5
self.rect.y += self.vel.y
self.screen.blit(
self.spriteCollection.get("koopa-hiding").image,
(self.rect.x + camera.x, self.rect.y - 32),
)
else:
self.vel.y += 0.3
self.rect.y += self.vel.y
self.textPos.y += -0.5
self.dashboard.drawText("100", self.textPos.x + camera.x, self.textPos.y, 8)
self.screen.blit(
self.spriteCollection.get("koopa-hiding").image,
(self.rect.x + camera.x, self.rect.y - 32),
)
if self.timer > 500:
# delete entity
self.alive = None
self.timer += 6

def sleepingInShell(self, camera):
if self.timer < self.timeAfterDeath:
self.screen.blit(
Expand Down
3 changes: 2 additions & 1 deletion entities/Mario.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _onCollisionWithBlock(self, block):
block.triggered = True

def _onCollisionWithMob(self, mob, collisionState):
if isinstance(mob, RedMushroom):
if isinstance(mob, RedMushroom) and mob.alive:
self.powerup(1)
self.killEntity(mob)
self.sound.play_sfx(self.sound.powerup)
Expand Down Expand Up @@ -133,6 +133,7 @@ def _onCollisionWithMob(self, mob, collisionState):
x, y = self.rect.x, self.rect.y
self.rect = pygame.Rect(x, y + 32, 32, 32)
self.invincibilityFrames = 60
self.sound.play_sfx(self.sound.pipe)

def bounce(self):
self.traits["bounceTrait"].jump = True
Expand Down
11 changes: 1 addition & 10 deletions entities/Mushroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,4 @@ def movePointsTextUpAndDraw(self, camera):
self.dashboard.drawText("100", self.textPos.x + camera.x, self.textPos.y, 8)

def checkEntityCollision(self):
for ent in self.levelObj.entityList:
collisionState = self.EntityCollider.check(ent)
if collisionState.isColliding:
if ent.type == "Mob":
self._onCollisionWithMob(ent, collisionState)

def _onCollisionWithMob(self, mob, collisionState):
if collisionState.isColliding and mob.alive == "shellBouncing":
self.alive = False
self.sound.play_sfx(self.sound.brick_bump)
pass
Binary file added sfx/pipe.ogg
Binary file not shown.

0 comments on commit 4f73f51

Please sign in to comment.