Talk:Complete Roguelike Tutorial, using python+libtcod, part 11

From RogueBasin
Revision as of 00:03, 24 February 2013 by Dontroel (talk | contribs) (Suggestion regarding rendering of stairs vs monsters)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Just returned after a half year hiatus to find more parts of this excellent tutorial!

A minor bug/suggestion regarding stairs: Since the stairs are added last in make_map(), the < will always be drawn last (except for the player). This means that when monsters step on top of it, they "disappear".

A quick fix (avoiding introducing general z-levels) is to simply extend the special handling of the players to all fighters. In render_all() substitute the lines:

    #draw all objects in the list, except the player. we want it to
    #always appear over all other objects! so it's drawn later.
    for object in objects:
        if object != player:
            object.draw()
    player.draw()

for

    #draw all objects in the list, except the fighters (monsters and player).
    #we want those to always appear over all other objects! So they're drawn later.
    fighters = []
    for object in objects:
        if object.fighter is None:
            object.draw()
        else:
            fighters.append(object)
    for fighter in fighters:
        fighter.draw()

Cheers, --Dontroel (talk) 01:03, 24 February 2013 (CET)