Ejemplo n.º 1
0
def create_monster(name, symbol, color, hp=10, power=1, defense=1):
    mob = Entity(name,symbol,color)
    mob.actor = HuntingMobile(mob)
    mob.interactable = NPC(mob)
    mob.fighter = Fighter(mob, hp, defense, power)
    mob.render_order = RenderOrder.ACTOR
    return mob


        
Ejemplo n.º 2
0
def kill_monster(monster: Entity) -> Message:
    death_message = Message(f'{monster.name.capitalize()} is dead!',
                            tcod.orange)

    monster.char = '%'
    monster.color = tcod.dark_red
    monster.blocks = False
    monster.fighter = None
    monster.ai = None
    monster.name = f'remains of {monster.name}'
    monster.render_order = RenderOrder.CORPSE
    return death_message
Ejemplo n.º 3
0
def kill_monster(monster: Entity):
    death_message = Message(f"{monster.name.capitalize()} is dead!",
                            Colors.ORANGE)

    monster.char = "%"
    monster.color = Colors.RED
    monster.blocks = False
    monster.fighter = None
    monster.ai = None
    monster.name = f"remains of {monster.name}"
    monster.render_order = RenderLayer.CORPSE

    return death_message
Ejemplo n.º 4
0
def main():
    screen_width = 80
    screen_height = 50
    map_width = 80
    map_height = 45

    room_max_size = 10
    room_min_size = 6
    max_rooms = 30

    player = Entity('player', '@', tcod.white)
    player.interactable = NPC(player)
    player.fighter = Fighter(player, hp=30, defense=2, power=5)
    player.render_order = RenderOrder.ACTOR

    tcod.console_set_custom_font(
        'terminal12x12_gs_ro.png',
        tcod.FONT_TYPE_GREYSCALE | tcod.FONT_LAYOUT_ASCII_INROW
    )
    
    with tcod.console_init_root(
        screen_width,
        screen_height,
        'Roguelikedev2019', 
        order='F', 
        renderer=tcod.RENDERER_SDL2,
        vsync=True
    ) as root_console:

        con = tcod.console.Console(screen_width, screen_height, order='F')
        game_map = GameMap(map_width, map_height, player)
        game_map.load(make_sample_map(map_width, map_height))
        #game_map.load(make_tutorial_map(map_width, map_height, max_rooms, room_min_size, room_max_size))

        handler = Playing(game_map)

        while True:
            con.clear(fg=(255,255,255))
            handler.update()
            handler.render(con)
            con.print(1, screen_height - 2, f'HP: {player.fighter.hp}/{player.fighter.max_hp}', (255,255,255), (0,0,0), tcod.BKGND_NONE, tcod.LEFT)
            con.blit(root_console, 0, 0, 0, 0, screen_width, screen_height)
            tcod.console_flush()
            for event in tcod.event.wait():
                handler.dispatch(event)