Skip to content
Open
Show file tree
Hide file tree
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
33 changes: 23 additions & 10 deletions src/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@ def square_start(self, hieght: int, width: int) -> [[int, int]]:
fourth_x = second_x * 3
first_y = hieght / 3
second_y = first_y * 2
squares = [[first_x, 0], [second_x, 0], [third_x, 0], [fourth_x, 0],
[first_x, first_y], [second_x, first_y], [third_x, first_y], [fourth_x, first_y],
[first_x, second_y], [second_x, second_y], [third_x, second_y], [fourth_x, second_y]]
return squares
return [
[first_x, 0],
[second_x, 0],
[third_x, 0],
[fourth_x, 0],
[first_x, first_y],
[second_x, first_y],
[third_x, first_y],
[fourth_x, first_y],
[first_x, second_y],
[second_x, second_y],
[third_x, second_y],
[fourth_x, second_y],
]
Comment on lines -14 to +27

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MemoryGameData.square_start refactored with the following changes:


def fullsquares(self, hieght: int, width: int) -> {int: pygame.Rect}:
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
Expand All @@ -28,13 +38,16 @@ def fullsquares(self, hieght: int, width: int) -> {int: pygame.Rect}:
return fullsquares

def prompts(self) -> {str: str}:
prompts = {
"Pencil": "Click On the square where you saw the yellow Pencil.",
"Mountain": "Click On the square where you saw the Tall White Mountain.",
"Numbers": "Click On the square where you saw the Numbers surronded by the red circles.",
"Letters": "Click On the square where you saw the the letters in the yellow box."
return {
"Pencil":
"Click On the square where you saw the yellow Pencil.",
"Mountain":
"Click On the square where you saw the Tall White Mountain.",
"Numbers":
"Click On the square where you saw the Numbers surronded by the red circles.",
"Letters":
"Click On the square where you saw the the letters in the yellow box.",
}
return prompts
Comment on lines -31 to -37

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MemoryGameData.prompts refactored with the following changes:


def images(self) -> {str: pygame.surface}:
images = {"Pencil": pygame.image.load("../assets/pencil.jpg"),
Expand Down
43 changes: 20 additions & 23 deletions src/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,13 @@ def draw_random_image(self, random_image_choice: str = "Mountain", sleeptime: in
del self.Images[invimage]
self.correct_square = self.squares.index(random_square)
self.correct_square += 1

prompt = self.prompts[random_image_choice]

return prompt

return self.prompts[random_image_choice]
Comment on lines -67 to +68

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Game.draw_random_image refactored with the following changes:


def drawscreen(self, difficulty: int = 5, sleeptimer: int = 1) -> pygame.display:

prompt = ""
current_difficulty = 0
amount_of_guesses = 1

Comment on lines -76 to -77

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Game.drawscreen refactored with the following changes:

while current_difficulty != difficulty:
event = pygame.event.poll()
if event.type == pygame.QUIT:
Expand All @@ -87,8 +83,8 @@ def drawscreen(self, difficulty: int = 5, sleeptimer: int = 1) -> pygame.display
self.drawlines()
prompt = self.draw_random_image(sleeptime=sleeptimer)
current_difficulty += 1
if self.correct_square == None:

if self.correct_square is None:
print("Game Bug Image did not show up.")
print("Restarting...")
self.screen.fill((0, 0, 0))
Expand All @@ -98,7 +94,9 @@ def drawscreen(self, difficulty: int = 5, sleeptimer: int = 1) -> pygame.display
self.drawscreen(difficulty, sleeptimer)
else:
print(prompt)


amount_of_guesses = 1

while True:
event = pygame.event.poll()
self.screen.fill((0, 0, 0))
Expand All @@ -109,18 +107,17 @@ def drawscreen(self, difficulty: int = 5, sleeptimer: int = 1) -> pygame.display
if event.type == pygame.K_ESCAPE:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONUP:

if (event.type == pygame.MOUSEBUTTONUP
and event.button == 1):
correct_rect = self.fullsquares[self.correct_square]
if event.button == 1:
if correct_rect.collidepoint(event.pos):
print("guess : " + str(amount_of_guesses))
print("Correct!")
print("You got it right in " + str(amount_of_guesses) + " guess/ess")
sys.exit()

else:
print("guess : " + str(amount_of_guesses))
amount_of_guesses += 1
print("That is not the correct square")
if correct_rect.collidepoint(event.pos):
print("guess : " + str(amount_of_guesses))
print("Correct!")
print("You got it right in " + str(amount_of_guesses) + " guess/ess")
sys.exit()

else:
print("guess : " + str(amount_of_guesses))
amount_of_guesses += 1
print("That is not the correct square")