コード例 #1
0
def safe_exit(button = None):
    threades.GAME_EXIT_FLAG = True
    
    if message_thread:
        message_thread.join()
    sleep(1)
    proceduralFlow.openStoryBoardFile()
    proceduralFlow.closeStoryBoardFile()
    threades.audio.stop_soundtrack()
    pygame.mixer.quit()
    pygame.quit()
    sys.exit()
コード例 #2
0
    def startup_text(self,button = None):
        threades.audio.play_music(True,'soundtrack')
        threades.current_level = 1
        self.remove_buttons()
        if proceduralFlow.storyboardfile:
            #closing the storyboard
            proceduralFlow.closeStoryBoardFile()
            #opening the storyboard again
        proceduralFlow.openStoryBoardFile()
	
        data_file = os.path.join('storyboards',str(model.storyboard_file),'data','data1.pkl')            
        graphics_file = 'graphics_layout.pkl'
        level_obj.new_level_stats(data_file,graphics_file) 
        model.game_controller.reset_time() 
        self.run = False
	threades.load_initial_facilities()
コード例 #3
0
 def set_selected_storyboard(self,button = None):
     
             
     storyBoardFileName = ""
     if self.storyboard1.value:
         storyBoardFileName = "storyboard.pkl"
         proceduralFlow.openStoryBoardFile(storyBoardFileName)
         self.sbWin.close()
     elif self.storyboard2.value:
         storyBoardFileName = "storyboard.pkl"
         proceduralFlow.openStoryBoardFile(storyBoardFileName)
         self.sbWin.close()
     else:
         print "return"
         return
     self.run = False
コード例 #4
0
def safe_exit(button = None):
    """
        Maintains safe exit from the game
    """
    #print 'in safe_exit'
    #print 'in safe_exit'
    threades.GAME_EXIT_FLAG = True
    if update_thread:
        update_thread.join()
    if message_thread:
        message_thread.join()
    sleep(1)
    proceduralFlow.openStoryBoardFile()
    proceduralFlow.closeStoryBoardFile()
    if soundtrack:
        soundtrack.stop()
    pygame.mixer.quit()
    pygame.quit()
    exit()
コード例 #5
0
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()
コード例 #6
0
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
コード例 #7
0
def load_resume_game():
   
    actiontemp = proceduralFlow.actionTemplate()
    actiontemp.actionType = 3
    proceduralFlow.openStoryBoardFile()
    action_obj = proceduralFlow.Actions(actiontemp)
コード例 #8
0
def event_handling(e):    
    #For the safe exit of the game
    if e.type == pygame.QUIT:
        safe_exit()
    if e.type == QUIT:
        safe_exit()
        
         #Updates the region
    if e.type == KEYDOWN:
        if e.key == 27:  # For escape key
            escape()
        if e.key == K_UP:
            threades.transform_obj.start_move('up')
        if e.key == K_DOWN:
            threades.transform_obj.start_move('down')
        if e.key == K_LEFT:
            threades.transform_obj.start_move('left')
        if e.key == K_RIGHT:
            threades.transform_obj.start_move('right')
        if e.key == K_f or e.key == 61:
            threades.transform_obj.focus()
        if e.key == K_d or e.key == 45:
            threades.transform_obj.defocus()
        if e.key == K_RETURN:
            gui_buttons.gui_obj.press_enter()
        
            #Tackles the cases of setting up a facility,upgrading a facility,buying and selling of resources
        win_flag = gui_buttons.gui_obj.get_win_flag()
        if not win_flag:
            if e.key == K_s and gui_buttons.gui_obj.setup_button.enabled:
                gui_buttons.gui_obj.setup_obj.setup()
            if e.key == K_u and gui_buttons.gui_obj.upgrade_button.enabled:
                gui_buttons.gui_obj.upgrade_obj.upgrade()
            if e.key == K_b and gui_buttons.gui_obj.buysell_button.enabled:
                gui_buttons.gui_obj.buysell_obj.buysell()
            
                #Resetting the game
    if proceduralFlow.GAME_END_FLAG:
        threades.PLACING_LIST_TEMP = []
        proceduralFlow.GAME_END_FLAG = False
        proceduralFlow.closeStoryBoardFile()
        proceduralFlow.openStoryBoardFile()
        threades.delete_saved_game()
        proceduralFlow.storyboard_level = 1
	data_file = os.path.join('storyboards',str(model.storyboard_file),'data','data1.pkl')
        proceduralFlow.load_level_obj.new_level_stats(data_file,'graphics_layout.pkl')
        event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0)
        game_events.EventQueue.add(event)
        model.game_controller.reset_time()
        pause_screen()
        
    if e.type == KEYUP:
        if e.key == K_UP:
            threades.transform_obj.stop_move('up')
        if e.key == K_DOWN:
            threades.transform_obj.stop_move('down')
        if e.key == K_LEFT:
            threades.transform_obj.stop_move('left')
        if e.key == K_RIGHT:
            threades.transform_obj.stop_move('right')

    x,y = pygame.mouse.get_pos()
    r = pygame.Rect(threades.resize_rect((0,40,930,560)))
    if gui_buttons.gui_obj.buysell_obj.get_win_flag():
        gui_buttons.gui_obj.buysell_obj.drawPriceChart()
    if r.collidepoint(x,y):
        
        if e.type == MOUSEBUTTONDOWN:
            if e.button == 1 and gui_buttons.gui_obj.get_child_win_flag():
                gui_buttons.gui_obj.setup_obj.bardisplay.updateChart((x,y))
            if e.button == 1 and gui_buttons.gui_obj.buysell_obj.get_win_flag():
                gui_buttons.gui_obj.buysell_obj.barObject.updateChart((x,y))
            if e.button == 4:
                threades.transform_obj.focus()
            if e.button == 5:
                threades.transform_obj.defocus()
    if model.FLAG_XO:
        
        if e.type==mesh.CONNECT :
            game_sharing.sharing_handler(e.type,None,'')
        elif e.type==mesh.PARTICIPANT_ADD or e.type==mesh.PARTICIPANT_REMOVE :
            game_sharing.sharing_handler(e.type,e.handle,'')
        elif e.type==mesh.MESSAGE_MULTI or e.type==mesh.MESSAGE_UNI :
            game_sharing.sharing_handler(e.type,e.handle,e.content)
コード例 #9
0
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()