Beispiel #1
0
 def construct_store_screen(self):
     """ Clears screen and input, prints store owner & available gold."""
     common.clear()
     print_centre(animations.get("Shopkeep"))
     print_centre("{}:\t{} gold".format(self.hero.name, self.hero.gold))
     print_centre("Welcome to my store! How may I serve you today?\n")
     common.flush_input()
Beispiel #2
0
 def set_key(self):
     """ Key press is recorded in self.direction variable if it is valid."""
     ch = self.record_keypress()
     if ch in ["w", "W", "a", "A", "s", "S", "d", "D"]:
         self.direction = ch
         return ch
     elif ch in ["x", "X"]:
         sys.exit()
     else:
         clear()
         self.print_controls()
         self.set_key()
Beispiel #3
0
def animate_overworld(overworld, hero):
    """ Overworld animation that moves character upon key press."""
    n = 0
    while n != 1:
        clear()
        overworld.key_press.print_controls()
        overworld.field.render_field()
        overworld.key_press.set_key()
        overworld.move_hero()
        if (overworld.field.x == overworld.field.x_store
                and overworld.field.y == overworld.field.y_store):
            StoreSequence(hero).execute()
        n = random.randint(1, 20)
 def construct_battle_screen(self):
     """ Clears screen and input, prints characters stats and animations."""
     common.clear()
     print_centre(self.enemy.animation)
     print_centre("\n{}\n{}\n".format(self.hero, self.enemy))
     common.flush_input()
Beispiel #5
0
def battle_animation():
    """ Animation that precedes battle."""
    for battle in ["battle", "Battle!", "BATTLE!!!"]:
        clear()
        print_middle(battle)
        time.sleep(0.4)
Beispiel #6
0
def title_animation():
    """ Show game title screen for a few seconds."""
    clear()
    print_middle(animations["Title"])
    time.sleep(3)
Beispiel #7
0
def resize_terminal(height, width):
    clear()
    sys.stdout.write("\x1b[8;{rows};{cols}t".format(rows=height, cols=width))
    # below code prevents title animation from printing off-centre.
    print("")
    time.sleep(0.1)