aboutsummaryrefslogtreecommitdiff
path: root/src/ghost.py
diff options
context:
space:
mode:
authorMoisis <moisis.george@yahoo.com>2023-05-19 23:41:23 +0300
committerGitHub <noreply@github.com>2023-05-19 23:41:23 +0300
commit271af3b2b85ac05aa8061cef0f35e7540f90b778 (patch)
treea0475e1d88be01716e76f2e75c495a4284290bb9 /src/ghost.py
parent8eeb31dba61e8c9b29704c5988f95dcba4338fca (diff)
parent6a351ed2d6a554ed6d338abba234527705d1040f (diff)
downloadMacpan-master.tar.xz
Macpan-master.zip
Merge pull request #7 from omagdy7/FinalMISOHEADmaster
Final Touches
Diffstat (limited to 'src/ghost.py')
-rw-r--r--src/ghost.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ghost.py b/src/ghost.py
index 8568ff4..37c3d37 100644
--- a/src/ghost.py
+++ b/src/ghost.py
@@ -17,7 +17,7 @@ sprite_sheet = [2, 0, 3, 1]
class Ghost():
- def __init__(self, sprite_sheet, color, x, y):
+ def __init__(self, sprite_sheet, color, x, y ,lol):
self.x = x
self.y = y
self.sprite_sheet = sprite_sheet
@@ -28,6 +28,7 @@ class Ghost():
self.speed = 3
self.timer = None
self.mode = MODE.SCATTERED
+ self.settings = lol
def in_bounds(self, pos):
(x, y) = pos
@@ -69,14 +70,19 @@ class Ghost():
return True
def check_pacman_collision(self, game_state):
+ voiceofdot2 = pygame.mixer.Channel(4)
+ dotpickup = pygame.mixer.Sound('../assets/sfx/eat_ghost.wav')
+
if game_state.pacman.powerup and abs(game_state.pacman.x - self.x) <= 30 and abs(game_state.pacman.y - self.y) <= 30:
initial_position = self.get_intial_tile()
self.mode = MODE.EATEN
self.timer = Timer(2 * 1000)
- time.sleep(1)
+ time.sleep(0.3)
game_state.score += 200
self.x = initial_position[0]
self.y = initial_position[1]
+ if self.settings.sound:
+ voiceofdot2.play(dotpickup)
elif not game_state.pacman.powerup and abs(game_state.pacman.x - self.x) <= 30 and abs(game_state.pacman.y - self.y) <= 30:
if abs(game_state.pacman.x - self.x) <= 30 and abs(game_state.pacman.y - self.y) <= 30:
game_state.is_pacman_alive = False
@@ -116,7 +122,7 @@ class Ghost():
pos = self.get_intial_tile()
self.x = pos[0]
self.y = pos[1]
- if settings.debug:
+ if self.settings.debug:
pygame.draw.line(screen, self.color, (game_state.pacman.x, game_state.pacman.y),
(self.x, self.y), 1)