Ejemplo n.º 1
0
def safe_exit(button = None):
    #print 'in safe_exit'
    #print 'in safe_exit'
    proceduralFlow.closeStoryBoardFile()
    soundtrack.stop()
    pygame.mixer.quit()
    pygame.quit()
    exit()
Ejemplo n.º 2
0
def safe_exit(button = None):
    #print 'in safe_exit'
    #print 'in safe_exit'
    proceduralFlow.closeStoryBoardFile()
    GameSounds.objMusic.stop_music()
    pygame.mixer.quit()
    pygame.quit()
    exit()
Ejemplo n.º 3
0
   def start_game_again(self,button=None):
 
       data_file = 'storyboards/storyboard1/data/data1.pkl'
       graphics_file = 'graphics_layout.pkl'
       level_obj.new_level_stats(data_file,graphics_file)
       self.remove_buttons()
       if soundtrack:
           soundtrack.stop()
       proceduralFlow.closeStoryBoardFile()
       self.run = False
       main()
Ejemplo n.º 4
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()
Ejemplo n.º 5
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()
Ejemplo n.º 6
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()
Ejemplo n.º 7
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)