diff --git a/games/bgm/bubble_bobble.mp3 b/games/bgm/bubble_bobble.mp3 new file mode 100644 index 0000000..898dec4 Binary files /dev/null and b/games/bgm/bubble_bobble.mp3 differ diff --git a/games/bgm/game_over.wav b/games/bgm/game_over.wav new file mode 100644 index 0000000..deb6987 Binary files /dev/null and b/games/bgm/game_over.wav differ diff --git a/games/bgm/pingpongbat.wav b/games/bgm/pingpongbat.wav new file mode 100644 index 0000000..c430dde Binary files /dev/null and b/games/bgm/pingpongbat.wav differ diff --git a/games/pong.py b/games/pong.py index 6667806..89099d6 100644 --- a/games/pong.py +++ b/games/pong.py @@ -29,6 +29,15 @@ pygame.init() +pygame.mixer.init() +pygame.mixer.music.load("bgm/bubble_bobble.mp3") # 게임 bgm +pygame.mixer.music.set_volume(0.3) # volume 조절 1 ~ 0.1 +pygame.mixer.music.play(-1) + +game_over = pygame.mixer.Sound("bgm/game_over.wav") # 종료 bgm +pingpong = pygame.mixer.Sound("bgm/pingpongbat.wav") # 게임 효과음 + + screen = pygame.display.set_mode((640,480),0,32) #Creating 2 bars, a ball and background. @@ -167,10 +176,14 @@ def paused(): if circle_y >= bar1_y - 7.5 and circle_y <= bar1_y + 42.5: circle_x = 20. speed_x = -speed_x + pygame.mixer.Sound.play(pingpong) + if circle_x >= bar2_x - 15.: if circle_y >= bar2_y - 7.5 and circle_y <= bar2_y + 42.5: circle_x = 605. speed_x = -speed_x + pygame.mixer.Sound.play(pingpong) + if circle_x < 5.: bar2_score += 1 circle_x, circle_y = 320., 232.5 @@ -182,9 +195,28 @@ def paused(): if circle_y <= 10.: speed_y = -speed_y circle_y = 10. + pygame.mixer.Sound.play(pingpong) + elif circle_y >= 457.5: speed_y = -speed_y circle_y = 457.5 + pygame.mixer.Sound.play(pingpong) + + if bar2_score == 10: # ai가 10점 달성시 종료 bgm + pygame.mixer.music.stop() + pygame.mixer.Sound.play(game_over) + game_over.set_volume(0.3) + # 게임 오버 메시지 + msg = font.render("Game Over", True, (255, 255, 0)) + screen.blit(msg, (230,260)) + pygame.display.update() + + # 4초 대기후 나가기 + pygame.time.delay(4000) + pygame.quit() + exit() + + pygame.display.update() diff --git a/games/rank.db b/games/rank.db new file mode 100644 index 0000000..e68ee08 Binary files /dev/null and b/games/rank.db differ