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

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

项目:AIFun    作者:Plottel    | 项目源码 | 文件源码
def init():
    add_key(pygame.K_w)
    add_key(pygame.K_s)
    add_key(pygame.K_a)
    add_key(pygame.K_d)
    add_key(pygame.K_c)
    add_key(pygame.K_r)
    add_key(pygame.K_q)
    add_key(pygame.K_e)
    add_key(pygame.K_g)
    add_key(pygame.K_t)


# Adds a new key to be tracked for input
项目:AIFun    作者:Plottel    | 项目源码 | 文件源码
def init():
    add_key(pygame.K_w)
    add_key(pygame.K_s)
    add_key(pygame.K_a)
    add_key(pygame.K_d)
    add_key(pygame.K_c)
    add_key(pygame.K_r)
    add_key(pygame.K_q)
    add_key(pygame.K_e)
    add_key(pygame.K_g)
    add_key(pygame.K_t)


# Adds a new key to be tracked for input
项目:AIFun    作者:Plottel    | 项目源码 | 文件源码
def handle_mouse_input(tileset):
    tile = None

    if tileset.is_at_mouse_pos():
        tile = tileset.tile_at_mouse_pos()

    # Add column to Tileset
    if Input.key_typed(pygame.K_c):
        tileset.add_columns(1)

    # Add row to Tileset
    if Input.key_typed(pygame.K_r):
        tileset.add_rows(1)

    # Make Tile at mouse position not passable
    if Input.left_mouse_down:
        if tileset.is_at_mouse_pos():
            tile.passable = False
            tile.color = Renderer.COLOR_BLACK

    # Make Tile at mouse position passable
    if Input.right_mouse_down:
        if tileset.is_at_mouse_pos():
            tile.passable = True
            tile.color = (128, 128, 128)

    if Input.key_typed(pygame.K_q):
        if tileset.is_at(Input.mouse_x(), Input.mouse_y()):
            tile.passable = True
            tile.color = Renderer.COLOR_GREEN
            GenAlg.start_node = tile
            TileInteractor.start_node = tile

    if Input.key_typed(pygame.K_e):
        if tileset.is_at_mouse_pos():
            tile.passable = True
            tile.color = Renderer.COLOR_RED
            GenAlg.end_node = tile
            TileInteractor.end_node = tile

    if Input.key_typed(pygame.K_g):
        GenAlg.init()


# This is used for framerate