Пример #1
0
def blit_dialogues():
    """
        Draw dialogues onto the screen.
    """
    if len(player.dialogues) > 0:
        libtcod.console_clear(0)
        dlg = player.dialogues[-1]
        if dlg.npc_picture:
            icon = libtcod.image_load(os.path.join('data', 'images', dlg.npc_picture))
        else:
            icon = libtcod.image_load(os.path.join('data', 'images', 'icon-%s.png' % (dlg.npc_name)))
        frame = libtcod.image_load(os.path.join('data', 'images', 'dialogue-frame.png'))
        libtcod.image_blit_rect(frame, 0, 0, 0, -1, -1, libtcod.BKGND_SET)
        libtcod.image_blit_rect(icon, 0, C.MAP_LEFT, C.MAP_TOP, -1, -1, libtcod.BKGND_SET)
        # title
        libtcod.console_print_ex(0, 2 + (C.MAP_WIDTH / 2), 2,
                            libtcod.BKGND_NONE, libtcod.CENTER, 
                            "%c%s says:%c" % (C.COL4, dlg.npc_name, C.COLS))
#        # the message
#        libtcod.console_print_ex(0, 2 + (C.MAP_WIDTH / 2), C.MAP_TOP + 4,
#                            libtcod.BKGND_NONE, libtcod.CENTER, 
#                            "\"%c%s%c\"" % (C.COL5, dlg.dialogue, C.COLS))
        try:
            libtcod.console_print_rect(
                    0, 4, 6, C.MAP_WIDTH - 4, C.MAP_HEIGHT - 2,
                    "%s" % (dlg.dialogue))
        except e:
            print('dialogue string format error: %s' % (e))

        # press space
        libtcod.console_print_ex(0, 2 + (C.MAP_WIDTH / 2), 
                            C.SCREEN_HEIGHT - 1, 
                            libtcod.BKGND_NONE, libtcod.CENTER, 
                            "(spacebar or enter...)")
Пример #2
0
def blit_about():
    libtcod.console_clear(0)
    icon = libtcod.image_load(os.path.join('data', 'images', 'about-frame.png'))
    libtcod.image_blit_rect(icon, 0, 0, 0, -1, -1, libtcod.BKGND_SET)
    try:
        readme = file('README', 'r')
    except IOError, e:
        libtcod.console_print_ex(0, 2, 2,
                        libtcod.BKGND_NONE, libtcod.LEFT, 
                        "Error: about file not found :'(")
        return None
Пример #3
0
def blit_lost():
    libtcod.console_clear(0)
    frame = libtcod.image_load(os.path.join('data', 'images', 'dialogue-frame.png'))
    libtcod.image_blit_rect(frame, 0, 0, 0, -1, -1, libtcod.BKGND_SET)
    icon = libtcod.image_load(os.path.join('data', 'images', 'icon-paw.png'))
    libtcod.image_blit_rect(icon, 0, C.MAP_LEFT, C.MAP_TOP, -1, -1, libtcod.BKGND_SET)
    libtcod.console_print_ex(0, C.SCREEN_WIDTH / 2, 4,
                        libtcod.BKGND_NONE, libtcod.CENTER, \
                        "Ouch! You lost all your health.\n\n" \
                        "You rest to retry this level.\n\n" \
                        "(press space to try again)")
Пример #4
0
def blit_victory():
    libtcod.console_clear(0)
    frame = libtcod.image_load(os.path.join('data', 'images', 'about-frame.png'))
    libtcod.image_blit_rect(frame, 0, 0, 0, -1, -1, libtcod.BKGND_SET)
    results = ["You won, Top Dog!"]
    results.append("You moved %s times." % (player.moves))
    results.append("You drank %s puddles." % (player.quenches))
    results.append("You took %s bites." % (player.bites_taken))
    results.append("You ate %s treats." % (player.treats_eaten))
    results.append("You piddled %s times." % (player.piddles_taken))
    results.append("Your score is %s!" % (player.score))
    results.append("Well Done ^_^")
    libtcod.console_print_ex(0, C.SCREEN_WIDTH / 2, 4,
                        libtcod.BKGND_NONE, libtcod.CENTER, "\n\n".join(results))
Пример #5
0
def blit_menu():
    libtcod.console_clear(0)
    icon = libtcod.image_load(os.path.join('data', 'images', 'intro.png'))
    libtcod.image_blit_rect(icon, 0, 0, 0, -1, -1, libtcod.BKGND_SET)
    text = [
        "version %s" % (C.VERSION)
        ,"%cA%cbout" % (C.COL1, C.COLS)
        ,"%cspace%c to continue"  % (C.COL4, C.COLS)
        ]
    libtcod.console_print_ex(0, 2, 45,
                        libtcod.BKGND_NONE, libtcod.LEFT, 
                        "\n".join(text))
    libtcod.console_print_ex(0, C.SCREEN_WIDTH / 2, 24,
                        libtcod.BKGND_NONE, libtcod.CENTER, 
                        "in 'The Lost Puppy'")
Пример #6
0
def blit_help():
    """
        Show help.
    """
    libtcod.console_clear(0)
    icon = libtcod.image_load(os.path.join('data', 'images', 'stats-frame.png'))
    libtcod.image_blit_rect(icon, 0, C.MAP_LEFT, C.MAP_TOP, -1, -1, libtcod.BKGND_SET)
    
    libtcod.console_print_ex(0, C.SCREEN_WIDTH / 2, 2,
                        libtcod.BKGND_NONE, libtcod.CENTER, 
                        "%cTop Dog%c\nv%s\n^_^" % (C.COL5, C.COLS, C.VERSION))
                            

#    helptext = ["%c%s%s" % (C.COL5, C.COLS, C.VERSION)]
    helptext = ["The %cPuppy%c has been kidnapped by the %cFat Cat Mafioso%c. You travel from yard to yard, searching for the crafty Cats!" % (C.COL4, C.COLS, C.COL1, C.COLS)]
    
    helptext.append("\nYou are the %c@%c sign. Walk into other animals to interact with them." % (C.COL3, C.COLS))
    helptext.append("\n%cKEYPAD%c" % (C.COL5, C.COLS))
    helptext.append("\nUse the %cKeypad%c to move, this is preferred as \
diagonals are the dog's bark. Keypad 5 shows your stats, as does [i]nfo. The %cARROW%c keys also move you." \
        % (C.COL4, C.COLS, C.COL4, C.COLS))

    helptext.append("\n%cACTIONS%c" % (C.COL5, C.COLS))
    helptext.append("\n[%cd%c]rink water" % (C.COL5, C.COLS))
    helptext.append("[%ce%c]at food" % (C.COL5, C.COLS))
    helptext.append("[%cp%c]piddle to relieve yourself" % (C.COL5, C.COLS))
    helptext.append("[%ci%c]nfo screen: stats and quests" % (C.COL5, C.COLS))

    helptext.append("\nThe keypad also map to actions, use this mnemonic to remember:")
    helptext.append("\n%cD%crink and %cD%civide\n%cE%cat and %cM%cultiply\n%cP%ciddling %cS%coothes ;)" % (C.COL1, C.COLS, C.COL1, C.COLS
                , C.COL2, C.COLS, C.COL2, C.COLS
                , C.COL3, C.COLS, C.COL3, C.COLS))

    helptext.append("\nNow go find that %cPuppy!%c" % (C.COL5, C.COLS))
    helptext.append("\nWOOF!")

    libtcod.console_print_rect(0, 4, 10, C.MAP_WIDTH - 4, C.MAP_HEIGHT - 2,
                        "\n".join(helptext))
Пример #7
0
def blit_player_stats():
    """
        Draw player stats and quests screen.
    """
    libtcod.console_clear(0)
    icon = libtcod.image_load(os.path.join('data', 'images', 'stats-frame.png'))
    libtcod.image_blit_rect(icon, 0, C.MAP_LEFT, C.MAP_TOP, -1, -1, libtcod.BKGND_SET)
    
    if player.carrying:
        if player.carrying.quest_id:
            inv_item = "%c%s%c\n%c*quest item*%c" % \
                (C.COL3, player.carrying.name, C.COLS, C.COL4, C.COLS)
        else:
            inv_item = "%c%s%c" % (C.COL3, player.carrying.name, C.COLS)
    else:
        inv_item = ""
    
    labels = (
        ""
        ,""
        ,"%clevel%c:" % (C.COL5, C.COLS)
        ,"%cscore%c:" % (C.COL5, C.COLS)
        ,"%cmoves%c:" % (C.COL5, C.COLS)
        ,"%cinventory%c:" % (C.COL5, C.COLS)
        )
    values = [
        "%cTop Dog%c" % (C.COL5, C.COLS)
        ,""
        ,str(player.level)
        ,str(player.score)
        ,str(player.moves)
        ,inv_item
    ]
    
    # name, score, inventory
    libtcod.console_print_ex(0, C.STATS_SCREEN_LEFT, C.STATS_SCREEN_TOP,
                        libtcod.BKGND_NONE, libtcod.RIGHT, 
                        "\n".join(labels))

    libtcod.console_print_ex(0, C.STATS_SCREEN_LEFT + 2, C.STATS_SCREEN_TOP,
                        libtcod.BKGND_NONE, libtcod.LEFT, 
                        "\n".join(values))
    
    # quests
    values = []
    if len(player.quests) > 0:
        values = ["%cQUESTS%c\n" % (C.COL5, C.COLS)]
    for q in player.quests:
        values.append("+ %s" % (q.title))
    
    # hungry, thirsty, piddle, inventory
    if player.weak:
        values.append("+ %cweak%c, [e]at food" % (C.COL1, C.COLS))
    if player.hungry:
        values.append("+ %chungry%c, [e]at *food*" % (C.COL2, C.COLS))
    if player.thirsty:
        values.append("+ %cthirsty%c, [d]rink water" % (C.COL2, C.COLS))
    libtcod.console_print_ex(0, 4, C.SCREEN_HEIGHT / 2,
                        libtcod.BKGND_NONE, libtcod.LEFT, 
                        "\n".join(values))

    
    
    # player hearts
    if player.weak:
        heart_colors = [libtcod.red]* 10
    else:
        heart_colors = (libtcod.red, libtcod.red, libtcod.orange, libtcod.orange
                        , libtcod.amber, libtcod.amber, libtcod.lime, libtcod.lime
                        , libtcod.chartreuse, libtcod.chartreuse)
    for heart in range(player.get_hearts()):
        libtcod.console_put_char_ex(
                        0, heart + C.STAT_HEART_LEFT, C.STAT_HEART_TOP
                        ,chr(3), heart_colors[heart], None)
Пример #8
0
def blit_playtime():
    """
        Draw canvas and screens onto the display.
    """
    libtcod.image_blit_rect(mullions, 0, 0, 0, -1, -1, libtcod.BKGND_SET)
    libtcod.console_blit(canvas, 0, 0, C.MAP_WIDTH, C.MAP_HEIGHT, 0, C.MAP_LEFT, C.MAP_TOP)