COWABUNGA!

This commit is contained in:
maxneedspats 2022-08-01 16:29:45 -05:00
parent 985dc40ab1
commit bdcb1dbe55
3 changed files with 17 additions and 3 deletions

View file

@ -34,8 +34,12 @@ class Audio:
mixer.music.set_volume(0.5) mixer.music.set_volume(0.5)
@staticmethod @staticmethod
def stop_background_music(): def pause_music():
mixer.music.stop() mixer.music.pause()
@staticmethod
def unpause_background_music():
mixer.music.unpause()
@staticmethod @staticmethod
def click(): def click():

Binary file not shown.

12
main.py
View file

@ -60,7 +60,9 @@ try:
cards[i].goto(x, y) cards[i].goto(x, y)
score = 0 score = 0
matches = 0
game_is_running = True game_is_running = True
end_routine_done = False
clicked_cards = [] clicked_cards = []
def clicked_card(x, y): def clicked_card(x, y):
@ -70,7 +72,7 @@ try:
Audio.click() Audio.click()
global clicked_cards global clicked_cards
for card in cards: for card in cards:
if card.is_mouse_over(x, y): if card.is_mouse_over(x, y) and card.shape()[:10] != 'card_front':
if len(clicked_cards) == 2: if len(clicked_cards) == 2:
clicked_cards = [] clicked_cards = []
card.to_front() card.to_front()
@ -86,6 +88,13 @@ try:
while game_is_running: while game_is_running:
time.sleep(0.1) time.sleep(0.1)
if not end_routine_done:
if matches >= 8:
Audio.pause_music()
Audio.game_success()
time.sleep(3.1)
Audio.unpause_background_music()
end_routine_done = True
if len(clicked_cards) == 2: if len(clicked_cards) == 2:
if clicked_cards[0] != clicked_cards[1]: if clicked_cards[0] != clicked_cards[1]:
time.sleep(1) time.sleep(1)
@ -98,6 +107,7 @@ try:
score += 5 score += 5
update_score() update_score()
Audio.match_made() Audio.match_made()
matches += 1
clicked_cards = [] clicked_cards = []
screen.update() screen.update()