From 92c9abb3cce736abc8bae8b81e4c3206d4996bc8 Mon Sep 17 00:00:00 2001 From: James Carr Date: Tue, 27 Jul 2021 22:56:47 +0100 Subject: [PATCH] Remove max_size usage with displayio.Group --- .../advanced/rps_display.py | 22 +++++++++---------- .../simple/clue-simple-rpsgame.py | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CLUE_Rock_Paper_Scissors/advanced/rps_display.py b/CLUE_Rock_Paper_Scissors/advanced/rps_display.py index 1e2aaeeda..f2cc76589 100644 --- a/CLUE_Rock_Paper_Scissors/advanced/rps_display.py +++ b/CLUE_Rock_Paper_Scissors/advanced/rps_display.py @@ -78,7 +78,7 @@ def blankScreen(disp, pix): if disp is None: return - disp.show(Group(max_size=1)) + disp.show(Group()) class RPSDisplay(): @@ -235,7 +235,7 @@ def showChoice(self, self.emptyGroup(self.disp_group) # Would be slightly better to create this Group once and re-use it - round_choice_group = Group(max_size=3) + round_choice_group = Group() if round_no is not None: title_dob = Label(self.font, @@ -261,7 +261,7 @@ def showChoice(self, gamesum_dob.y = round(self.height - 2 * self.font_height // 2) round_choice_group.append(gamesum_dob) - s_group = Group(scale=3, max_size=1) + s_group = Group(scale=3) s_group.x = 32 s_group.y = (self.height - 3 * self.sprite_size) // 2 s_group.append(self.sprites[ch_idx]) @@ -275,7 +275,7 @@ def introductionScreen(self): """Introduction screen.""" if self.disp is not None: self.emptyGroup(self.disp_group) - intro_group = Group(max_size=7) + intro_group = Group() welcometo_dob = Label(self.font, text="Welcome To", scale=3, @@ -289,7 +289,7 @@ def introductionScreen(self): spacing = 3 * self.sprite_size + extra_space y_adj = (-6, -2, -2) for idx, sprite in enumerate(self.sprites): - s_group = Group(scale=3, max_size=1) + s_group = Group(scale=3) s_group.x = -96 s_group.y = round((self.height - 1.5 * self.sprite_size) / 2 + (idx - 1) * spacing) + y_adj[idx] @@ -384,7 +384,7 @@ def playerListScreen(self): self.emptyGroup(self.disp_group) # The two multiplier allows for rssi as separate label - playerlist_group = Group(max_size=self.max_players * 2) + playerlist_group = Group() self.showGroup(playerlist_group) @@ -460,7 +460,7 @@ def showGameResultScreen(self, pla, sco, rounds_tot=None): self.emptyGroup(self.disp_group) # Score list group + background + question mark for sorting - gs_group = Group(max_size=4) + gs_group = Group() # Pale grey large GAME SCORES background bg_scale = 6 @@ -500,7 +500,7 @@ def showGameResultScreen(self, pla, sco, rounds_tot=None): - len(pla) * scale * self.font_height - (len(pla) - 1) * spacing) / 2 + scale * self.font_height / 2) - scores_group = Group(max_size=len(pla)) + scores_group = Group() gs_group.append(scores_group) for idx, (name, _) in enumerate(pla): op_dob = Label(self.font, @@ -648,7 +648,7 @@ def showPlayerVPlayerScreen(self, me_name, op_name, my_ch_idx, op_ch_idx, if void: error_tot = 3 - error_group = Group(max_size=error_tot + 1) + error_group = Group() # Opponent's name helps pinpoint the error op_dob = Label(self.font, text=op_name, @@ -677,7 +677,7 @@ def showPlayerVPlayerScreen(self, me_name, op_name, my_ch_idx, op_ch_idx, else: # Would be slightly better to create this Group once and re-use it - pvp_group = Group(max_size=3) + pvp_group = Group() # Add player's name and sprite just off left side of screen # and opponent's just off right @@ -696,7 +696,7 @@ def showPlayerVPlayerScreen(self, me_name, op_name, my_ch_idx, op_ch_idx, for (name, sprite, start_x, fg, bg) in player_detail: - s_group = Group(scale=2, max_size=2) # Audio is choppy at scale=3 + s_group = Group(scale=2) # Audio is choppy at scale=3 s_group.x = start_x s_group.y = (self.height - 2 * (self.sprite_size + self.font_height)) // 2 diff --git a/CLUE_Rock_Paper_Scissors/simple/clue-simple-rpsgame.py b/CLUE_Rock_Paper_Scissors/simple/clue-simple-rpsgame.py index cce150b79..fe038a90f 100644 --- a/CLUE_Rock_Paper_Scissors/simple/clue-simple-rpsgame.py +++ b/CLUE_Rock_Paper_Scissors/simple/clue-simple-rpsgame.py @@ -177,7 +177,7 @@ def flashWinner(c_idx, who): # The 6x14 terminalio classic font FONT_WIDTH, FONT_HEIGHT = terminalio.FONT.get_bounding_box() -screen_group = Group(max_size=len(choices) * 2 + 1 + 1) +screen_group = Group() # The position of the two players RPS Label objects inside screen_group rps_dob_idx = []