當前位置: 首頁>>代碼示例>>Python>>正文


Python pygame.K_LCTRL屬性代碼示例

本文整理匯總了Python中pygame.K_LCTRL屬性的典型用法代碼示例。如果您正苦於以下問題:Python pygame.K_LCTRL屬性的具體用法?Python pygame.K_LCTRL怎麽用?Python pygame.K_LCTRL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在pygame的用法示例。


在下文中一共展示了pygame.K_LCTRL屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: key_event_up

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import K_LCTRL [as 別名]
def key_event_up(event):
    global penSize, undoed, holdingCTRL, colorScheme, selectedTool


    if event.key == pg.K_1:
        colorScheme = 1
    elif event.key == pg.K_2:
        colorScheme = 2

    if event.key == pg.K_e:
        selectedTool = 1
        B_Buttons[1].clicked = True
        for subbutton in B_Buttons:
            if B_Buttons.index(subbutton) != selectedTool:
                subbutton.clicked = False
    elif event.key == pg.K_b:
        selectedTool = 0
        B_Buttons[0].clicked = True
        for subbutton in B_Buttons:
            if B_Buttons.index(subbutton) != selectedTool:
                subbutton.clicked = False
    elif event.key == pg.K_g:
        selectedTool = 2
        B_Buttons[2].clicked = True
        for subbutton in B_Buttons:
            if B_Buttons.index(subbutton) != selectedTool:
                subbutton.clicked = False
    elif event.key == pg.K_i:
        selectedTool = 3
        B_Buttons[3].clicked = True
        for subbutton in B_Buttons:
            if B_Buttons.index(subbutton) != selectedTool:
                subbutton.clicked = False

    if event.key == pg.K_LCTRL:
        holdingCTRL = False

    if event.key == pg.K_SPACE:
        if holdingCTRL:
            g1.clean()
            undoed = True

    if event.key == pg.K_s:
        if holdingCTRL:
            shortcutPath = FileManager(1)
            SaveFile(g1, shortcutPath)

    if event.key == pg.K_z:
        if holdingCTRL:

            for i in range(g1.yCount):
                for j in range(g1.xCount):
                    if round == 1:
                        g1.change_color(j, i, g1.undoList[1][i][j])
                    if round == -1:
                        g1.change_color(j, i, g1.undoList[0][i][j])
            undoed = True 
開發者ID:Burakcoli,項目名稱:Pyint_Pixel-Painter,代碼行數:59,代碼來源:pyint.py

示例2: run

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import K_LCTRL [as 別名]
def run(self):

        self.initialize()
        
        while self.running:
        
            # update input state (down, pressed, up)
            self.input.update()
    
            if self.input.quit():
                self.running = False

            # debug tools
            
            # print FPS (Ctrl+F)
            if (self.input.isKeyPressed(pygame.K_LCTRL) or self.input.isKeyPressed(pygame.K_RCTRL)) and self.input.isKeyDown(pygame.K_f):
                fps = self.clock.get_fps()
                print( "FPS: " + str(int(fps)) )
                
            # save screenshot (Ctrl+S)
            if (self.input.isKeyPressed(pygame.K_LCTRL) or self.input.isKeyPressed(pygame.K_RCTRL)) and self.input.isKeyDown(pygame.K_s):
                timeString = str( int(1000 * time.time()) )
                fileName = "image-" + timeString + ".png"
                pygame.image.save(self.screen, fileName)
                
            self.deltaTime = self.clock.get_time() / 1000.0
            
            self.update()
            
            # display image on screen
            pygame.display.flip()

            # limit to 60 FPS
            self.clock.tick(60)

        # end of program
        pygame.quit()
        sys.exit() 
開發者ID:stemkoski,項目名稱:three.py,代碼行數:40,代碼來源:Base.py


注:本文中的pygame.K_LCTRL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。