Revised PAUSED screen.
This commit is contained in:
1 parent
bf2ab7c883
commit
278571afcf
1 file changed
+15
-3
@@ -9,7 +9,7 @@ pygame.joystick.init()
|
|||||||
# Load and play background music
|
# Load and play background music
|
||||||
pygame.mixer.music.load("audio_music.mp3")
|
pygame.mixer.music.load("audio_music.mp3")
|
||||||
pygame.mixer.music.set_volume(0.5)
|
pygame.mixer.music.set_volume(0.5)
|
||||||
pygame.mixer.music.play(-1) # Loop forever
|
pygame.mixer.music.play(-1)
|
||||||
|
|
||||||
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
|
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
|
||||||
pygame.mouse.set_visible(False)
|
pygame.mouse.set_visible(False)
|
||||||
@@ -57,6 +57,7 @@ score = 0
|
|||||||
game_over = False
|
game_over = False
|
||||||
game_over_time = None
|
game_over_time = None
|
||||||
paused = False
|
paused = False
|
||||||
|
pause_by_controller = False
|
||||||
exploding = False
|
exploding = False
|
||||||
explode_start = None
|
explode_start = None
|
||||||
sushi_fall_speed = 5
|
sushi_fall_speed = 5
|
||||||
@@ -90,12 +91,13 @@ def draw_centered_multiline_text(lines, color=(255,255,255), line_spacing=10):
|
|||||||
y += surf.get_height() + line_spacing
|
y += surf.get_height() + line_spacing
|
||||||
|
|
||||||
def reset_game():
|
def reset_game():
|
||||||
global score, objects, game_over, cat_rect, cat_img, game_over_time, paused, exploding, explode_start, start_time, speed_increase_time, sushi_fall_speed, CAT_SIZE, cat_left, cat_right
|
global score, objects, game_over, cat_rect, cat_img, game_over_time, paused, pause_by_controller, exploding, explode_start, start_time, speed_increase_time, sushi_fall_speed, CAT_SIZE, cat_left, cat_right
|
||||||
score = 0
|
score = 0
|
||||||
objects = []
|
objects = []
|
||||||
game_over = False
|
game_over = False
|
||||||
game_over_time = None
|
game_over_time = None
|
||||||
paused = False
|
paused = False
|
||||||
|
pause_by_controller = False
|
||||||
exploding = False
|
exploding = False
|
||||||
explode_start = None
|
explode_start = None
|
||||||
CAT_SIZE = [160, 160]
|
CAT_SIZE = [160, 160]
|
||||||
@@ -134,6 +136,7 @@ while True:
|
|||||||
if event.key == pygame.K_ESCAPE:
|
if event.key == pygame.K_ESCAPE:
|
||||||
if not exploding and not game_over:
|
if not exploding and not game_over:
|
||||||
paused = not paused
|
paused = not paused
|
||||||
|
pause_by_controller = False
|
||||||
if paused:
|
if paused:
|
||||||
pygame.mixer.music.pause()
|
pygame.mixer.music.pause()
|
||||||
else:
|
else:
|
||||||
@@ -147,6 +150,7 @@ while True:
|
|||||||
if event.button == 7 or event.button == 6:
|
if event.button == 7 or event.button == 6:
|
||||||
if not exploding and not game_over:
|
if not exploding and not game_over:
|
||||||
paused = not paused
|
paused = not paused
|
||||||
|
pause_by_controller = True
|
||||||
if paused:
|
if paused:
|
||||||
pygame.mixer.music.pause()
|
pygame.mixer.music.pause()
|
||||||
else:
|
else:
|
||||||
@@ -158,7 +162,15 @@ while True:
|
|||||||
reset_game()
|
reset_game()
|
||||||
|
|
||||||
if paused:
|
if paused:
|
||||||
draw_centered_text("PAUSED", (255, 255, 0))
|
draw_centered_text("PAUSED", (255, 255, 255))
|
||||||
|
small_font = pygame.font.SysFont(None, 32)
|
||||||
|
if pause_by_controller:
|
||||||
|
instruction = small_font.render("Press START to resume or X to quit.", True, (255, 255, 255))
|
||||||
|
else:
|
||||||
|
instruction = small_font.render("Press ESC to resume or Q to quit.", True, (255, 255, 255))
|
||||||
|
instr_rect = instruction.get_rect(center=(WIDTH // 2, HEIGHT // 2 + 40))
|
||||||
|
screen.blit(instruction, instr_rect)
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user