From 5da8c5e668f46839bb260fe8b75989778922faeb Mon Sep 17 00:00:00 2001 From: PaMeirelles Date: Thu, 26 Sep 2024 22:22:59 -0300 Subject: [PATCH 1/2] Improving visualization --- santoriniGame/board.py | 24 +++++++++++++++++++++--- santoriniGame/pieces.py | 5 ++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/santoriniGame/board.py b/santoriniGame/board.py index ccd9660..d73dc7a 100644 --- a/santoriniGame/board.py +++ b/santoriniGame/board.py @@ -25,9 +25,27 @@ def draw(self, win: pygame.SurfaceType, valid_moves=None): # Draw the square border pygame.draw.rect(win, GREY, (x, y, SQUARE_SIZE, SQUARE_SIZE), 2) - # Draw the level number on each tile - level_text = self.font.render(str(self.tile_levels[row][col]), True, (0, 0, 0)) - win.blit(level_text, (x + 5, y + 5)) # Position the text in the top left of each tile + if self.tile_levels[row][col] >= 1: + pygame.draw.rect(win, WHITE, (x + SQUARE_SIZE // 20, y + SQUARE_SIZE // 20, + 18 * SQUARE_SIZE // 20, 18 * SQUARE_SIZE // 20)) + pygame.draw.rect(win, BLACK, (x + SQUARE_SIZE // 20, y + SQUARE_SIZE // 20, + 18 * SQUARE_SIZE // 20, 18 * SQUARE_SIZE // 20), width=SQUARE_SIZE//40) + if self.tile_levels[row][col] >= 2: + pygame.draw.rect(win, WHITE, (x + SQUARE_SIZE // 10, y + SQUARE_SIZE // 10, + 8 * SQUARE_SIZE // 10, 8 * SQUARE_SIZE // 10)) + pygame.draw.rect(win, BLACK, (x + SQUARE_SIZE // 10, y + SQUARE_SIZE // 10, + 8 * SQUARE_SIZE // 10, 8 * SQUARE_SIZE // 10), + width=SQUARE_SIZE // 40) + if self.tile_levels[row][col] >= 3: + pygame.draw.circle(win, WHITE, (x + SQUARE_SIZE // 2, y + SQUARE_SIZE // 2), + SQUARE_SIZE // 3) + pygame.draw.circle(win, BLACK, (x + SQUARE_SIZE // 2, y + SQUARE_SIZE // 2), + SQUARE_SIZE // 3, width=SQUARE_SIZE//40) + if self.tile_levels[row][col] >= 4: + pygame.draw.circle(win, BLUE, (x + SQUARE_SIZE // 2, y + SQUARE_SIZE // 2), + SQUARE_SIZE // 3) + pygame.draw.circle(win, BLACK, (x + SQUARE_SIZE // 2, y + SQUARE_SIZE // 2), + SQUARE_SIZE // 3, width=SQUARE_SIZE//40) # Highlight valid moves if valid_moves and (row, col) in valid_moves: diff --git a/santoriniGame/pieces.py b/santoriniGame/pieces.py index 5375111..b2f2de3 100644 --- a/santoriniGame/pieces.py +++ b/santoriniGame/pieces.py @@ -21,8 +21,11 @@ def calc_pos(self): self.y = SQUARE_SIZE * self.row + SQUARE_SIZE // 2 def draw(self, win: pygame.SurfaceType): - radius = SQUARE_SIZE//2 - self.PADDING + radius = SQUARE_SIZE // 4 - self.PADDING + width = SQUARE_SIZE // 40 pygame.draw.circle(win, self.color, (self.x, self.y), radius) + pygame.draw.circle(win, BLACK, (self.x, self.y), radius, width) + def move(self, row: int, col: int, level: int): self.row = row From 5510c4197f891320c4ace3d2af9082ec3a9a70b1 Mon Sep 17 00:00:00 2001 From: PaMeirelles Date: Thu, 26 Sep 2024 22:27:38 -0300 Subject: [PATCH 2/2] Removing duplicated code --- santoriniGame/board.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/santoriniGame/board.py b/santoriniGame/board.py index d73dc7a..f1721dc 100644 --- a/santoriniGame/board.py +++ b/santoriniGame/board.py @@ -44,8 +44,6 @@ def draw(self, win: pygame.SurfaceType, valid_moves=None): if self.tile_levels[row][col] >= 4: pygame.draw.circle(win, BLUE, (x + SQUARE_SIZE // 2, y + SQUARE_SIZE // 2), SQUARE_SIZE // 3) - pygame.draw.circle(win, BLACK, (x + SQUARE_SIZE // 2, y + SQUARE_SIZE // 2), - SQUARE_SIZE // 3, width=SQUARE_SIZE//40) # Highlight valid moves if valid_moves and (row, col) in valid_moves: