コード例 #1
0
ファイル: game.py プロジェクト: Esum/rpg
def game_loop(window: sf.RenderWindow, player: int, input_clock=sf.Clock()):
    moving = 0
    running = conf.auto_run
    menu = False
    cursor = 0
    direction = world.Direction.DOWN
    battle = None
    while True:
        for event in window.events:
            if event.type == sf.Event.RELEASED:
                window.close()
                exit()
        if battle is not None:
            draw.draw_battle(window, player, battle)
            window.display()
        else:
            if moving:
                moving -= 2 + int(running)
                if moving <= 0:
                    moving = 0
                    world.activate_walk_event(player)
            elif menu:
                if input.key.key_pressed(input.key.Key.DOWN, input_clock):
                    cursor = (cursor + 1) % 3
                elif input.key.key_pressed(input.key.Key.UP, input_clock):
                    cursor = (cursor - 1) % 3
                elif input.key.key_pressed(input.key.Key.MENU, input_clock):
                    menu = False
            else:
                if input.key.key_pressed(input.key.Key.RIGHT, input_clock):
                    moving, direction, battle = world.move_player(player, world.Direction.RIGHT)
                elif input.key.key_pressed(input.key.Key.UP, input_clock):
                    moving, direction, battle = world.move_player(player, world.Direction.UP)
                elif input.key.key_pressed(input.key.Key.LEFT, input_clock):
                    moving, direction, battle = world.move_player(player, world.Direction.LEFT)
                elif input.key.key_pressed(input.key.Key.DOWN, input_clock):
                    moving, direction, battle = world.move_player(player, world.Direction.DOWN)
                elif input.key.key_pressed(input.key.Key.MENU, input_clock):
                    menu = True
            draw.draw_game(window, player, moving, direction.value)
            if menu:
                draw.draw_game_menu(window, player, cursor)
            window.display()
            music.play_music(player)
コード例 #2
0
ファイル: menu.py プロジェクト: Esum/rpg
def game_menu(window: sf.RenderWindow, identifier: int):
    cursor = 0
    while True:
        for event in window.events:
            if event.type == sf.Event.RELEASED:
                break
        if sf.Keyboard.is_key_pressed(sf.Keyboard.DOWN):
            cursor = (cursor + 1) % 5
        elif sf.Keyboard.is_key_pressed(sf.Keyboard.UP):
            cursor = (cursor - 1) % 5
        if sf.Keyboard.is_key_pressed(sf.Keyboard.RETURN):
            if cursor == 0: #items
                pass
            if cursor == 1: #equipments
                pass
            if cursor == 2: #jobs
                pass
            if cursor == 3: #state
                pass
            if cursor == 4: #options
                pass
        if sf.Keyboard.is_key_pressed(sf.Keyboard.ESCAPE):
            break
        draw.draw_game_menu(window, identifier, cursor)