def main_menu(self,pause_flag = True, game_save_flag = False): ''' Display the starting menu ''' self.init_game_save_flag = game_save_flag self.game_save_flag = False logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() self.ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250))) threades.screen.fill((0,0,0)) threades.screen.blit(self.ff_logo,threades.resize_pos((40,50))) # Font type myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) # Creating new button style buttonsurf = pygame.image.load(os.path.join('art','button_green.png')).convert_alpha() buttonsurf = pygame.transform.scale(buttonsurf, (36, threades.resize_pt_y(40))) self.button_style = gui.createButtonStyle(myfont,(0,0,0), buttonsurf,4,1,4,4,1,4,4,1,4,4,1,4) self.pause_flag = pause_flag #Starting new game button if self.pause_flag: self.start_button1 = gui.Button(position = threades.resize_pos((475,500)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Start New Game1",style = self.button_style) self.start_button1.onClick = self.startup_text self.start_button2 = gui.Button(position = threades.resize_pos((475,850)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Start new Game2",style = self.button_style) self.start_button2.onClick = self.startup_text #Resume saved level button if a game is saved if self.init_game_save_flag == True: self.resume_saved_level_button = gui.Button(position = threades.resize_pos((475,430)),size = threades.resize_pos((250,50)), parent = desktop2, text = "Resume Saved Game",style =self.button_style) self.resume_saved_level_button.onClick = self.resume_saved_level else: self.resume_button = gui.Button(position = threades.resize_pos((475,500)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Resume Game",style = self.button_style) self.resume_button.onClick = self.resume #Save Game Button if proceduralFlow.storyboard_level != 1: self.save_button = gui.Button(position = threades.resize_pos((475,430)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Save Current Level",style = self.button_style) self.save_button.onClick = self.save_current_level self.controls_button = gui.Button(position = threades.resize_pos((475,640)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Controls",style = self.button_style) self.exit_button = gui.Button(position = threades.resize_pos((475,710)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Exit",style = self.button_style) self.instructions_button = gui.Button(position = threades.resize_pos((475,570)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Guide",style = self.button_style) self.about_us_button = gui.Button(position = threades.resize_pos((1000,20)), size = threades.resize_pos((150,40)), parent = desktop2, text = "About Us",style = self.button_style) self.controls_button.onClick = self.controls self.exit_button.onClick = safe_exit self.instructions_button.onClick = self.instructionsWindow self.about_us_button.onClick = self.aboutUsWindow self.run = True
def main_menu(self,pause_flag = True, game_save_flag = False): self.init_game_save_flag = game_save_flag self.game_save_flag = False if threades.game_save_flag: self.init_game_save_flag = True logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() self.ff_logo = pygame.transform.scale(logo,threades.resize_pos((1128,171))) threades.screen.fill((0,0,0)) threades.screen.blit(self.ff_logo,threades.resize_pos((40,90))) # Font type myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) # Creating new button style buttonsurf = pygame.image.load(os.path.join('art','button_green.png')).convert_alpha() buttonsurf = pygame.transform.scale(buttonsurf, (36, threades.resize_pt_y(40))) self.button_style = gui.createButtonStyle(myfont,(0,0,0), buttonsurf,4,1,4,4,1,4,4,1,4,4,1,4) self.pause_flag = pause_flag if self.pause_flag: self.start_button = gui.Button(position = threades.resize_pos((475,500)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.start_new_game[0],style = self.button_style) self.start_button.onClick = self.select_save_or_new_game #Resume saved level button if a game is saved if self.init_game_save_flag == True: self.resume_saved_level_button = gui.Button(position = threades.resize_pos((475,430)),size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.resume_saved_game[0],style =self.button_style) self.resume_saved_level_button.onClick = self.select_save_or_new_game else: self.resume_button = gui.Button(position = threades.resize_pos((475,430)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.resume_game[0],style = self.button_style) self.resume_button.onClick = self.resume self.start_game_again_button = gui.Button(position = threades.resize_pos((475,500)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.start_game_again[0],style = self.button_style) self.start_game_again_button.onClick = self.storyboardWindow #Save Game Button if proceduralFlow.storyboard_level != 1: self.save_button = gui.Button(position = threades.resize_pos((475,360)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.save_current_level[0],style = self.button_style) self.save_button.onClick = self.save_current_level self.controls_button = gui.Button(position = threades.resize_pos((475,640)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.control_button_text[0],style = self.button_style) self.exit_button = gui.Button(position = threades.resize_pos((475,710)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.exit_button_text[0],style = self.button_style) self.instructions_button = gui.Button(position = threades.resize_pos((475,570)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.instructions_window_text[0],style = self.button_style) self.about_us_button = gui.Button(position = threades.resize_pos((1000,20)), size = threades.resize_pos((150,40)), parent = desktop2, text = model.text_file.about_button_text[0],style = self.button_style) self.controls_button.onClick = self.controls self.exit_button.onClick = safe_exit self.instructions_button.onClick = self.instructionsWindow self.about_us_button.onClick = self.aboutUsWindow self.run = True
def main_menu(self,pause_flag = True): ''' Display the starting menu ''' logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() self.ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250))) threades.screen.fill((0,0,0)) threades.screen.blit(self.ff_logo,threades.resize_pos((40,50))) # Font type myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) # Creating new button style buttonsurf = pygame.image.load(os.path.join('art','button_green.png')).convert_alpha() self.button_style = gui.createButtonStyle(myfont,(0,0,0), buttonsurf,4,1,4,4,1,4,4,1,4,4,1,4) self.pause_flag = pause_flag if self.pause_flag: self.start_button = gui.Button(position = threades.resize_pos((500,500)), size = threades.resize_pos((200,30)), parent = desktop2, text = "Start New Game",style = self.button_style) self.start_button.onClick = self.startup_text else: self.resume_button = gui.Button(position = threades.resize_pos((500,500)), size = threades.resize_pos((200,30)), parent = desktop2, text = "Resume Game",style = self.button_style) self.resume_button.onClick = self.resume #self.resume_button = gui.Button(position = threades.resize_pos((500,550)), size = threades.resize_pos((200,30)), parent = threades.desktop, text = "Resume Game",style = self.button_style) self.controls_button = gui.Button(position = threades.resize_pos((500,600)), size = threades.resize_pos((200,30)), parent = desktop2, text = "Controls",style = self.button_style) self.exit_button = gui.Button(position = threades.resize_pos((500,650)), size = threades.resize_pos((200,30)), parent = desktop2, text = "Exit",style = self.button_style) self.instructions_button = gui.Button(position = threades.resize_pos((500,550)), size = threades.resize_pos((200,30)), parent = desktop2, text = "Guide",style = self.button_style) self.about_us_button = gui.Button(position = threades.resize_pos((1000,20)), size = threades.resize_pos((150,30)), parent = desktop2, text = "About Us",style = self.button_style) #self.resume_button.onClick = self.resume self.controls_button.onClick = self.controls self.exit_button.onClick = safe_exit self.instructions_button.onClick = self.instructionsWindow self.about_us_button.onClick = self.aboutUsWindow self.run = True
def storyboardWindow(self,button = None): global select_flag self.remove_buttons() self.lightgreen_color = (0,80,0) self.green_color = (0,150,0) self.black_color = (0,0,0) myfont1 = pygame.font.Font('font.ttf',threades.resize_pt(50)) myfont = pygame.font.Font("font.ttf", threades.resize_pt(20)) buttonsurf = pygame.image.load(os.path.join('art','button_green.png')).convert_alpha() buttonsurf = pygame.transform.scale(buttonsurf, (38, threades.resize_pt_y(50))) self.button_style_2 = gui.createButtonStyle(myfont,(0,0,0), buttonsurf,4,1,4,4,1,4,4,1,4,4,1,4) win_style = gui.defaultWindowStyle.copy() win_style['font'] = myfont1 win_style['font-color'] = self.green_color win_style['bg-color'] = self.black_color win_style['border-color'] =self.black_color position_win = threades.resize_pos((150.0,270.0)) size_win = threades.resize_pos((900.0,650.0)) myfont2 = pygame.font.Font('font.ttf',threades.resize_pt(20)) labelstylecopy = gui.defaultLabelStyle.copy() labelstylecopy['font'] = myfont2 labelstylecopy['font-color'] = self.green_color labelstylecopy['border-width'] = 1 labelstylecopy['border-color'] = (0,0,0) labelstylecopy['autosize']=True labelstylecopy['wordwrap']=False op_image = pygame.image.load(os.path.join("art","optionbox_green.png")).convert_alpha() op_style = gui.createOptionBoxStyle(gui.defaultFont, op_image, 12, (255,255,255),(100,100,100), autosize = True) op_style['font'] = myfont2 op_style['font-color'] = self.green_color op_style['normal'] = True op_style['autosize'] = True op_style['word wrap'] = False self.op_style = op_style self.win = gui.Window(position = position_win,size = size_win,parent = desktop2,style = win_style,text = model.text_file.storyboard_window_text[0], closeable = False,shadeable = False,moveable = False ) self.win.onClose = self.main_menu vertical_dist = 150.0 #for the position of optionboxes vertical_dist_photo = 120.0 storyboard_list_file = open('storyboard_list.pkl') for i in range(pickle.load(storyboard_list_file)): storyboard_name = pickle.load(storyboard_list_file) if select_flag == True or os.path.exists(os.path.join('storyboards',str(storyboard_name[1]),'save_game.pkl')): self.image = pygame.image.load(os.path.join('storyboards',str(storyboard_name[1]),'intro_image.png')).convert_alpha() self.image = pygame.transform.scale(self.image, threades.resize_pos((150,120))) finalSurface = pygame.surface.Surface(threades.resize_pos((150,150))).convert_alpha() finalSurface.blit(self.image,threades.resize_pos((10,10))) self.win.surf.blit(finalSurface,threades.resize_pos((160,vertical_dist_photo))) self.item = gui.Button(position = threades.resize_pos((450.0,vertical_dist),(900.0,600.0),self.win.size),size = threades.resize_pos((290,50)),parent = self.win,text = str(storyboard_name[1]),style = self.button_style_2) self.item.onClick = self.select_storyboard vertical_dist = vertical_dist + 180 vertical_dist_photo = vertical_dist_photo + 180 self.skip_button = gui.Button(position = threades.resize_pos((180,490),(900.0,600.0),self.win.size), size = threades.resize_pos((110,30),(900.0,600.0),self.win.size), parent = self.win, text = model.text_file.skip_text[0],style = self.button_style) self.skip_button.onClick = self.close_win logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() ff_logo = pygame.transform.scale(logo,threades.resize_pos((1128,171))) self.storyboard_menu_run = True while self.storyboard_menu_run: pygame.display.set_caption('FoodForce2') threades.screen.fill((0,0,0)) threades.screen.blit(ff_logo,threades.resize_pos((40,90))) for e in gui.setEvents(pygame.event.get()): if e.type == KEYDOWN: if e.key == 27: # For escape key self.storyboard_menu_run = False self.win.close() if model.FLAG_XO: if e.type==mesh.CONNECT : game_sharing.sharing_handler(e.type,None,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,None,'']).start() elif e.type==mesh.PARTICIPANT_ADD or e.type==mesh.PARTICIPANT_REMOVE : game_sharing.sharing_handler(e.type,e.handle,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,'']).start() elif e.type==mesh.MESSAGE_MULTI or e.type==mesh.MESSAGE_UNI : game_sharing.sharing_handler(e.type,e.handle,e.content) #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,e.content]).start() desktop2.update() desktop2.draw() pygame.display.update()