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


Python pygame.KMOD_CTRL属性代码示例

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


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

示例1: keydown_mod_ctrl

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import KMOD_CTRL [as 别名]
def keydown_mod_ctrl(key, inlist=True):
        """
        Create a mod ctrl keydown event (Ctrl+Key).

        :param key: Key to press
        :type key: int
        :param inlist: Return event in a list
        :type inlist: bool
        :return: Event
        :rtype: :py:class:`pygame.event.Event`
        """
        pygame.key.set_mods(pygame.KMOD_CTRL)
        event_obj = pygame.event.Event(pygame.KEYDOWN,
                                       {'key': key,
                                        'test': True,
                                        })
        if inlist:
            event_obj = [event_obj]
        return event_obj 
开发者ID:ppizarror,项目名称:pygame-menu,代码行数:21,代码来源:_utils.py

示例2: _pygame_update_modifiers

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import KMOD_CTRL [as 别名]
def _pygame_update_modifiers(self, mods=None):
        # Available mod, from dir(pygame)
        # 'KMOD_ALT', 'KMOD_CAPS', 'KMOD_CTRL', 'KMOD_LALT',
        # 'KMOD_LCTRL', 'KMOD_LMETA', 'KMOD_LSHIFT', 'KMOD_META',
        # 'KMOD_MODE', 'KMOD_NONE'
        if mods is None:
            mods = pygame.key.get_mods()
        self._modifiers = []
        if mods & (pygame.KMOD_SHIFT | pygame.KMOD_LSHIFT):
            self._modifiers.append('shift')
        if mods & (pygame.KMOD_ALT | pygame.KMOD_LALT):
            self._modifiers.append('alt')
        if mods & (pygame.KMOD_CTRL | pygame.KMOD_LCTRL):
            self._modifiers.append('ctrl')
        if mods & (pygame.KMOD_META | pygame.KMOD_LMETA):
            self._modifiers.append('meta') 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:18,代码来源:window_pygame.py

示例3: _handle_mods

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import KMOD_CTRL [as 别名]
def _handle_mods(self) -> None:
        """Update key mods"""
        mods = pygame.key.get_mods()
        self._modifiers.shift = mods & pygame.KMOD_SHIFT
        self._modifiers.ctrl = mods & pygame.KMOD_CTRL
        self._modifiers.alt = mods & pygame.KMOD_ALT 
开发者ID:moderngl,项目名称:moderngl-window,代码行数:8,代码来源:window.py

示例4: find_fullscreen_event

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import KMOD_CTRL [as 别名]
def find_fullscreen_event(self, events):
        """Return the first found event if found in the list.
        """
        for event in events:
            if event.type == pygame.KEYDOWN and \
                    event.key == pygame.K_f and pygame.key.get_mods() & pygame.KMOD_CTRL:
                return event
        return None 
开发者ID:pibooth,项目名称:pibooth,代码行数:10,代码来源:booth.py

示例5: find_print_event

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import KMOD_CTRL [as 别名]
def find_print_event(self, events):
        """Return the first found event if found in the list.
        """
        for event in events:
            if event.type == pygame.KEYDOWN and event.key == pygame.K_e\
                        and pygame.key.get_mods() & pygame.KMOD_CTRL:
                return event
            if event.type == pygame.MOUSEBUTTONUP and event.button in (1, 2, 3):
                # Don't consider the mouse wheel (button 4 & 5):
                rect = self._window.get_rect()
                if pygame.Rect(rect.width // 2, 0, rect.width // 2, rect.height).collidepoint(event.pos):
                    return event
            if event.type == BUTTONDOWN and event.printer:
                return event
        return None 
开发者ID:pibooth,项目名称:pibooth,代码行数:17,代码来源:booth.py

示例6: test_set_and_get_mods

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import KMOD_CTRL [as 别名]
def test_set_and_get_mods(self):
        pygame.key.set_mods(pygame.KMOD_CTRL)
        self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL)

        pygame.key.set_mods(pygame.KMOD_ALT)
        self.assertEqual(pygame.key.get_mods(), pygame.KMOD_ALT)
        pygame.key.set_mods(pygame.KMOD_CTRL | pygame.KMOD_ALT)
        self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL | pygame.KMOD_ALT) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:10,代码来源:key_test.py

示例7: run

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import KMOD_CTRL [as 别名]
def run(self):
        # The main game loop
        #
        while True:
            # Limit frame speed to 30 FPS
            #
            time_passed = self.clock.tick(30)
            #~ time_passed = self.clock.tick()
            #~ print time_passed
            
            # If too long has passed between two frames, don't
            # update (the game must have been suspended for some
            # reason, and we don't want it to "jump forward"
            # suddenly)
            #
            if time_passed > 100:
                continue
            
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    self.quit()
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_SPACE:
                        self.paused = not self.paused
                    elif event.key == pygame.K_g:
                        if pygame.key.get_mods() & pygame.KMOD_CTRL:
                            self.options['draw_grid'] = not self.options['draw_grid']
                elif (  event.type == pygame.MOUSEBUTTONDOWN and
                        event.button == 1):
                    for creep in self.creeps:
                        creep.mouse_click_event(event.pos)
            
            if not self.paused:
                msg1 = 'Creeps: %d' % len(self.creeps)
                msg2 = ''

                self.mboard_text = [msg1, msg2]
                
                self.creep_spawn_timer.update(time_passed)
                
                # Update and all creeps
                for creep in self.creeps:
                    creep.update(time_passed)
                    
                self.draw()
                
            pygame.display.flip() 
开发者ID:eliben,项目名称:code-for-blog,代码行数:49,代码来源:creeps.py


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