Python pygame.K_1 Examples

The following are 4 code examples of pygame.K_1(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pygame , or try the search function .
Example #1
Source File: pyint.py    From Pyint_Pixel-Painter with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #2
Source File: kernal.py    From RoboMaster-AI-Challenge-Simulator-2D with MIT License 5 votes vote down vote up
def get_order(self): 
        # get order from controler
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return True
        pressed = pygame.key.get_pressed()
        if pressed[pygame.K_1]: self.n = 0
        if pressed[pygame.K_2]: self.n = 1
        if pressed[pygame.K_3]: self.n = 2
        if pressed[pygame.K_4]: self.n = 3
        self.orders[self.n] = 0
        if pressed[pygame.K_w]: self.orders[self.n, 0] += 1
        if pressed[pygame.K_s]: self.orders[self.n, 0] -= 1
        if pressed[pygame.K_q]: self.orders[self.n, 1] -= 1
        if pressed[pygame.K_e]: self.orders[self.n, 1] += 1
        if pressed[pygame.K_a]: self.orders[self.n, 2] -= 1
        if pressed[pygame.K_d]: self.orders[self.n, 2] += 1
        if pressed[pygame.K_b]: self.orders[self.n, 3] -= 1
        if pressed[pygame.K_m]: self.orders[self.n, 3] += 1
        if pressed[pygame.K_SPACE]: self.orders[self.n, 4] = 1
        else: self.orders[self.n, 4] = 0
        if pressed[pygame.K_f]: self.orders[self.n, 5] = 1
        else: self.orders[self.n, 5] = 0
        if pressed[pygame.K_r]: self.orders[self.n, 6] = 1
        else: self.orders[self.n, 6] = 0
        if pressed[pygame.K_n]: self.orders[self.n, 7] = 1
        else: self.orders[self.n, 7] = 0
        if pressed[pygame.K_TAB]: self.dev = True
        else: self.dev = False
        return False 
Example #3
Source File: view_convert_dataset.py    From costar_plan with Apache License 2.0 4 votes vote down vote up
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, ') 
Example #4
Source File: main.py    From python-examples with MIT License 4 votes vote down vote up
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()

# ---