def facility_placement(): """ Checks the collision and if the place is free builds the facility at that particular position """ (x,y) = (0,0) x,y = pygame.mouse.get_pos() gui_buttons.gui_obj.setup_button.enabled = False facility_name = threades.buildFacilityPlacementFlag #Sets the variable to the facility which is to be build for i in range(len(model.Facility_Size)): if model.Facility_Size[i][0] == facility_name: height = model.Facility_Size[i][1] width = model.Facility_Size[i][2] height_temp = threades.resize_pt_y((model.Facility_Size[i][1])*threades.transform_obj.ratio) width_temp = threades.resize_pt_x((model.Facility_Size[i][2])*threades.transform_obj.ratio) #Checking the bounds if x > threades.resize_pt_x(930): pygame.mouse.set_pos(threades.resize_pt_x(930),y) if y > threades.resize_pt_y(600): pygame.mouse.set_pos(x,threades.resize_pt_y(600)) #Creating the rectangle in which the facility is built rect = (x,y,width,height) rect_temp = (x,y,width_temp,height_temp) rect_obj = pygame.Rect(rect) rect_obj_temp = pygame.Rect(rect_temp) #Checks the collision collide_check = threades.place_facility_collide_check(rect_obj) if collide_check: color = (205,0,0) else: color = (205,200,100) pygame.draw.rect(threades.screen,color,rect_obj_temp,5) #Takes action of the user and performs the action l,m,r = pygame.mouse.get_pressed() if l == 1 and collide_check == False: (a,b) = threades.transform_obj.inverse_trans_cordinate((x,y)) rect_obj_send = pygame.Rect((a,b,width_temp,height_temp)) PLACING_DATA_LIST = [threades.buildFacilityPlacementFlag,rect_obj_send] threades.build_placed_facility(threades.buildFacilityPlacementFlag,False,PLACING_DATA_LIST) threades.set_build_facility_placement_flag() gui_buttons.gui_obj.setup_button.enabled = True if r == 1: threades.set_build_facility_placement_flag() gui_buttons.gui_obj.setup_button.enabled = True
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 facility_placement(): (x,y) = (0,0) x,y = pygame.mouse.get_pos() gui_buttons.gui_obj.setup_button.enabled = False facility_name = threades.buildFacilityPlacementFlag for i in range(len(model.Facility_Size)): if model.Facility_Size[i][0] == facility_name: height = model.Facility_Size[i][1] width = model.Facility_Size[i][2] height_temp = threades.resize_pt_y((model.Facility_Size[i][1])*threades.transform_obj.ratio) width_temp = threades.resize_pt_x((model.Facility_Size[i][2])*threades.transform_obj.ratio) if x > threades.resize_pt_x(930): pygame.mouse.set_pos(threades.resize_pt_x(930),y) if y > threades.resize_pt_y(600): pygame.mouse.set_pos(x,threades.resize_pt_y(600)) x -= width_temp/2 y -= height_temp/2 rect = (x,y,width,height) rect_temp = (x,y,width_temp,height_temp) rect_obj = pygame.Rect(rect) rect_obj_temp = pygame.Rect(rect_temp) collide_check = threades.place_facility_collide_check(rect_obj) if collide_check: color = (205,0,0) else: color = (205,200,100) pygame.draw.rect(threades.screen,color,rect_obj_temp,5) l,m,r = pygame.mouse.get_pressed() if l == 1 and collide_check == False: (a,b) = threades.transform_obj.inverse_trans_cordinate((x,y)) rect_obj_send = pygame.Rect((a,b,width_temp,height_temp)) PLACING_DATA_LIST = [threades.buildFacilityPlacementFlag,rect_obj_send] threades.build_placed_facility(threades.buildFacilityPlacementFlag,False,PLACING_DATA_LIST) threades.set_build_facility_placement_flag() gui_buttons.gui_obj.setup_button.enabled = True if r == 1: threades.set_build_facility_placement_flag() gui_buttons.gui_obj.setup_button.enabled = 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(): global panel global chat_screen global level_setting # Displaying the WFP logo intro_thread = threading.Thread(target = load_images.load_images, args=[]) intro_thread.start() # Loading and starting the sound play GameSounds.objMusic.start_music() level_setting=level_change.change_level() pause_screen() intro_thread.join() threades.initialize_facilities() #surface_middle = pygame.transform.scale(surface3,threades.resize_pos((1200,560))) # Processing regarding the storyboard proceduralFlow.openStoryBoardFile() storyboardObj = proceduralFlow.storyboardFlow() proceduralFlow.openStoryBoardFile() gui_buttons.initialize_gui() threades.screen.fill((0,0,0)) panel = display_panel.display_panel() animation_obj = threades.Animation() animation_obj.update() # Starting of the threads update_thread = threading.Thread(target = threades.update_turn, args=[]).start() message_thread = threading.Thread(target = message_window, args=[]).start() mouse_flag = False chat_screen=chat.chat() model.game_controller.reset_time() # The main infinite loop while True: #clock.tick() model.game_controller.update_level_time() mouse_flag = False (x,y) = (0,0) x,y = pygame.mouse.get_pos() if ((x < threades.new_screen_size[0]) and (x > (threades.new_screen_size[0]-60))): threades.transform_obj.move_free((0,0)) if (x < 60 and x > 0): threades.transform_obj.move_free((0,0)) if (y < threades.resize_pt_y(900)) and (y > threades.resize_pt_y(840)): threades.transform_obj.move_free((0,0)) if ((y < threades.resize_pt_y(60)) and (y > threades.resize_pt_y(0))): threades.transform_obj.move_free((0,0)) if (x > threades.resize_pt_x(0)) and (x < threades.resize_pt_x(600)) and (y > threades.resize_pt_y(845)) and (y < threades.resize_pt_y(900)): mouse_flag = True pygame.display.set_caption('FoodForce2') for e in gui.setEvents(pygame.event.get()): event_handling(e) #pygame.draw.rect(threades.screen,(209,169,106),threades.resize_rect((0,40,1200,560))) animation_obj.update() # Claculate indicators again threades.calculate_indicators_starting() #For middle surface #surface_middle = pygame.transform.scale(surface3,threades.resize_pos((1200,560))) #threades.screen.blit(surface_middle,threades.resize_pos((0,40))) rects_list = get_update_region() panel.update() if (threades.total_update_flag or threades.map_update_flag or threades.facilities_update_flag or threades.panel_update_flag or panel.res.money_flag): threades.desktop.update() threades.desktop.draw() pygame.display.update(rects_list) model.iteration_time = clock.tick() model.global_time += model.iteration_time storyboardObj.flow()
def main(): for arg in sys.argv[1:]: process(arg) select_lang() global panel global chat_screen global level_setting global message_thread cursor = pygame.cursors.load_xbm(os.path.join('art', 'ff2_cursor.xbm'),os.path.join('art', 'ff2_cursor-mask.xbm')) #print cursor pygame.mouse.set_cursor(cursor[0],cursor[1],cursor[2],cursor[3]) # Displaying the WFP logo intro_thread = threading.Thread(target = load_images.load_images, args=[]) intro_thread.start() # Loading and starting the sound play threades.audio.play_music(False,'soundtrack') threades.check_saved_game_level() model.game_controller.reset_time() gui_buttons.initialize_gui() pause_screen() intro_thread.join() proceduralFlow.storyboard_level = threades.current_level if threades.current_level != 1: load_resume_game() else: threades.load_initial_facilities() data_file = os.path.join('storyboards',str(model.storyboard_file),'data','data1.pkl') model.init_cons(data_file) model.init_obj() threades.initialize_facilities(True) proceduralFlow.openStoryBoardFile() # loading the correct data file #gui_buttons.initialize_gui() threades.screen.fill((0,0,0)) #panel = display_panel.display_panel() panel.change_labels() animation_obj = threades.Animation() animation_obj.update() # Starting of the threads #print update_thread message_thread = threading.Thread(target = message_window, args=[]) message_thread.start() mouse_flag = False chat_screen=chat.chat() #print 'i was here' clock = pygame.time.Clock() threades.total_update_flag = True # The main infinite loop while True: time_passed = clock.tick() model.game_controller.update_level_time(threades.update_thread_pause) threades.update_turn(time_passed) animation_obj.update() mouse_flag = False (x,y) = (0,0) x,y = pygame.mouse.get_pos() if not gui_buttons.gui_obj.get_win_flag(): if len(threades.buildFacilityPlacementFlag): facility_placement() if (x > (threades.resize_pt_x(890)) and x < threades.resize_pt_x(930)) and y< threades.resize_pt_y(600): threades.transform_obj.move_free((-10,0)) if x < threades.resize_pt_x(60) and y< threades.resize_pt_y(600): threades.transform_obj.move_free((10,0)) if y > threades.resize_pt_y(560) and y< threades.resize_pt_y(600) and x < threades.resize_pt_x(930): threades.transform_obj.move_free((0,-10)) if y < threades.resize_pt_y(60) and x < threades.resize_pt_x(930) and x < threades.resize_pt_x(930): threades.transform_obj.move_free((0,10)) if (x > threades.resize_pt_x(0)) and (x < threades.resize_pt_x(600)) and (y > threades.resize_pt_y(845)) and (y < threades.resize_pt_y(900)): mouse_flag = True pygame.display.set_caption('FoodForce2') for e in gui.setEvents(pygame.event.get()): event_handling(e) # Calculate the values of the indicators threades.calculate_indicators_starting() rects_list = get_update_region() panel.update() if (threades.total_update_flag or threades.map_update_flag or threades.facilities_update_flag or threades.panel_update_flag or panel.res.money_flag): threades.desktop.update() threades.desktop.draw() pygame.display.update(rects_list) model.iteration_time = time_passed model.global_time += model.iteration_time storyboardObj.flow() gui_buttons.instruction_off_flag = False
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()
def startup_text(self,button = None): ''' Displays the startup text ''' self.remove_buttons() threades.screen.fill((255,255,255)) hunger_map = pygame.image.load(os.path.join('data', 'Wfpwork.png')).convert() hunger_map = pygame.transform.scale(hunger_map,threades.new_screen_size) threades.screen.blit(hunger_map,threades.resize_pos((0,0))) color_brown = (255,214,150) # gui.Window custom style myfont = pygame.font.Font("font.ttf", threades.resize_pt(28)) win_style = gui.defaultWindowStyle.copy() win_style['font'] = myfont win_style['font-color'] = color_brown win_style['bg-color'] = (0,0,0) win_style['border-color'] = color_brown position_win =threades.resize_pos((200.0,50.0)) size_win =threades.resize_pos((800.0,600.0)) win = gui.Window(position = position_win, size = size_win, parent = desktop2, text = " FOODFORCE II : ESCAPING POVERTY " ,style = win_style,shadeable = False, closeable = False,moveable = False) self.startup_text_run = True win.surf.set_alpha(100) myfont2 = pygame.font.Font("font.ttf",threades.resize_pt(19)) labelstyle1 = gui.defaultLabelStyle.copy() labelstyle1['border-width'] = 0 labelstyle1['wordwrap'] = True labelstyle1['autosize'] = False labelstyle1['font'] = myfont2 labelstyle1['font-color'] = color_brown counter = 0 label = gui.Label(position = threades.resize_pos((10.0,130.0),(800.0,600.0),win.size),size = threades.resize_pos((780.0,460.0),(800.0,600.0),win.size), parent = win, text = '', style = labelstyle1) button_style = gui.defaultButtonStyle.copy() button_style['font'] = myfont2 self.skip_button = gui.Button(position = threades.resize_pos((600,550),(800.0,600.0),win.size), size = threades.resize_pos((150,30),(800.0,600.0),win.size), parent = win, text = " Skip ",style = button_style) self.skip_button.onClick = self.turnoff_startup_run model.global_time = 0 #One time show of the background image threades.screen.fill((255,255,255)) threades.screen.blit(hunger_map,threades.resize_pos((0,0))) pygame.display.flip() #sleep(5) first_display = True model.global_time = 0 while self.startup_text_run: label.text = texts.trailer_text[counter] for e in gui.setEvents(pygame.event.get()): if e.type == pygame.QUIT: safe_exit() if e.type == KEYDOWN: if e.key == 27: # For escape key self.startup_text_run = False if e.key == K_RETURN: counter += 1 if model.global_time >= 5000: first_display = False model.global_time = 0 counter += 1 if not first_display: threades.screen.fill((255,255,255)) threades.screen.blit(hunger_map,threades.resize_pos((0,0))) desktop2.update() desktop2.draw() pygame.display.flip() if counter == len(texts.trailer_text): self.startup_text_run = False model.iteration_time = clock.tick() model.global_time += model.iteration_time win.close() # Creating gui to select which storyboard to start self.sbWin = gui.Window(position = position_win, size = size_win, parent = desktop2, text = " FOODFORCE II : Choose Storyboard " ,style = win_style,shadeable = False, closeable = False,moveable = False) self.sbWin.surf.fill((0,0,0,170)) # creating custom style for option box op_style = gui.defaultOptionBoxStyle.copy() op_style['font'] = myfont2 op_style['font-color'] = color_brown op_style['autosize'] = True op_style['word wrap'] = False position_optionbox = threades.resize_pos((200.0,150.0),(800.0,600.0),size_win) self.storyboard1 = gui.OptionBox(position = position_optionbox, parent = self.sbWin, style = op_style, text = 'Storyboard1') self.storyboard2 = gui.OptionBox(position = self.sbWin.nextPosition(threades.resize_pt_y(10)), parent = self.sbWin, style = op_style, text = 'Storyboard2') # Creating a button style button_style = gui.defaultButtonStyle.copy() button_style['font'] = myfont2 self.select_button = gui.Button(position = threades.resize_pos((600,550),(800.0,600.0),size_win), size = threades.resize_pos((150,30),(800.0,600.0),size_win), parent = self.sbWin, text = " Select ",style = button_style) self.select_button.onClick = self.set_selected_storyboard
def main(): global panel global chat_screen global level_setting global update_thread global message_thread cursor = pygame.cursors.load_xbm(os.path.join('art', 'ff2_cursor.xbm'),os.path.join('art', 'ff2_cursor-mask.xbm')) #print cursor pygame.mouse.set_cursor(cursor[0],cursor[1],cursor[2],cursor[3]) # Displaying the WFP logo intro_thread = threading.Thread(target = load_images.load_images, args=[]) intro_thread.start() # Loading and starting the sound play #level_setting=level_change.change_level() #Checks the level on which he user is threades.current_level = threades.check_saved_game_level() #Resets the time model.game_controller.reset_time() #Initialises and creates the starting screen and pauses the game until the user gives an input pause_screen() #Lets the initial thread started to get completed intro_thread.join() proceduralFlow.storyboard_level = threades.current_level #Takes action according to the level if threades.current_level != 1: load_resume_game() else: threades.initialize_facilities(True) proceduralFlow.openStoryBoardFile() # Processing regarding the storyboard storyboardObj = proceduralFlow.storyboardFlow() gui_buttons.initialize_gui() threades.screen.fill((0,0,0)) panel = display_panel.display_panel() animation_obj = threades.Animation() animation_obj.update() # Starting of the threads update_thread = threading.Thread(target = threades.update_turn, args=[]) update_thread.start() #print update_thread message_thread = threading.Thread(target = message_window, args=[]) message_thread.start() mouse_flag = False chat_screen=chat.chat() # The main infinite loop while True: #clock.tick() model.game_controller.update_level_time(threades.update_thread_pause) animation_obj.update() mouse_flag = False (x,y) = (0,0) x,y = pygame.mouse.get_pos() if len(threades.buildFacilityPlacementFlag): facility_placement() if (x > (threades.resize_pt_x(890)) and x < threades.resize_pt_x(930)): threades.transform_obj.move_free((-10,0)) if x < threades.resize_pt_x(60) : threades.transform_obj.move_free((10,0)) if y > threades.resize_pt_y(560) and y< threades.resize_pt_y(600): threades.transform_obj.move_free((0,-10)) if y < threades.resize_pt_y(60): threades.transform_obj.move_free((0,10)) if (x > threades.resize_pt_x(0)) and (x < threades.resize_pt_x(600)) and (y > threades.resize_pt_y(845)) and (y < threades.resize_pt_y(900)): mouse_flag = True pygame.display.set_caption('FoodForce2') for e in gui.setEvents(pygame.event.get()): event_handling(e) # Calculate the values of the indicators threades.calculate_indicators_starting() #updating the region rects_list = get_update_region() panel.update() if (threades.total_update_flag or threades.map_update_flag or threades.facilities_update_flag or threades.panel_update_flag or panel.res.money_flag): threades.desktop.update() threades.desktop.draw() pygame.display.update(rects_list) #updates the time model.iteration_time = clock.tick() model.global_time += model.iteration_time #Calls the function which decides which action to be taken storyboardObj.flow()