Exemple #1
0
def redraw():
    global g
    global chasing
    g.clear_screen()
    g.display_player_stats()
    print(f"Position: {g.player.pos[0]},{g.player.pos[1]}")
    # if not DEBUG:
    g.display_board()
    if chasing:
        Utils.print_white_on_red("Guard is chasing!!!")
Exemple #2
0
    refresh_screen()
    notifications.clear()
    g.actuate_npcs(g.current_level)
    # Here we do everything related to the first level.
    if g.current_level == 1:
        whale_behavior()
        portal_fairy_behavior()
    # Now, let's take care of the case where player's life is down to zero or worst.
    if g.player.hp <= 0:
        # First, does he have a Scroll of Wisdom. If yes we save him and warn him that next time he is dead.
        if len(g.player.inventory.search("Scroll of Wisdom")) > 0:
            # To do so we set the HP back to the maximum
            g.player.hp = g.player.max_hp
            # Warn the player
            print( Utils.red_bright('You have been saved by the Scroll of Wisdom, be careful next time you will die!') )
            # And consume the scroll in the process
            g.player.inventory.delete_item("Scroll of Wisdom")
        else:
            # If he doesn't, well... Death is the sentence and that's game over.
            g.clear_screen()
            Utils.print_white_on_red(f"\n\n\n\t{g.player.name} is dead!\n\t      ** Game over **     \n\n")
            g.change_level(999)
            g.display_board()
            break
    # Finally if the amount of turn left in level 2 is 0 we exit with a message
    if level_2_turns_left == 0:
        g.clear_screen()
        print_animated(f"{Sprites.UNICORN_FACE}: Congratulations Mighty Wizard!\n{Sprites.UNICORN_FACE}: The whales are happy and the sheep are patrolling!\n{Sprites.UNICORN_FACE}: You also got {Utils.green_bright(str(g.player.inventory.value()+(g.player.hp*100)))} points!\n{Sprites.UNICORN_FACE}: Try to do even better next time.\n\n{Sprites.UNICORN_FACE}: Thank you for playing!\n")
        break
    key = Utils.get_key()
Exemple #3
0
            g.timer -= 5.0


def adapt_resolution(g):
    global term, term_res
    if term.width >= 140:
        term_res = 140
    else:
        term_res = 80
    g.partial_display_viewport = [10, int(term_res / 4)]


# We need the hac-game-lib v1.1+
if Constants.HAC_GAME_LIB_VERSION < "1.1.0":
    Utils.print_white_on_red(
        "Super Panda Run EX require the hac-game-lib version 1.1.0 or greater."
        f" Version installed is {Constants.HAC_GAME_LIB_VERSION}")
    raise SystemExit()

g = Game()
g.enable_partial_display = True
g.partial_display_viewport = [10, int(term_res / 4)]
g.current_level = 0
g.player = Player(model=bg_color + Graphics.Sprites.PANDA +
                  Graphics.Style.RESET_ALL)
g.player.name = "Zigomar"
g.player.max_y = g.player.pos[0]
g.player.dy = gravity_speed
g.player.last_y = g.player.pos[0]
g.player.last_x = g.player.pos[1]
g.timer = 60
Exemple #4
0
g.player = Player(name="The Mighty Wizard", model=Sprites.MAGE)
g.change_level(1)

guards = []

for item in g.current_board().get_movables(type="guard"):
    guards.append(item)

nm = None
key = None
chasing = False

while nm != Constants.NO_DIR:
    if g.player.hp <= 0:
        g.clear_screen()
        Utils.print_white_on_red("GAME OVER")
        break
    r = g.player.pos[0]
    c = g.player.pos[1]
    if key == Utils.key.UP:
        g.move_player(Constants.UP, 1)
    elif key == Utils.key.DOWN:
        g.move_player(Constants.DOWN, 1)
    elif key == Utils.key.RIGHT:
        g.move_player(Constants.RIGHT, 1)
    elif key == Utils.key.LEFT:
        g.move_player(Constants.LEFT, 1)
    elif key == "Q":
        break
    for guard in guards:
        if g.player in g.neighbors(5, guard):