Skip to content

fix typo's and other comment updates memory game #3009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions Metro/Metro_RP2350_Memory/memory_game/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def update_score_text():
)
display = framebufferio.FramebufferDisplay(fb)

# main group will hold all of our visual elements
# main group will hold all the visual elements
main_group = Group()

# make main group visible on the display
Expand Down Expand Up @@ -202,7 +202,7 @@ def update_score_text():
40,
)

# make it hidden, we'll show it when the game is over.
# make it hidden, it will show it when the game is over.
game_over_group.hidden = True

# add the game over lable to the game over group
Expand Down Expand Up @@ -339,9 +339,9 @@ def update_score_text():
# back over and changing turns
WAIT_UNTIL = 0

# bool indicating whether we are waiting to reset flipped
# bool indicating whether the code is waiting to reset flipped
# cards and change turns or award points and remove
# cards. Will be True if we are waiting to take action,
# cards. Will be True if the code is waiting to take action,
# False otherwise.
waiting_to_reset = False

Expand All @@ -352,16 +352,16 @@ def update_score_text():

# attempt mouse read
try:
# read data from the mouse, small timeout so we move on
# try to read data from the mouse, small timeout so the code will move on
# quickly if there is no data
data_len = mouse.read(0x81, buf, timeout=10)

# if we got data, then update the mouse cursor on the display
# if there was data, then update the mouse cursor on the display
# using min and max to keep it within the bounds of the display
mouse_tg.x = max(0, min(display.width - 1, mouse_tg.x + buf[1] // 2))
mouse_tg.y = max(0, min(display.height - 1, mouse_tg.y + buf[2] // 2))

# timeout error is raised if no data was read within the alotted timeout
# timeout error is raised if no data was read within the allotted timeout
except usb.core.USBTimeoutError:
# no problem, just go on
pass
Expand All @@ -380,13 +380,13 @@ def update_score_text():
# if the current state is playing
elif CUR_STATE == STATE_PLAYING:

# if we are waiting to reset, and it's time to take action
# if the code is waiting to reset, and it's time to take action
if waiting_to_reset and now >= WAIT_UNTIL:
# this means that there are already 2 cards flipped face up.
# we need to either award points, or flip them back over and
# change to the next players turn.
# The code needs to either award points, or flip the cards
# back over and change to the next players turn.

# change variable to indicate we're no longer waiting to take action
# change variable to indicate the code is no longer waiting to take action
waiting_to_reset = False

# if both cards were the same i.e. they found a match
Expand All @@ -406,7 +406,7 @@ def update_score_text():
update_score_text()

# if the total of both players scores is equal to half the amount
# of cards then we know the game is over because each pair is worth 1
# of cards then the code knows the game is over because each pair is worth 1
# point
if (
player_scores[0] + player_scores[1]
Expand Down Expand Up @@ -454,7 +454,7 @@ def update_score_text():
# empty out the cards flipped this turn list
cards_flipped_this_turn = []

# ignore any clicks while we're waiting to take reset cards
# ignore any clicks while the code is waiting to take reset cards
if now >= WAIT_UNTIL:
# left btn pressed
if buf[0] & (1 << 0) != 0:
Expand Down Expand Up @@ -497,7 +497,7 @@ def update_score_text():
# reload
supervisor.reload()

# if the mouse pint is within the exit
# if the mouse point is within the exit
# button bounding box
if exit_btn.contains(coords):
# break to exit out of this script
Expand Down