コード例 #1
0
ファイル: main.py プロジェクト: RabidGuy/Delphi-Flexus
def main(stdscr):
    color.init_color_pairs()
    screen = Screen(stdscr)  # Use default size.
    world = World()  # Use default size.
    while True:
        screen.clear()
        screen.update_dimensions()
        view = world.get_view_over_character(screen.lines, screen.cols)
        screen.update_view(view)
        screen.refresh()

        event = screen.get_keyboard_event()
        # Quit game on Esc. key.
        if event == 27:
            break

        # Inspect target on spacebar or enter.
        if event == 32 or event == 10:
            target = world.get_character_target()
            screen.text_box(target.inspect_text)

        # Move character and change facing.
        elif event == ord('w'):
            world.move_character_up()
        elif event == ord('s'):
            world.move_character_down()
        elif event == ord('a'):
            world.move_character_left()
        elif event == ord('d'):
            world.move_character_right()

        # Change character facing without moving.
        elif event == ord('W'):
            character.face_up()
        elif event == ord('S'):
            character.face_down()
        elif event == ord('A'):
            character.face_left()
        elif event == ord('D'):
            character.face_right()

        # Do nothing.
        else:
            pass
コード例 #2
0
ファイル: world.py プロジェクト: RabidGuy/Delphi-Flexus
 def move_character_left(self):
     self._move_character(0, -1)
     character.face_left()