Python pygame 模块,K_z() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用pygame.K_z()

项目:Arkon    作者:UnkDevE    | 项目源码 | 文件源码
def run(self):
        while self.visible & this.drawing:
            # wait for event
            event = pygame.event.wait()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_DOWN:
                    self.select_previous()
                elif event.key == pygame.K_LEFT:
                    self.select_previous()
                elif event.key == pygame.K_RETURN:
                    self.activate()
                elif event.key == pygame.K_z:
                    self.activate()
                elif event.key == pygame.K_x:
                    self.previous_menu()
                elif event.key == pygame.K_RIGHT:
                    self.select_next()

    # runs self, as well as show.
项目:third_person_im    作者:bstadie    | 项目源码 | 文件源码
def _Keyboard_Event(self, key, down=True):
        """
        Internal keyboard event, don't override this.

        Checks for the initial keydown of the basic testbed keys. Passes the
        unused ones onto the test via the Keyboard() function.
        """
        if down:
            if key == pygame.K_z:       # Zoom in
                self.viewZoom = min(2 * self.viewZoom, 500.0)
            elif key == pygame.K_x:     # Zoom out
                self.viewZoom = max(0.9 * self.viewZoom, 0.02)
项目:rllabplusplus    作者:shaneshixiang    | 项目源码 | 文件源码
def _Keyboard_Event(self, key, down=True):
        """
        Internal keyboard event, don't override this.

        Checks for the initial keydown of the basic testbed keys. Passes the
        unused ones onto the test via the Keyboard() function.
        """
        if down:
            if key == pygame.K_z:       # Zoom in
                self.viewZoom = min(2 * self.viewZoom, 500.0)
            elif key == pygame.K_x:     # Zoom out
                self.viewZoom = max(0.9 * self.viewZoom, 0.02)
项目:pytetris    作者:catalinc    | 项目源码 | 文件源码
def process_input(self):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
            if event.type == pygame.KEYDOWN:
                if self.state.paused:
                    if event.key == pygame.K_r:
                        self.state.paused = False
                if self.state.game_over:
                    if event.key == pygame.K_r:
                        self.state = State(self.ROWS, self.COLS)
                    if event.key == pygame.K_ESCAPE:
                        sys.exit()
                if self.state.running:
                    if event.key == pygame.K_DOWN:
                        self.state.move_piece(board.DIRECTION_DOWN)
                    if event.key == pygame.K_LEFT:
                        self.state.move_piece(board.DIRECTION_LEFT)
                    if event.key == pygame.K_RIGHT:
                        self.state.move_piece(board.DIRECTION_RIGHT)
                    if event.key == pygame.K_x:
                        self.state.rotate_piece()
                    if event.key == pygame.K_z:
                        self.state.rotate_piece(True)
                    if event.key == pygame.K_SPACE:
                        self.state.drop_piece()
                    if event.key == pygame.K_p:
                        self.state.paused = True
项目:Snakis    作者:fbessou    | 项目源码 | 文件源码
def __init__(self):
        self._mapping = [
                { # Player 
                    pygame.K_d:"right",
                    pygame.K_s:"down",
                    pygame.K_q:"left",
                    pygame.K_z:"up"
                },
                { # Player 1
                    pygame.K_RIGHT:"right",
                    pygame.K_DOWN:"down",
                    pygame.K_LEFT:"left",
                    pygame.K_UP:"up"
                }
        ]
项目:Arkon    作者:UnkDevE    | 项目源码 | 文件源码
def run(self):
        # while no other GUI elements are visible or not in battle
        while this.drawing & (not (this.text_box_visible | this.text_menu_visible | this.inbattle)):
            pygame.event.pump()

            event = pygame.event.poll()

            if event.type == pygame.KEYDOWN:
                # get keys pressed using pygame.key.get_pressed() as it is more continous than events.
                if event.key == pygame.K_LCTRL:
                    # seperate hide and show buttons as they would counteract eachother.
                    self.player_menu.show()
                elif event.key == pygame.K_z:
                    self.activate()
                elif event.key == pygame.K_f:
                    # quick testing key to find if the battles work has to be with a background
                    #  where Lucidia Bright is present.
                    battle(self, this.onscreen_sprites["Lucida Bright"])

            pygame.time.delay(5)

            keys = pygame.key.get_pressed()

            if keys[pygame.K_UP]:
                self.facing("backward")
                self.move(0, -1)
            elif keys[pygame.K_DOWN]:
                self.facing("forward")
                self.move(0, 1)
            elif keys[pygame.K_LEFT]:
                self.facing("left")
                self.move(-1, 0)
            elif keys[pygame.K_RIGHT]:
                self.facing("right")
                self.move(1, 0)
项目:gail-driver    作者:sisl    | 项目源码 | 文件源码
def _Keyboard_Event(self, key, down=True):
        """
        Internal keyboard event, don't override this.

        Checks for the initial keydown of the basic testbed keys. Passes the
        unused ones onto the test via the Keyboard() function.
        """
        if down:
            if key == pygame.K_z:       # Zoom in
                self.viewZoom = min(2 * self.viewZoom, 500.0)
            elif key == pygame.K_x:     # Zoom out
                self.viewZoom = max(0.9 * self.viewZoom, 0.02)
项目:rllab    作者:rll    | 项目源码 | 文件源码
def _Keyboard_Event(self, key, down=True):
        """
        Internal keyboard event, don't override this.

        Checks for the initial keydown of the basic testbed keys. Passes the
        unused ones onto the test via the Keyboard() function.
        """
        if down:
            if key == pygame.K_z:       # Zoom in
                self.viewZoom = min(2 * self.viewZoom, 500.0)
            elif key == pygame.K_x:     # Zoom out
                self.viewZoom = max(0.9 * self.viewZoom, 0.02)
项目:GameToy    作者:rukai    | 项目源码 | 文件源码
def keyEvent(self, event):
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_DOWN:
                self.down = 0
            if event.key == pygame.K_UP:
                self.up = 0
            if event.key == pygame.K_LEFT:
                self.left = 0
            if event.key == pygame.K_RIGHT:
                self.right = 0
            if event.key == pygame.K_a:
                self.start = 0
            if event.key == pygame.K_s:
                self.select = 0
            if event.key == pygame.K_x:
                self.b = 0
            if event.key == pygame.K_z:
                self.a = 0

        if event.type == pygame.KEYUP:
            if event.key == pygame.K_DOWN:
                self.down = 1
            if event.key == pygame.K_UP:
                self.up = 1
            if event.key == pygame.K_LEFT:
                self.left = 1
            if event.key == pygame.K_RIGHT:
                self.right = 1
            if event.key == pygame.K_a:
                self.start = 1
            if event.key == pygame.K_s:
                self.select = 1
            if event.key == pygame.K_x:
                self.b = 1
            if event.key == pygame.K_z:
                self.a = 1
项目:maml_rl    作者:cbfinn    | 项目源码 | 文件源码
def _Keyboard_Event(self, key, down=True):
        """
        Internal keyboard event, don't override this.

        Checks for the initial keydown of the basic testbed keys. Passes the
        unused ones onto the test via the Keyboard() function.
        """
        if down:
            if key == pygame.K_z:       # Zoom in
                self.viewZoom = min(2 * self.viewZoom, 500.0)
            elif key == pygame.K_x:     # Zoom out
                self.viewZoom = max(0.9 * self.viewZoom, 0.02)
项目:pytari2600    作者:ajgrah2000    | 项目源码 | 文件源码
def handle_events(self, event):
        if event.type== pygame.KEYDOWN:
            if event.key   == pygame.K_UP:
                self.swcha ^= 0x10
            elif event.key == pygame.K_DOWN:
                self.swcha ^= 0x20
            elif event.key == pygame.K_LEFT:
                self.swcha ^= 0x40
                self.paddle0 = 1
            elif event.key == pygame.K_RIGHT:
                self.swcha ^= 0x80
                self.paddle0 = -1
            elif event.key == pygame.K_s: # Game select
                self.swchb ^= 0x1
            elif event.key == pygame.K_r: # Game reset
                self.swchb ^= 0x2
            elif event.key == pygame.K_1:
                self.swchb ^= 0x40
                print("P0 dificulty %s"%(("hard", "easy")[self.swchb & 0x40 != 0]))
            elif event.key == pygame.K_2:
                self.swchb ^= 0x80
                print("P1 dificulty %s"%(("hard", "easy")[self.swchb & 0x80 != 0]))
            elif event.key == pygame.K_c: # toggle black and white
                self.swchb ^= 0x8
            elif event.key == pygame.K_z: # toggle black and white
                self.input7 &= 0x7F
            elif event.key == pygame.K_q: # Dodgy quit
                self.quit = 0x1
                pygame.quit()
                sys.exit()

            # Custom key events
            elif event.key   == pygame.K_LEFTBRACKET:
                self._save_state = 0x1
            elif event.key   == pygame.K_RIGHTBRACKET:
                self._restore_state = 0x1
        elif event.type== pygame.KEYUP:
            if event.key   == pygame.K_UP:
                self.swcha |= 0x10
            elif event.key == pygame.K_DOWN:
                self.swcha |= 0x20
            elif event.key == pygame.K_LEFT:
                self.swcha |= 0x40
                self.paddle0 = 0
            elif event.key == pygame.K_RIGHT:
                self.swcha |= 0x80
                self.paddle0 = 0
            elif event.key == pygame.K_s: # Game select
                self.swchb |= 0x1
            elif event.key == pygame.K_r: # Game reset
                self.swchb |= 0x2
            elif event.key == pygame.K_z: # toggle black and white
                self.input7 |= 0x80

            # Custom key events
            elif event.key   == pygame.K_LEFTBRACKET:
                self._save_state = 0x0
            elif event.key   == pygame.K_RIGHTBRACKET:
                self._restore_state = 0x0