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


Python pygame.K_0屬性代碼示例

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


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

示例1: new_demo

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import K_0 [as 別名]
def new_demo(test=True):
    import pygame
    from demo.game import Game
    
    if test is False:
        game = Game(640, 480, None)
    else:
        def _render(game):
            while True:
                game.draw()
                for event in pygame.event.get():
                    if event.type == pygame.KEYDOWN:
                        if event.key == pygame.K_9:
                            game.increase_fps()
                        elif event.key == pygame.K_0:
                            game.decrease_fps()    
        pygame.init()
        DISPLAYSURF = pygame.display.set_mode((640, 480), 0, 32)
        pygame.display.set_caption('Demo')
        game = Game(640, 480, DISPLAYSURF)
        t = Thread(target=lambda: _render(game))
        t.start()
    
    return game 
開發者ID:PacktPublishing,項目名稱:Python-Reinforcement-Learning-Projects,代碼行數:26,代碼來源:environment.py

示例2: new_demo

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import K_0 [as 別名]
def new_demo(test=False):
    
    import pygame
    from demo.game import Game
    if test is False:
        game = Game(640, 480, None)
    else:
        def _render(game):
            while True:
                game.draw()
                for event in pygame.event.get():
                    if event.type == pygame.KEYDOWN:
                        if event.key == pygame.K_9:
                            game.increase_fps()
                        elif event.key == pygame.K_0:
                            game.decrease_fps()    
        pygame.init()
        DISPLAYSURF = pygame.display.set_mode((640, 480), 0, 32)
        pygame.display.set_caption('Demo')
        game = Game(640, 480, DISPLAYSURF)
        t = Thread(target=lambda: _render(game))
        t.start()
    
    parameter = Parameter(lr=1e-3)
    parameter.gamma = 0.9
    parameter.iteration_num = 300000
    parameter.num_history_frames = 1
    parameter.network_type = 'mlp'
    
    parameter.update_method = 'rmsprop'
    parameter.rho = 0.95
    parameter.async_update_interval = 5
    parameter.input_scale = 1.0
    
    return game, parameter 
開發者ID:PacktPublishing,項目名稱:Python-Reinforcement-Learning-Projects,代碼行數:37,代碼來源:environment.py

示例3: test_name

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import K_0 [as 別名]
def test_name(self):
        self.assertEqual(pygame.key.name(pygame.K_RETURN), "return")
        self.assertEqual(pygame.key.name(pygame.K_0), "0")
        self.assertEqual(pygame.key.name(pygame.K_SPACE), "space") 
開發者ID:wistbean,項目名稱:fxxkpython,代碼行數:6,代碼來源:key_test.py

示例4: wait_for_keypress_to_select_label

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import K_0 [as 別名]
def wait_for_keypress_to_select_label(progress_bar):
    """
    # Returns

      description, comment.
    """
    progress_bar.write(
        "\nPress a key to label the file: 1. success, 2. failure, 4. skip, 5. Extra Cool Example, 6. Problem with this Example 0. whoops! make previous file unconfirmed \n"
        "What to look for:\n"
        " - A successful stack is 3 blocks tall or 4 blocks tall with the gripper completely removed from the field of view.\n"
        " - If the tower is 3 blocks tall and blocks will clearly slide off if not for the wall press 2 for 'failure',\n"
        "   if it is merely in contact with a wall, press 1 for 'success'."
        " - When the robot doesn't move but there is already a visible successful stack, that's an error.failure.falsely_appears_correct, so press 1 for 'success'!\n"
        " - If you can see the gripper, the example is a failure even if the stack is tall enough!\n")
    # , 3: error.failure
    flag = 0
    comment = 'none'
    mark_previous_unconfirmed = None
    while flag == 0:
        # pygame.event.pump()
        events = pygame.event.get()
        # if len(events) > 0:
        #     print(events)
        for event in events:
            if event.type == pygame.QUIT:
                pygame.quit()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_1:
                    progress_bar.write("label set to success")
                    flag = 1
                    return "success", comment, mark_previous_unconfirmed
                elif event.key == pygame.K_2:
                    progress_bar.write("label set to failure")
                    flag = 1
                    return "failure", comment, mark_previous_unconfirmed
                # elif event.key == pygame.K_3:
                #     progress_bar.write("label set to error.failure")
                #     flag = 1
                #     return "error.failure"
                elif event.key == pygame.K_4:
                    flag = 1
                    return 'skip', comment, mark_previous_unconfirmed
                elif event.key == pygame.K_5:
                    comment = 'extra_cool_example'
                    progress_bar.write('comment added: extra_cool_example (this note will remove past notes)')
                elif event.key == pygame.K_6:
                    comment = 'problem_with_example'
                    progress_bar.write('comment added: problem_with_example (this note will remove past notes)')
                elif event.key == pygame.K_0:
                    mark_previous_unconfirmed = True
                    progress_bar.write(
                        'Thanks for mentioning there is a problem with the selection for the previous example.'
                        'We will clear that data so the example will appear again when you re-run the label correction.'
                        'Jut to be extra safe, we also suggest you write down the exact filename '
                        'of the previous example so you can check it manually, ') 
開發者ID:jhu-lcsr,項目名稱:costar_plan,代碼行數:57,代碼來源:view_convert_dataset.py

示例5: display_cube

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import K_0 [as 別名]
def display_cube():
    WINDOW_WIDTH = 800
    WINDOW_HEIGHT = 600

    pygame.init()
    pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), pygame.DOUBLEBUF | pygame.OPENGL)
    
    OpenGL.GLU.gluPerspective(45, (WINDOW_WIDTH/WINDOW_HEIGHT), 0.1, 50.0)
    OpenGL.GL.glTranslatef(0.0, 0.0, -10)
    
    show_cube_1 = True
    show_cube_2 = True
    show_lines = True
    
    running = True
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    running = False
                elif event.key == pygame.K_1:
                    show_cube_1 = not show_cube_1
                elif event.key == pygame.K_2:
                    show_cube_2 = not show_cube_2
                elif event.key == pygame.K_0:
                    show_lines = not show_lines
                    
                    
        OpenGL.GL.glRotate(1, 3, 10, 10) # (angle,x,y,z)
        OpenGL.GL.glClear(OpenGL.GL.GL_COLOR_BUFFER_BIT | OpenGL.GL.GL_DEPTH_BUFFER_BIT)

        if show_cube_1:
            cube(vertices1, edges) # large cube
        if show_cube_2:
            cube(vertices2, edges) # small cube
        if show_lines:
            lines(vertices1, vertices2)
        
        pygame.display.flip()
        pygame.time.wait(10)

    pygame.quit()

# --- 
開發者ID:furas,項目名稱:python-examples,代碼行數:48,代碼來源:main.py


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