Difference between revisions of "Talk:Complete Roguelike Tutorial, using python+libtcod, part 11"
m |
|||
(One intermediate revision by the same user not shown) | |||
Line 34: | Line 34: | ||
: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! [[User:Jotaf|Jotaf]] ([[User talk:Jotaf|talk]]) 06:01, 26 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! [[User:Jotaf|Jotaf]] ([[User talk:Jotaf|talk]]) 06:01, 26 February 2013 (CET) | ||
::You're welcome! That seems very sensible to do for now. But yes, the send_to_back() function is a nice and simple solution, but it does become a bit unmanageable, if one wants a bit more control over how several objects in a single tile are rendered. [[User:Dontroel|Dontroel]] ([[User talk:Dontroel|talk]]) 22:32, 26 February 2013 (CET) | ::You're welcome! That seems very sensible to do for now. But yes, the send_to_back() function is a nice and simple solution, but it does become a bit unmanageable, if one wants a bit more control over how several objects in a single tile are rendered. [[User:Dontroel|Dontroel]] ([[User talk:Dontroel|talk]]) 22:32, 26 February 2013 (CET) | ||
Syntax for handling '<' and '>' style input seems to have changed. | |||
Described here: https://bitbucket.org/libtcod/libtcod/issues/39/proposed-sdl2-unknown-pressed-character | |||
I had to use this style to correctly handle the down stairs command (<) | |||
<source lang="python"> | |||
... | |||
elif key.vk == libtcod.KEY_TEXT: # some character is pressed | |||
ch = key.text | |||
if ch == "<": | |||
#go down stairs, if the player is on them | |||
if stairs.x == player.x and stairs.y == player.y: | |||
next_level() | |||
... | |||
</source> |
Latest revision as of 01:47, 15 March 2017
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)
Syntax for handling '<' and '>' style input seems to have changed.
Described here: https://bitbucket.org/libtcod/libtcod/issues/39/proposed-sdl2-unknown-pressed-character
I had to use this style to correctly handle the down stairs command (<)
...
elif key.vk == libtcod.KEY_TEXT: # some character is pressed
ch = key.text
if ch == "<":
#go down stairs, if the player is on them
if stairs.x == player.x and stairs.y == player.y:
next_level()
...