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

From RogueBasin
Revision as of 05:01, 26 February 2013 by Jotaf (talk | contribs)
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)

Thanks for the encouragement, and the suggestion! That's a very elegant solution. However, we can simply use the send_to_back() function, which is a bit more brittle; I just fixed it in the tutorial. In the long run I may change to your solution though, for now this will do as it's a much smaller change! Jotaf (talk) 06:01, 26 February 2013 (CET)