当前位置: 首页>>代码示例>>Python>>正文


Python Match.draw方法代码示例

本文整理汇总了Python中match.Match.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Match.draw方法的具体用法?Python Match.draw怎么用?Python Match.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在match.Match的用法示例。


在下文中一共展示了Match.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Sce_Match

# 需要导入模块: from match import Match [as 别名]
# 或者: from match.Match import draw [as 别名]
class Sce_Match(Scene):
    '''
    classdocs
    '''

    def __init__(self, director, background_match):
        '''
        Constructor
        '''
        Scene.__init__(self, director, background_match)        
        self.match = Match()
        self.scene_winner =  Sce_Winner(director, 'winner', MATCH_SCENE)
        self.c_fails = 0
        
        self.match.generate_table()
        for buttom in self.common_buttoms.itervalues():
            buttom.is_visible = True

    def on_update(self):
        self.time = self.director.time 
        
        if not self.is_failed:
            self.update()
            
            for key_function, function in self.match.functions.iteritems():
                if not function.is_correct:                                                      
                    if function.is_pressed:
                        function.is_mark = True 
                        function.line.point_end = pygame.mouse.get_pos()
                        break
                        
                    if function.is_mark:                
                        for key_element, element in self.match.elements.iteritems():
                            if element.is_pressed and not element.is_mark:
                                if key_function==key_element:
                                    print "key_function: "+key_function
                                    print "key_element: "+key_element
                                    point_end = element.rect.midleft
                                    function.line.point_end = point_end
                                    function.is_correct = True
                                    function.is_mark = False
                                    element.is_mark = True
                                    break
                                else:
                                    self.c_fails += 1
                                    if self.c_fails >= 4:
                                        self.c_fails = 0
                                        self.is_failed = True
                                        
                                    element.is_pressed = False
                        function.is_mark = False
                               
            self.is_complete = self.match.check_complete()

    def on_event(self, event):
        self.event(event)
        
        if event.type == pygame.MOUSEBUTTONDOWN: 
            mouse_pos = pygame.mouse.get_pos()            
            for function in self.match.functions.itervalues():
                function.pressed(mouse_pos)
                
        elif event.type == pygame.MOUSEBUTTONUP:            
            for function in self.match.functions.itervalues():
                if function.is_pressed and not function.is_correct:            
                    for element in self.match.elements.itervalues():
                        mouse_pos = pygame.mouse.get_pos()
                        element.pressed(mouse_pos)
                    function.release()
                    break
                    
                        

    def on_draw(self, screen):
        self.draw(screen)       
        self.match.draw(screen)
        for function in self.match.functions.itervalues(): 
            if function.is_pressed or function.is_correct:
                pygame.draw.line(screen,function.line.color,function.line.point_init, function.line.point_end,3)
        
        if self.is_failed:
            screen.blit(self.failed_img, self.failed_rect)          
开发者ID:NightZpy,项目名称:QuimicaDidactica,代码行数:84,代码来源:sce_match.py

示例2:

# 需要导入模块: from match import Match [as 别名]
# 或者: from match.Match import draw [as 别名]
        difficulty=int(configuration["difficulty"])
        nb_players_team=int(configuration["nb_players_team"])
        match_length=int(configuration["duration"])
        west_team_index,east_team_index=0,1
        (teamA_filename,west_team_index,teamB_filename,east_team_index)=select_teams(display,nesfont,mainClock,west_team_index,east_team_index)
        if (teamA_filename=="?"):
            configuration["exit_menu"]="no"
            
        
    
    #players_human_teamA,players_human_teamB,difficulty,nb_players_team,match_length,teamA_filename,teamB_filename=call_all_menus(display,nesfont,mainClock)

    match=Match(teamA_filename,teamB_filename)
    match.show_loading(display,nesfont)   
    match.init(players_human_teamA,nb_players_team,players_human_teamB,nb_players_team,difficulty,match_length)
    
    while not match.is_finished:
        screen = display.get_surface()
        
        if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            match.is_finished=True
        
        match.update()
        
        match.draw(screen,nesfont)
        
        display.update()
        mainClock.tick(50)
    
    
开发者ID:andru255,项目名称:pyNekketsu,代码行数:30,代码来源:pyNekketsu.py


注:本文中的match.Match.draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。