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 __blit_all_characters(self, screen): active_players = [] # get list of active players for player in self.players: if player.playing: active_players.append(player) # width interval dependant on number of active players width_interval = DISPLAY_RES[0] / len(active_players) # blit all characters for i in range(len(active_players)): # calculate location blit_loc = (((width_interval * i) + width_interval / 2) - active_players[i].char_surface.get_width() / 2, DISPLAY_RES[1] - active_players[i].char_surface.get_height()) # blit alpha depending on state if (self.state.if_state(FINAL_BET_STATE) and active_players[i].bet_set) or ( self.state.if_state(FINAL_CHECK_STATE) and active_players[i].check_set): util.blit_alpha(screen, active_players[i].char_surface, blit_loc, 25) # blit character surface else: screen.blit(active_players[i].char_surface, blit_loc)
def __blit_all_characters(self, screen): char_surfs = [] for i in range(4): if self.charsel_state: if self.char_selected[i]: charnum = self.active_players[i] else: charnum = self.player_cursor_pos[i] char_surfs.append(gen.char_surface(charnum).convert()) else: char_surfs.append(gen.char_surface(0).convert()) # width interval dependant on number of players width_interval = DISPLAY_RES[0]/4 blit_loc = (((width_interval*(i)) + width_interval/2) - char_surfs[i].get_width()/2, DISPLAY_RES[1]-char_surfs[i].get_height()) # blit all characters for i in range(4): # calculate location blit_loc = (((width_interval*(i)) + width_interval/2) - char_surfs[i].get_width()/2, DISPLAY_RES[1]-char_surfs[i].get_height()) if self.char_selected[i]: util.blit_alpha(screen, char_surfs[i], blit_loc, 25) else: self.SCREEN.blit(char_surfs[i], blit_loc)
def __blit_character_select(self, screen): x_dim = self.charsel_dimension[0] y_dim = 2 + self.charsel_dimension[1] x_home = DISPLAY_RES[0]/2 - (200*x_dim)/2 y_home = 200 for i in range(y_dim): for j in range(x_dim): charnum = (x_dim * i) + j char_surf = pygame.Surface((180, 120)) char_surf.fill(BLUE) char_surf.blit(CHARACTERS_IMAGE, (0, 0), (charnum*180, 0, 180, 120)) blit_loc = (x_home + 200*j, 20 + 170*i) if (charnum in self.active_players) and charnum != 0: util.blit_alpha(screen, char_surf, blit_loc, 25) else: screen.blit(char_surf, blit_loc) screen.blit(self.border_surface, (x_home + 200*j, 20 + 170*i)) it = 0 for num in self.player_cursor_pos: pos = self.__get_pos_from_num(num) if not self.char_selected[it]: screen.blit(self.cursor_surfaces[it], (x_home + 200*pos[0], 20 + 170*pos[1])) it += 1
def __blit_all_characters(self, screen): char_surfs = [] for index in range(4): if self.charsel_state: if self.char_selected[index]: charnum = self.active_players[index] else: charnum = self.player_cursor_pos[index] char_surfs.append(gen.char_surface(charnum).convert()) else: char_surfs.append(gen.char_surface(0).convert()) # width interval dependant on number of players width_interval = DISPLAY_RES[0] / 4 # blit all characters for i in range(4): # calculate location blit_loc = (((width_interval * (i)) + width_interval / 2) - char_surfs[i].get_width() / 2, DISPLAY_RES[1] - char_surfs[i].get_height()) if self.char_selected[i]: util.blit_alpha(screen, char_surfs[i], blit_loc, 25) else: self.SCREEN.blit(char_surfs[i], blit_loc)
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 draw(self, screen): blit_alpha(screen, opz.surface, (0, 4), 150) write_center_text(optionName[self.id], 40, (0, 0, 0), screen, 9) blit_alpha(screen, opzMini.surface, (0, 50), 150) string = self.valuesList[self.current][1] write_center_text(string, 30, (0, 0, 0), screen, 50) string = '[' + str(self.current + 1) + '/' + str(self.limit) + ']' write_right_text(string, 30, (0, 0, 0), screen, 50)
def render_image(self, image, p, s, alpha, blend, screen): if alpha == 255: screen.blit( image, (p.x - s.width * s.scale // 2, p.y - s.height * s.scale // 2), special_flags=blend) else: util.blit_alpha( screen, image, (p.x - s.width * s.scale // 2, p.y - s.height * s.scale // 2), alpha, blend)
def __update_display(self): # update text surfaces based on state values self.__update_text_surfaces() # fill screen self.SCREEN.fill(BLUE) # calculate offset for centering text offset = gen.menu_item("> INPUT: ", "KEYBOARD", False).get_width() / 2 x_loc = DISPLAY_RES[0] / 2 - offset - HELVETICA[30].size("")[0] scaled_alex = pygame.transform.scale( ALEX_IMAGE, (ALEX_IMAGE.get_width() * 3, ALEX_IMAGE.get_height() * 3)) # blit surfaces if self.charsel_state: self.SCREEN.blit(pygame.transform.scale(MAINBG_IMAGE, DISPLAY_RES), (0, 0)) self.__blit_character_select(self.SCREEN) else: # self.SCREEN.blit(PYGAME_IMAGE, (DISPLAY_RES[0]/2-PYGAME_IMAGE.get_width()/2, 5)) util.blit_alpha(self.SCREEN, scaled_alex, (0, DISPLAY_RES[1] - scaled_alex.get_height()), 100) util.blit_alpha(self.SCREEN, pygame.transform.flip(scaled_alex, True, True), (DISPLAY_RES[0] - scaled_alex.get_width(), DISPLAY_RES[1] - scaled_alex.get_height()), 100) self.SCREEN.blit( LOGO_IMAGE, (DISPLAY_RES[0] / 2 - LOGO_IMAGE.get_width() / 2, 70)) self.SCREEN.blit(self.gamedate_text_surface, (DISPLAY_RES[0] / 2 - self.gamedate_text_surface.get_width() / 2, 275)) self.SCREEN.blit(self.start_text_surface, (x_loc, 325)) self.SCREEN.blit(self.newgame_text_surface, (x_loc, 360)) self.SCREEN.blit(self.check_buzzers_surface, (x_loc, 395)) self.SCREEN.blit(self.sfx_text_surface, (x_loc, 430)) self.SCREEN.blit(self.speech_text_surface, (x_loc, 465)) self.SCREEN.blit(self.music_text_surface, (x_loc, 500)) self.SCREEN.blit(self.buzzer_prompt_surface, (0, 0)) self.SCREEN.blit(self.buzzer_status_surface, (165, 0)) # display players self.__blit_all_characters(self.SCREEN)
def __display_main(self): self.SCREEN.fill(BLUE) self.__update_board_surf() # create scaled character surface active_char_surf = self.players[self.state.active_player].char_surface scaled_image = pygame.transform.scale(active_char_surf, (active_char_surf.get_width()*3, active_char_surf.get_height()*3)) # blit active char util.blit_alpha(self.SCREEN, scaled_image, (0, DISPLAY_RES[1]-scaled_image.get_height()), 100) # blit game board self.SCREEN.blit(self.board_surf, (DISPLAY_RES[0]/2-BOARD_SIZE[0]/2,0)) # blit all characters self.__blit_all_characters(self.SCREEN)
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 draw(self, screen): blit_alpha(screen, opz.surface, (0, 4), 150) write_center_text(optionName[self.id], 40, (0, 0, 0), screen, 9) # Button if self.current == 0: screen.blit(offImg.surface, (135, 125)) screen.blit(onImg.surface, (135, 110)) #pygame.draw.circle(screen, (90,90,90), (160, 135), 20, 20) #pygame.draw.circle(screen, (10,200,200), (160, 135), 16, 14) else: screen.blit(onImg.surface, (135, 110)) screen.blit(offImg.surface, (135, 125)) #pygame.draw.circle(screen, (90,90,90), (160, 135), 20, 20) #pygame.draw.circle(screen, (200,200,200), (160, 135), 16, 14) blit_alpha(screen, opzMini.surface, (0, 50), 150) string = str(self.values[self.current][1]) write_center_text(string, 30, (0, 0, 0), screen, 50) ''' >> Nome Opzione
def draw(self, screen): blit_alpha(screen, opz.surface, (0, 4), 150) write_center_text(optionName[self.id], 40, (0, 0, 0), screen, 9) # Slider pygame.draw.line(screen, (80, 80, 80), (self.sliderInf, 135), (self.sliderSup, 135), 10) pygame.draw.line(screen, (10, 200, 200), (self.sliderInf + 1, 135), (self.currentPosX, 135), 8) pygame.draw.line(screen, (200, 200, 200), (self.currentPosX, 135), (self.sliderSup - 1, 135), 8) screen.blit(sliderBall.surface, (self.currentPosX - 10, 125)) #pygame.draw.circle(screen, (90,90,90), (self.currentPosX, 135), 15, 15) #pygame.draw.circle(screen, (200,200,200), (self.currentPosX, 135), 12, 10) blit_alpha(screen, opzMini.surface, (0, 50), 150) string = str(self.current) write_center_text(string, 30, (0, 0, 0), screen, 50) ''' >> Nome Opzione
def __update_display(self): # update text surfaces based on state values self.__update_text_surfaces() # fill screen self.SCREEN.fill(BLUE) # calculate offset for centering text offset = gen.menu_item("> INPUT: ", "KEYBOARD", False).get_width()/2 x_loc = DISPLAY_RES[0]/2 - offset - HELVETICA[30].size("")[0] scaled_alex = pygame.transform.scale(ALEX_IMAGE, (ALEX_IMAGE.get_width()*3, ALEX_IMAGE.get_height()*3)) # blit surfaces if self.charsel_state: self.SCREEN.blit(pygame.transform.scale(MAINBG_IMAGE, DISPLAY_RES), (0, 0)) self.__blit_character_select(self.SCREEN) else: #self.SCREEN.blit(PYGAME_IMAGE, (DISPLAY_RES[0]/2-PYGAME_IMAGE.get_width()/2, 5)) util.blit_alpha(self.SCREEN, scaled_alex, (0, DISPLAY_RES[1]-scaled_alex.get_height()), 100) util.blit_alpha(self.SCREEN, pygame.transform.flip(scaled_alex, True, True), (DISPLAY_RES[0]-scaled_alex.get_width(), DISPLAY_RES[1]-scaled_alex.get_height()), 100) self.SCREEN.blit(LOGO_IMAGE, (DISPLAY_RES[0]/2-LOGO_IMAGE.get_width()/2, 70)) self.SCREEN.blit(self.gamedate_text_surface, (DISPLAY_RES[0]/2 - self.gamedate_text_surface.get_width()/2, 275)) self.SCREEN.blit(self.start_text_surface, (x_loc, 325)) self.SCREEN.blit(self.newgame_text_surface, (x_loc, 360)) self.SCREEN.blit(self.check_buzzers_surface, (x_loc, 395)) self.SCREEN.blit(self.sfx_text_surface, (x_loc, 430)) self.SCREEN.blit(self.speech_text_surface, (x_loc, 465)) self.SCREEN.blit(self.music_text_surface, (x_loc, 500)) self.SCREEN.blit(self.buzzer_prompt_surface, (0, 0)) self.SCREEN.blit(self.buzzer_status_surface, (165, 0)) # display players self.__blit_all_characters(self.SCREEN)
def __display_main(self): self.SCREEN.fill(BLUE) self.__update_board_surf() # create scaled character surface active_char_surf = self.players[self.state.active_player].char_surface scaled_image = pygame.transform.scale( active_char_surf, (active_char_surf.get_width() * 3, active_char_surf.get_height() * 3)) # blit active char util.blit_alpha(self.SCREEN, scaled_image, (0, DISPLAY_RES[1] - scaled_image.get_height()), 100) # blit game board self.SCREEN.blit(self.board_surf, (DISPLAY_RES[0] / 2 - BOARD_SIZE[0] / 2, 0)) # blit all characters self.__blit_all_characters(self.SCREEN) # toasty animation if self.play_toasty: self.__run_toasty()
def __blit_all_characters(self, screen): active_players = [] # get list of active players for player in self.players: if player.playing: active_players.append(player) # width interval dependant on number of active players width_interval = DISPLAY_RES[0]/len(active_players) # blit all characters for i in range(len(active_players)): # calculate location blit_loc = (((width_interval*(i)) + width_interval/2) - active_players[i].char_surface.get_width()/2, DISPLAY_RES[1]-active_players[i].char_surface.get_height()) # blit alpha depending on state if (self.state.if_state(FINAL_BET_STATE) and active_players[i].bet_set) or (self.state.if_state(FINAL_CHECK_STATE) and active_players[i].check_set): util.blit_alpha(screen, active_players[i].char_surface, blit_loc, 25) # blit character surface else: screen.blit(active_players[i].char_surface, blit_loc)
def __blit_character_select(self, screen): x_dim = self.charsel_dimension[0] y_dim = 2 + self.charsel_dimension[1] x_home = DISPLAY_RES[0] / 2 - (200 * x_dim) / 2 y_home = 200 for i in range(y_dim): for j in range(x_dim): charnum = (x_dim * i) + j char_surf = pygame.Surface((180, 120)) char_surf.fill(BLUE) char_surf.blit(CHARACTERS_IMAGE, (0, 0), (charnum * 180, 0, 180, 120)) blit_loc = (x_home + 200 * j, 20 + 170 * i) if (charnum in self.active_players) and charnum != 0: util.blit_alpha(screen, char_surf, blit_loc, 25) else: screen.blit(char_surf, blit_loc) screen.blit(self.border_surface, (x_home + 200 * j, 20 + 170 * i)) it = 0 for num in self.player_cursor_pos: pos = self.__get_pos_from_num(num) if not self.char_selected[it]: screen.blit(self.cursor_surfaces[it], (x_home + 200 * pos[0], 20 + 170 * pos[1])) it += 1
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)