def draw(self, window): self.surface.fill("black") self.surface.set_colorkey("black") self.surface.blit(self.selector, (0,self.sel_y-3)) for i in range(len(self.options)): draw_text(self.surface, self.options[i], FONT_SIZE, GAME_FONT, self.surf_rect.centerx, FONT_SIZE*(i+1) + self.spacing*(i+1), self.colors[self.act_opt[i]], "centered") window.blit(self.surface, (0,window.get_height()/2 - 32))
def draw(self, window): self.table_surf.fill("black") self.table_surf.set_colorkey("black") if len(self.scores) != 0: for i in range(len(self.scores[self.cur_tbl])): name = self.scores[self.cur_tbl][i][0].upper() score = self.scores[self.cur_tbl][i][1] difficulty = DIFFICULTIES[self.scores[self.cur_tbl][i][2]] # If difficulty is HARD, then set color to yellow difficulty_color = "WHITE" if difficulty == DIFFICULTIES[2]: difficulty_color = "YELLOW" # Draw text draw_text(self.table_surf, f"{(i+1)+(self.cur_tbl*self.splice_n)}.", FONT_SIZE, GAME_FONT, self.table_rect.centerx * 0.35 + len(str(i)), FONT_SIZE*(i+1) + self.spacing*(i+1), "YELLOW") draw_text(self.table_surf, f"{name}", FONT_SIZE, GAME_FONT, self.table_rect.centerx * 0.6, FONT_SIZE*(i+1) + self.spacing*(i+1), "WHITE") draw_text(self.table_surf, f"{score}", FONT_SIZE, GAME_FONT, self.table_rect.centerx * 1.0, FONT_SIZE*(i+1) + self.spacing*(i+1), "WHITE") draw_text2(self.table_surf, f"{difficulty}", GAME_FONT, FONT_SIZE, (self.table_rect.centerx * 1.4, FONT_SIZE*(i+1) + self.spacing*(i+1)), difficulty_color) draw_text(window, f"PAGE {self.cur_tbl+1} OF {len(self.scores)}", FONT_SIZE, GAME_FONT, self.table_rect.centerx, self.table_rect.bottom * 1.25, "WHITE", "centered") else: draw_text2(self.table_surf, "No scores yet...", GAME_FONT, FONT_SIZE, (self.table_rect.centerx, 64), "WHITE", align="center") draw_text2(self.table_surf, "Go play the game!", GAME_FONT, FONT_SIZE, (self.table_rect.centerx, 96), "WHITE", align="center") window.blit(self.table_surf,(0,WIN_RES["h"]/2 - 128))
def draw(self, window): # Set colorkeys self.direction_panel.fill("BLACK") self.direction_panel.set_colorkey("BLACK") self.back_panel.fill("BLACK") self.back_panel.set_colorkey("BLACK") # Selector if self.active_panel == self.sub_panels[0]: self.direction_panel.blit(self.selector, (self.dp_rect.centerx * self.sel_i, 0)) elif self.active_panel == self.sub_panels[1]: self.back_panel.blit(self.selector, (self.back_panel.get_rect().width / 4, 0)) # Direction panel draw_text(self.direction_panel, self.dp_options[0], FONT_SIZE, GAME_FONT, self.dp_rect.centerx * 0.5, self.dp_rect.centery * 0.5, self.colors[self.dp_act_opt[0]], "centered") draw_text(self.direction_panel, self.dp_options[1], FONT_SIZE, GAME_FONT, self.dp_rect.centerx * 1.5, self.dp_rect.centery * 0.5, self.colors[self.dp_act_opt[1]], "centered") window.blit(self.direction_panel, (0, window.get_rect().height * 0.7)) # Back panel draw_text(self.back_panel, "BACK", FONT_SIZE, GAME_FONT, self.dp_rect.centerx, self.dp_rect.centery * 0.5, self.colors[self.bp_active], "centered") window.blit(self.back_panel, (0, window.get_rect().height * 0.8))
def draw(self, window): self.back_button.fill("BLACK") self.back_button.set_colorkey("BLACK") self.surface.fill("black") self.surface.set_colorkey("black") # Change selector size and draw if self.options[self.sel_i] != "BACK": self.selector = pygame.Surface((WIN_RES["w"], FONT_SIZE + 4)) self.selector.fill("white") self.surface.blit(self.selector, (0,self.sel_y-3)) else: self.selector = pygame.Surface((128,32)) self.selector.fill("white") self.back_button.blit( self.selector, (0,0) ) # Draw menu for i in range(len(self.options)): if self.options[i] != "BACK": draw_text(self.surface, self.options[i], FONT_SIZE, GAME_FONT, self.surf_rect.centerx, FONT_SIZE*(i+1) + self.spacing*(i+1), self.colors[self.act_opt[i]], "centered") else: draw_text2( self.back_button, "BACK", GAME_FONT, FONT_SIZE, (self.back_button.get_width()/2, self.back_button.get_height()/2 - FONT_SIZE/2), self.colors[self.act_opt[i]], align="center" ) window.blit( self.back_button, (window.get_width()/2 - self.back_button.get_width()/2, window.get_height()*0.8) ) # Draw the menu widget surface window.blit(self.surface, (0,window.get_height()*0.3))