def __display_resp(self): main_center_loc = [BOARD_SIZE[0]/2, BOARD_SIZE[1]/2] # generate marker surfaces correct_surf = gen.correct_surface(True) incorrect_surf = gen.correct_surface(False) # generate character and text surfaces cat_surf = gen.text_surface((str(self.cur_block.category).upper())) char_surf = self.players[self.state.buzzed_player].char_surface text_surf = gen.text_surface(self.cur_block.response, BOARD_SIZE[0], BOARD_SIZE[1], 40, WHITE, "korinna") # scale character surface scaled_image = pygame.transform.scale(char_surf, (char_surf.get_width()*3, char_surf.get_height()*3)) # fill screen self.SCREEN.fill(BLUE) # blit character and text to screen util.blit_alpha(self.SCREEN, scaled_image, (0, DISPLAY_RES[1]-scaled_image.get_height()), 100) self.SCREEN.blit(char_surf, (0, DISPLAY_RES[1]-char_surf.get_height())) # blit response self.SCREEN.blit(cat_surf, (DISPLAY_RES[0]/2 - BOARD_SIZE[0]/2, -200)) self.SCREEN.blit(text_surf, (DISPLAY_RES[0]/2 - BOARD_SIZE[0]/2,0)) # blit markers if not (self.state.buzzed_timeout or self.state.clue_timeout): self.SCREEN.blit(correct_surf, (main_center_loc[0]-100, main_center_loc[1]+150)) self.SCREEN.blit(incorrect_surf, (main_center_loc[0]+incorrect_surf.get_width(), main_center_loc[1]+150))
def __display_bet(self): # set variables category = self.cur_block.category player = self.players[self.state.buzzed_player] # scale surfaces background_surf = pygame.transform.scale(DDBG_IMAGE, DISPLAY_RES) scaled_image_surf = pygame.transform.scale( player.blank_char_surface, (player.blank_char_surface.get_width() * 3, player.blank_char_surface.get_height() * 3)) # generate other surfaces prompt_text_surf = gen.text_surface(category) bet_text_surf = gen.text_surface(player.cur_bet, scaled_image_surf.get_width(), scaled_image_surf.get_height(), 63, WHITE, "digital") # blit to image surface scaled_image_surf.blit(bet_text_surf, (0, scaled_image_surf.get_height() / 3 + 20)) # blit to screen self.SCREEN.blit(background_surf, (0, 0)) self.SCREEN.blit( prompt_text_surf, (DISPLAY_RES[0] / 2 - prompt_text_surf.get_width() / 2, -200)) self.SCREEN.blit( scaled_image_surf, (DISPLAY_RES[0] / 2 - scaled_image_surf.get_width() / 2, DISPLAY_RES[1] - scaled_image_surf.get_height()))
def __display_clue(self): # generate category and clue surface cat_surf = gen.text_surface((str(self.cur_block.category).upper())) clue_surf = gen.text_surface(self.cur_block.clue, BOARD_SIZE[0], BOARD_SIZE[1], 40, WHITE, "korinna") # determine character surface if self.state.if_state(SHOW_CLUE_STATE): char_surf = ALEX_IMAGE elif self.state.if_state(BUZZED_STATE): char_surf = self.players[self.state.buzzed_player].char_surface # scale character surface scaled_image = pygame.transform.scale(char_surf, (char_surf.get_width()*3, char_surf.get_height()*3)) # fill screen self.SCREEN.fill(BLUE) # blit character and text to screen util.blit_alpha(self.SCREEN, scaled_image, (0, DISPLAY_RES[1]-scaled_image.get_height()), 100) self.SCREEN.blit(char_surf, (0, DISPLAY_RES[1]-char_surf.get_height())) # get resource and display/play ### if self.cur_block.if_resource(): ### ACTUAL CHECK WHEN MOVIES AND MUSIC if self.cur_block.resource.surface: ### DETERMINE IF MOVIE, MUSIC, OR IMAGE ### res_surface = self.cur_block.resource.surface res_surface = pygame.transform.scale(res_surface, (res_surface.get_width()/2, res_surface.get_height()/2)) self.SCREEN.blit(res_surface, (DISPLAY_RES[0]/2 - res_surface.get_width()/2, 400)) # blit category and clue to screen self.SCREEN.blit(cat_surf, (DISPLAY_RES[0]/2 - BOARD_SIZE[0]/2, -200)) self.SCREEN.blit(clue_surf, (DISPLAY_RES[0]/2 - BOARD_SIZE[0]/2,0))
def __init__(self, screen, theme_channel, buzzers): self.SCREEN = screen self.THEME_CHANNEL = theme_channel self.BUZZERS = buzzers # play if channel inactive if not theme_channel.get_busy(): theme_channel.play(THEME_SOUND, -1) # menu state self.charsel_state = False # info state self.input_state = bool(buzzers) self.sfx_state = True self.speech_state = True self.music_state = True self.new_game = False self.check_buzzers = False # misc variables self.cursor_loc = 0 self.game_date = None self.charsel_dimension = [((NUM_SPRITES + 1) / 2), (NUM_SPRITES + 1) % 2] # which players are active self.active_players = [-1, -1, -1, -1] self.player_cursor_pos = [0, 0, 0, 0] self.char_selected = [False, True, True, True] # text surfaces self.start_text_surface = None self.newgame_text_surface = None self.check_buzzers_surface = None self.sfx_text_surface = None self.speech_text_surface = None self.music_text_surface = None self.gamedate_text_surface = None # cursor surfaces self.cursor_surfaces = [ gen.cursor_surface(180, 120, WHITE, "P1"), gen.cursor_surface(180, 120, WHITE, "P2"), gen.cursor_surface(180, 120, WHITE, "P3"), gen.cursor_surface(180, 120, WHITE, "P4") ] self.border_surface = gen.cursor_surface(180, 120, YELLOW) # buzzer status surface self.buzzer_prompt_surface = gen.text_surface("BUZZERS FOUND: ", 175, 50, 20) self.buzzer_status_surface = self.__get_buzzer_status_surface() # initial blit to screen self.__update_display()
def __display_resp(self): main_center_loc = [BOARD_SIZE[0] / 2, BOARD_SIZE[1] / 2] # generate marker surfaces correct_surf = gen.correct_surface(True) incorrect_surf = gen.correct_surface(False) # generate character and text surfaces cat_surf = gen.text_surface((str(self.cur_block.category).upper())) char_surf = self.players[self.state.buzzed_player].char_surface text_surf = gen.text_surface(self.cur_block.response, BOARD_SIZE[0], BOARD_SIZE[1], 40, WHITE, "korinna") # scale character surface scaled_image = pygame.transform.scale( char_surf, (char_surf.get_width() * 3, char_surf.get_height() * 3)) # fill screen self.SCREEN.fill(BLUE) # blit character and text to screen util.blit_alpha(self.SCREEN, scaled_image, (0, DISPLAY_RES[1] - scaled_image.get_height()), 100) self.SCREEN.blit(char_surf, (0, DISPLAY_RES[1] - char_surf.get_height())) # blit response self.SCREEN.blit(cat_surf, (DISPLAY_RES[0] / 2 - BOARD_SIZE[0] / 2, -200)) self.SCREEN.blit(text_surf, (DISPLAY_RES[0] / 2 - BOARD_SIZE[0] / 2, 0)) # blit markers if not (self.state.buzzed_timeout or self.state.clue_timeout): self.SCREEN.blit( correct_surf, (main_center_loc[0] - 100, main_center_loc[1] + 150)) self.SCREEN.blit(incorrect_surf, (main_center_loc[0] + incorrect_surf.get_width(), main_center_loc[1] + 150)) # read response if self.state.init: self.__ttsx_speak(self.cur_block.response)
def __get_buzzer_status_surface(self): if self.BUZZERS: color = WHITE text = "YES" else: color = RED text = "NO" return gen.text_surface(text, 50, 50, 20, color)
def __update_char_surface(self, value): # determine display color if self.score >= 0: color = constants.WHITE else: color = constants.RED # update player surface self.char_surface.fill(constants.DARK_BLUE) self.char_surface.blit(self.blank_char_surface, (0,0)) self.char_surface.blit(gen.text_surface(value, self.char_surface.get_width(), self.char_surface.get_height(), 35, color, "digital", constants.BLUE), (0, 71))
def __init__(self, screen, theme_channel, buzzers): self.SCREEN = screen self.THEME_CHANNEL = theme_channel self.BUZZERS = buzzers # play if channel inactive if not theme_channel.get_busy(): theme_channel.play(THEME_SOUND, -1) # menu state self.charsel_state = False # info state self.input_state = bool(buzzers) self.sfx_state = True self.speech_state = True self.music_state = True self.new_game = False self.check_buzzers = False # misc variables self.cursor_loc = 0 self.game_date = None self.charsel_dimension = [((NUM_SPRITES + 1) / 2), (NUM_SPRITES + 1) % 2] # which players are active self.active_players = [-1, -1, -1, -1] self.player_cursor_pos = [0, 0, 0, 0] self.char_selected = [False, True, True, True] # text surfaces self.start_text_surface = None self.newgame_text_surface = None self.check_buzzers_surface = None self.sfx_text_surface = None self.speech_text_surface = None self.music_text_surface = None self.gamedate_text_surface = None # cursor surfaces self.cursor_surfaces = [ gen.cursor_surface(180, 120, WHITE, "P1"), gen.cursor_surface(180, 120, WHITE, "P2"), gen.cursor_surface(180, 120, WHITE, "P3"), gen.cursor_surface(180, 120, WHITE, "P4"), ] self.border_surface = gen.cursor_surface(180, 120, YELLOW) # buzzer status surface self.buzzer_prompt_surface = gen.text_surface("BUZZERS FOUND: ", 175, 50, 20) self.buzzer_status_surface = self.__get_buzzer_status_surface() # initial blit to screen self.__update_display()
def __init__(self, text): # data self.text = text self.board_surface = None self.display_surface = None # state self.completed = False self.board_surface = gen.text_surface(self.text, constants.BOARD_SIZE[0]/6 - 20, constants.BOARD_SIZE[0]/6 - 20, 20, constants.YELLOW, "helvetica", constants.DARK_BLUE)
def __display_bet(self): # set variables category = self.cur_block.category player = self.players[self.state.buzzed_player] # scale surfaces background_surf = pygame.transform.scale(DDBG_IMAGE, DISPLAY_RES) scaled_image_surf = pygame.transform.scale(player.blank_char_surface, (player.blank_char_surface.get_width()*3, player.blank_char_surface.get_height()*3)) # generate other surfaces prompt_text_surf = gen.text_surface(category) bet_text_surf = gen.text_surface(player.cur_bet, scaled_image_surf.get_width(), scaled_image_surf.get_height(), 63, WHITE, "digital") # blit to image surface scaled_image_surf.blit(bet_text_surf, (0, scaled_image_surf.get_height()/3+20)) # blit to screen self.SCREEN.blit(background_surf, (0, 0)) self.SCREEN.blit(prompt_text_surf, (DISPLAY_RES[0]/2-prompt_text_surf.get_width()/2, -200)) self.SCREEN.blit(scaled_image_surf, (DISPLAY_RES[0]/2-scaled_image_surf.get_width()/2, DISPLAY_RES[1]-scaled_image_surf.get_height()))
def __display_final_bet(self): # blit background image background_surf = pygame.transform.scale(FJBG_IMAGE, DISPLAY_RES) self.SCREEN.blit(background_surf, (0, 0)) # blit category prompt_text_surf = gen.text_surface(self.cur_block.category) self.SCREEN.blit(prompt_text_surf, (DISPLAY_RES[0]/2-prompt_text_surf.get_width()/2, -200)) # blit all characters self.__blit_all_characters(self.SCREEN)
def __init__(self, text): # data self.text = text self.board_surface = None self.display_surface = None # state self.completed = False self.board_surface = gen.text_surface(self.text, constants.BOARD_SIZE[0] / 6 - 20, constants.BOARD_SIZE[0] / 6 - 20, 20, constants.YELLOW, "helvetica", constants.DARK_BLUE)
def __display_final_bet(self): # blit background image background_surf = pygame.transform.scale(FJBG_IMAGE, DISPLAY_RES) self.SCREEN.blit(background_surf, (0, 0)) # blit category prompt_text_surf = gen.text_surface(self.cur_block.category) self.SCREEN.blit( prompt_text_surf, (DISPLAY_RES[0] / 2 - prompt_text_surf.get_width() / 2, -200)) # blit all characters self.__blit_all_characters(self.SCREEN)
def __update_char_surface(self, value): # determine display color if self.score >= 0: color = constants.WHITE else: color = constants.RED # update player surface self.char_surface.fill(constants.DARK_BLUE) self.char_surface.blit(self.blank_char_surface, (0, 0)) self.char_surface.blit( gen.text_surface(value, self.char_surface.get_width(), self.char_surface.get_height(), 35, color, "digital", constants.BLUE), (0, 71))
def __display_end(self): # scale and blit background image background_surf = pygame.transform.scale(MAINBG_IMAGE, DISPLAY_RES) self.SCREEN.blit(background_surf, (0, 0)) # determine winners (may be a tie) winners = self.__determine_winners() # blit winners for i in range(len(winners)): char_surf = winners[i].char_surface if winners[i].playing: self.SCREEN.blit(pygame.transform.scale(char_surf, (char_surf.get_width()*3, char_surf.get_height()*3)), (i*300, 200)) self.SCREEN.blit(gen.text_surface("CONGRATULATIONS!!!"), (0,-200))
def __display_final_check(self): main_center_loc = [BOARD_SIZE[0]/2, BOARD_SIZE[1]/2] correct_surf = gen.correct_surface(True) incorrect_surf = gen.correct_surface(False) # fill screen self.SCREEN.fill(BLUE) # blit response self.SCREEN.blit(gen.text_surface(self.cur_block.response), (DISPLAY_RES[0]/2 - BOARD_SIZE[0]/2,0)) # blit markers self.SCREEN.blit(correct_surf, (main_center_loc[0]-100, main_center_loc[1]+100)) self.SCREEN.blit(incorrect_surf, (main_center_loc[0]+incorrect_surf.get_width(), main_center_loc[1]+100)) # blit all characters self.__blit_all_characters(self.SCREEN)
def __display_end(self): # scale and blit background image background_surf = pygame.transform.scale(MAINBG_IMAGE, DISPLAY_RES) self.SCREEN.blit(background_surf, (0, 0)) # determine winners (may be a tie) winners = self.__determine_winners() # blit winners for i in range(len(winners)): char_surf = winners[i].char_surface if winners[i].playing: self.SCREEN.blit( pygame.transform.scale(char_surf, (char_surf.get_width() * 3, char_surf.get_height() * 3)), (i * 300, 200)) self.SCREEN.blit(gen.text_surface("CONGRATULATIONS!!!"), (0, -200))
def __display_final_check(self): main_center_loc = [BOARD_SIZE[0] / 2, BOARD_SIZE[1] / 2] correct_surf = gen.correct_surface(True) incorrect_surf = gen.correct_surface(False) # fill screen self.SCREEN.fill(BLUE) # blit response self.SCREEN.blit(gen.text_surface(self.cur_block.response), (DISPLAY_RES[0] / 2 - BOARD_SIZE[0] / 2, 0)) # blit markers self.SCREEN.blit(correct_surf, (main_center_loc[0] - 100, main_center_loc[1] + 100)) self.SCREEN.blit(incorrect_surf, (main_center_loc[0] + incorrect_surf.get_width(), main_center_loc[1] + 100)) # blit all characters self.__blit_all_characters(self.SCREEN)
def __display_clue(self): # generate category and clue surface cat_surf = gen.text_surface((str(self.cur_block.category).upper())) clue_surf = gen.text_surface(self.cur_block.clue, BOARD_SIZE[0] + 100, BOARD_SIZE[1] + 100, 32, WHITE, "korinna") # determine character surface if self.state.if_state(SHOW_CLUE_STATE): char_surf = ALEX_IMAGE elif self.state.if_state(BUZZED_STATE): char_surf = self.players[self.state.buzzed_player].char_surface # scale character surface scaled_image = pygame.transform.scale( char_surf, (char_surf.get_width() * 3, char_surf.get_height() * 3)) # fill screen self.SCREEN.fill(BLUE) # blit character and text to screen util.blit_alpha(self.SCREEN, scaled_image, (0, DISPLAY_RES[1] - scaled_image.get_height()), 100) self.SCREEN.blit(char_surf, (0, DISPLAY_RES[1] - char_surf.get_height())) i = 0 for skip in self.skip_arr: if skip: self.SCREEN.blit(self.players[i].skip_surface, ((i * 100) + 50, 50)) i += 1 # get resource and display/play ### if self.cur_block.if_resource(): ### ACTUAL CHECK WHEN MOVIES AND MUSIC if self.cur_block.resource.surface: ### DETERMINE IF MOVIE, MUSIC, OR IMAGE ### res_surface = self.cur_block.resource.surface # resize scale_height = 200.0 height = res_surface.get_height() scale_width = res_surface.get_width() * (scale_height / height) scaled_surf = pygame.Surface((scale_width, scale_height)) # res_surface = pygame.transform.smoothscale(res_surface, (scale_width, scale_height), scaled_surf) res_surface = pygame.transform.scale( res_surface, (int(scale_width), int(scale_height))) # res_surface = pygame.transform.scale(res_surface, (res_surface.get_width()/2, res_surface.get_height()/2)) # self.SCREEN.blit(scaled_surf, (DISPLAY_RES[0]/2 - res_surface.get_width()/2, 400)) self.SCREEN.blit(res_surface, ((DISPLAY_RES[0] / 2) - (res_surface.get_width() / 2), DISPLAY_RES[1] - res_surface.get_height() - 20)) # blit category and clue to screen self.SCREEN.blit(cat_surf, (DISPLAY_RES[0] / 2 - BOARD_SIZE[0] / 2, -200)) self.SCREEN.blit(clue_surf, ((DISPLAY_RES[0] / 2 - BOARD_SIZE[0] / 2) - 50, 0)) # read response if self.state.init and (self.state.if_state(SHOW_CLUE_STATE) or self.state.dailydouble): self.__ttsx_speak(self.cur_block.clue)