當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。