Skip to content

Commit 4f73f51

Browse files
committed
added sfx when big mario is damaged and fixed 2 bugs
1 parent 326dd86 commit 4f73f51

File tree

5 files changed

+4
-40
lines changed

5 files changed

+4
-40
lines changed

classes/Sound.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(self):
2020
self.brick_bump = mixer.Sound("./sfx/brick-bump.ogg")
2121
self.powerup = mixer.Sound('./sfx/powerup.ogg')
2222
self.powerup_appear = mixer.Sound('./sfx/powerup_appears.ogg')
23+
self.pipe = mixer.Sound('./sfx/pipe.ogg')
2324

2425
def play_sfx(self, sfx):
2526
if self.allowSFX:

entities/Koopa.py

-29
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ def update(self, camera):
3838
self.checkEntityCollision()
3939
elif self.alive == "shellBouncing":
4040
self.shellBouncing(camera)
41-
elif self.alive is False:
42-
self.die(camera)
4341

4442
def drawKoopa(self, camera):
4543
if self.leftrightTrait.direction == -1:
@@ -59,33 +57,6 @@ def shellBouncing(self, camera):
5957
self.drawKoopa(camera)
6058
self.leftrightTrait.update()
6159

62-
def die(self, camera):
63-
if self.timer == 0:
64-
self.textPos = Vec2D(self.rect.x + 3, self.rect.y - 32)
65-
if self.timer < self.timeAfterDeath:
66-
self.textPos.y += -0.5
67-
self.textPos = Vec2D(self.rect.x + 3, self.rect.y - 32)
68-
self.dashboard.drawText("100", self.textPos.x + camera.x, self.textPos.y, 8)
69-
self.vel.y -= 0.5
70-
self.rect.y += self.vel.y
71-
self.screen.blit(
72-
self.spriteCollection.get("koopa-hiding").image,
73-
(self.rect.x + camera.x, self.rect.y - 32),
74-
)
75-
else:
76-
self.vel.y += 0.3
77-
self.rect.y += self.vel.y
78-
self.textPos.y += -0.5
79-
self.dashboard.drawText("100", self.textPos.x + camera.x, self.textPos.y, 8)
80-
self.screen.blit(
81-
self.spriteCollection.get("koopa-hiding").image,
82-
(self.rect.x + camera.x, self.rect.y - 32),
83-
)
84-
if self.timer > 500:
85-
# delete entity
86-
self.alive = None
87-
self.timer += 6
88-
8960
def sleepingInShell(self, camera):
9061
if self.timer < self.timeAfterDeath:
9162
self.screen.blit(

entities/Mario.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def _onCollisionWithBlock(self, block):
9999
block.triggered = True
100100

101101
def _onCollisionWithMob(self, mob, collisionState):
102-
if isinstance(mob, RedMushroom):
102+
if isinstance(mob, RedMushroom) and mob.alive:
103103
self.powerup(1)
104104
self.killEntity(mob)
105105
self.sound.play_sfx(self.sound.powerup)
@@ -133,6 +133,7 @@ def _onCollisionWithMob(self, mob, collisionState):
133133
x, y = self.rect.x, self.rect.y
134134
self.rect = pygame.Rect(x, y + 32, 32, 32)
135135
self.invincibilityFrames = 60
136+
self.sound.play_sfx(self.sound.pipe)
136137

137138
def bounce(self):
138139
self.traits["bounceTrait"].jump = True

entities/Mushroom.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,4 @@ def movePointsTextUpAndDraw(self, camera):
5454
self.dashboard.drawText("100", self.textPos.x + camera.x, self.textPos.y, 8)
5555

5656
def checkEntityCollision(self):
57-
for ent in self.levelObj.entityList:
58-
collisionState = self.EntityCollider.check(ent)
59-
if collisionState.isColliding:
60-
if ent.type == "Mob":
61-
self._onCollisionWithMob(ent, collisionState)
62-
63-
def _onCollisionWithMob(self, mob, collisionState):
64-
if collisionState.isColliding and mob.alive == "shellBouncing":
65-
self.alive = False
66-
self.sound.play_sfx(self.sound.brick_bump)
57+
pass

sfx/pipe.ogg

10.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)