Compare commits

...

23 commits

Author SHA1 Message Date
askiiart
f87e6dd836
Update README to be more clear 2022-09-22 11:00:37 -05:00
maxneedspats
c8020398a9 Updated to be more concise. 2022-08-04 17:02:03 -05:00
maxneedspats
3df378dd21 Added big turtle image when you win 2022-08-04 16:53:34 -05:00
maxneedspats
b14c6d2660 Removes card after correct match is made. 2022-08-03 18:59:31 -05:00
maxneedspats
4ed1f12107 Fixed formatting 2022-08-03 18:27:09 -05:00
ben
76a43c94b4 Added line 2022-08-02 15:09:57 -05:00
ben
d3ab01ff02 Changed formatting 2022-08-02 15:09:21 -05:00
ben
3249c2d2e9 Changed formatting 2022-08-02 15:08:56 -05:00
ben
bc04eaf0c8 Added name 2022-08-02 15:08:36 -05:00
ben
562623c713 Expanded future plans 2022-08-02 15:07:56 -05:00
ben
7bdebab0f5 Updated README again to make non-ideal behavior sound like it's not a bug (it's not) 2022-08-02 15:04:10 -05:00
ben
5b284ee2bb Updated with a "Info for users" section, and a "Technical info" section. 2022-08-02 13:37:21 -05:00
ben
32508d1738 Updated with even more info 2022-08-02 13:34:30 -05:00
ben
ab0589ddf2 Updated with more info 2022-08-02 13:29:52 -05:00
ben
01306f9ee0 Removed warning because bug is fixed 2022-08-02 13:24:07 -05:00
maxneedspats
8d147ad1df Issue fixed, but not in the ideal way. I'm working on that. 2022-08-01 21:41:21 -05:00
maxneedspats
3b266b2169 Inverted if statement 2022-08-01 20:02:15 -05:00
maxneedspats
0ca1eca5a3 Replaced game_success with tmnt Mikey saying "Cowabunga!" 2022-08-01 20:01:57 -05:00
maxneedspats
0068baa68e Updated game_success_sound comment 2022-08-01 18:36:46 -05:00
maxneedspats
4a03d31439 Added warning 2022-08-01 18:13:25 -05:00
maxneedspats
aec64b7408 Added warning 2022-08-01 18:12:52 -05:00
maxneedspats
bdcb1dbe55 COWABUNGA! 2022-08-01 16:29:45 -05:00
maxneedspats
985dc40ab1 Updated title 2022-08-01 12:35:59 -05:00
4 changed files with 63 additions and 16 deletions

View file

@ -1,5 +1,23 @@
## Memory Game
# Memory Game
### Benjamin Zimmerman
This is my final project (option 1) for ITSE-1479.
Instead of using the provided cardback.png image, I used a photo of one of my turtles as the card back.
---
Info for users:
- This is my final project (option 1) for ITSE-1479 (Intro to Scripting Languages)
- It is a memory game with a graphical interface.
- You can click on a card to flip it. Match 2 cards correctly and the cards will stay flipped. Match all cards to win.
- Scoring:
- When you make an incorrect match, you lose 1 point.
- When you make a correct match, you gain 5 points.
Technical info:
- This program is written in Python 3, using the turtle module for graphics, and the pygame module for sound and music.
- Instead of using the provided cardback.png image, I used a photo of one of my turtles as the card back.
- Notable game behavior: If you make an incorrect match, the cards will flip back over after 1 second. However, if you click on a card while the incorrect match is still face up, nothing will happen.
- Just wait until the cards flip back over.
Future plans:
- Change the game behavior to a queue of cards to flip over, 1 pair at a time.
- Expand the game to include a stopwatch.
- Expand score to include number of correct and incorrect matches.

View file

@ -25,7 +25,7 @@ class Audio:
# no_match sound is from https://freesound.org/people/distillerystudio/sounds/327738/
Audio.no_match_sound = mixer.Sound('audio/no_match.wav')
# game_success_sound is from https://freesound.org/people/jimhancock/sounds/376318/
# game_success_sound is TMNT turtle Michaelangelo saying "Cowabunga!"
Audio.game_success_sound = mixer.Sound('audio/game_success.wav')
@staticmethod
@ -34,8 +34,12 @@ class Audio:
mixer.music.set_volume(0.5)
@staticmethod
def stop_background_music():
mixer.music.stop()
def pause_music():
mixer.music.pause()
@staticmethod
def unpause_background_music():
mixer.music.unpause()
@staticmethod
def click():

Binary file not shown.

45
main.py
View file

@ -1,3 +1,5 @@
from tkinter import PhotoImage
from audio import Audio
try:
@ -16,6 +18,14 @@ try:
screen = turtle.Screen()
turtle.bgcolor('#46a38d')
screen.setup(WIDTH, HEIGHT)
screen.title('Turtle Match - Benjamin Zimmerman')
success_t = turtle.Turtle()
success_t.hideturtle()
success_t.penup()
turtle.register_shape('success_turtle', turtle.Shape('image', PhotoImage(file='images/turtle.png')))
success_t.shape('success_turtle')
success_t.goto(-379, 0)
Audio.start_audio()
Audio.play_background_music()
@ -59,21 +69,24 @@ try:
cards[i].goto(x, y)
score = 0
matches = 0
game_is_running = True
end_routine_done = False
clicked_cards = []
def clicked_card(x, y):
"""
:return: The card which was clicked
Appends the card which was clicked on to the list clicked_cards.
"""
Audio.click()
global clicked_cards
for card in cards:
if card.is_mouse_over(x, y):
if len(clicked_cards) == 2:
clicked_cards = []
return None
for card in cards:
if card.is_mouse_over(x, y) and card.shape()[:10] != 'card_front':
card.to_front()
clicked_cards.append(card)
Audio.click()
def update_score():
@ -85,18 +98,30 @@ try:
while game_is_running:
time.sleep(0.1)
if not end_routine_done:
if matches >= 8:
success_t.showturtle()
Audio.pause_music()
Audio.game_success()
time.sleep(3.1)
Audio.unpause_background_music()
end_routine_done = True
if len(clicked_cards) == 2:
if clicked_cards[0] != clicked_cards[1]:
if clicked_cards[0] == clicked_cards[1]:
time.sleep(0.5)
clicked_cards[0].hideturtle()
clicked_cards[1].hideturtle()
score += 5
update_score()
Audio.match_made()
matches += 1
else:
time.sleep(1)
clicked_cards[0].to_back()
clicked_cards[1].to_back()
score -= 1
update_score()
Audio.no_match()
else:
score += 5
update_score()
Audio.match_made()
clicked_cards = []
screen.update()