Skip to content

Commit 423428b

Browse files
committed
Update Pac-Man
1 parent f98ec73 commit 423428b

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed
36 Bytes
Binary file not shown.
134 Bytes
Binary file not shown.

Pac-Man/app_class.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,16 @@ def playing_draw(self):
155155
self.screen.fill(BLACK)
156156
self.screen.blit(self.background, (TOP_BOTTOM_BUFFER//2, TOP_BOTTOM_BUFFER//2))
157157
self.draw_coins()
158-
self.draw_text('CURRENT SCORE: {}'.format(self.player.current_score),
159-
self.screen, [60, 0], 18, WHITE, START_FONT)
160-
self.draw_text('HIGH SCORE: 0', self.screen, [WIDTH//2+60, 0], 18, WHITE, START_FONT)
158+
self.draw_text(f'CURRENT SCORE: {self.player.current_score}',self.screen, [60, 0], 18, WHITE, START_FONT)
159+
self.draw_text(f'HIGH SCORE: {self.player.high_score}', self.screen, [WIDTH//2+60, 0], 18, WHITE, START_FONT)
161160
self.player.draw()
162161
for enemy in self.enemies:
163162
enemy.draw()
164163
pygame.display.update()
165164

166165
def remove_life(self):
167166
self.player.lives -= 1
167+
self.player.current_score=0
168168
if self.player.lives == 0:
169169
self.state = "game over"
170170
winsound.PlaySound("Python-Projects\Pac-Man\death.wav", winsound.SND_ALIAS)

Pac-Man/player_class.py

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def __init__(self, app, pos):
1313
self.stored_direction = None
1414
self.able_to_move = True
1515
self.current_score = 0
16+
self.high_score = 0
1617
self.speed = 2
1718
self.lives = 1
1819

@@ -52,6 +53,8 @@ def eat_coin(self):
5253
self.app.coins.remove(self.grid_pos)
5354
winsound.PlaySound("Python-Projects\Pac-Man\chomp.wav", winsound.SND_ASYNC)
5455
self.current_score += 1
56+
if self.high_score<self.current_score:
57+
self.high_score=self.current_score
5558

5659
def move(self, direction):
5760
self.stored_direction = direction

0 commit comments

Comments
 (0)