Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
 def move_character_up(self):
     self._move_character(-1, 0)
     character.face_up()