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


Python Match.generate_table方法代码示例

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


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

示例1: Sce_Match

# 需要导入模块: from match import Match [as 别名]
# 或者: from match.Match import generate_table [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


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