libtcod / python-tcod

A high-performance Python port of libtcod. Includes the libtcodpy module for backwards compatibility with older projects.
BSD 2-Clause "Simplified" License
410 stars 36 forks source link

Subpanels problem #4

Closed Krypticdator closed 9 years ago

Krypticdator commented 9 years ago

Hello dear sir!

Before I post my problem I must thank you for this great library, it has really made libtcod available to me. Secondly I must apologize because this is not really a bug-report, but I couldn't find your contact information otherwise and I'm so sorry.

Anyways, I want to make Python 3 version of the tutorial from RogueBasin, called "Complete Roguelike Tutorial, using python+libtcod". The tutorial is great, but outdated if you consider Python 3.0 and requires too much tinkering with C-libraries, unlike your dtl-library.

In order to do new tutorial, I of course want to complete the original as faithful as I can with your library. Unfortunately I can't figure out how to do specific feature in your library, when comparing to libtcod. I'm trying to add statusbar to my tutorial-roguelike, as described in here: http://www.roguebasin.com/index.php?title=Complete_Roguelike_Tutorial,_using_python%2Blibtcod,_part_7

Full example-code after the exercise, using original libtcod library should look like this: http://www.roguebasin.com/index.php?title=Complete_Roguelike_Tutorial,_using_python%2Blibtcod,_part_7_code

I got it working, kinda but not quite. Here's my version of the one-file project so far: https://github.com/Krypticdator/Complete-Roguelike-Tutorial--using-python-3-libtcod-tdl-/

I'm trying to create statusbar according to the tutorial on codelines: 429-451. I saved the tutorials code in comments for reference.

If you could help me with this I would very much appreciate it, and so would probably those others who love python 3 and would want to go trought this amazing tutorial in the future.

With best regards Toni Nurmi toni.nurmi@hotmail.com

HexDecimal commented 9 years ago

No problem, I'm always looking for any kind of feedback with the project.

python-tdl's printStr method isn't nearly as flexible as in native libtcod. You're mostly supposed to use Python's native string functions to format strings and draw them that way.

The setColors method has no affect on draw* operations and you also need to use the move method to place the virtual cursor before calling printStr, this is why the text was only placed in the upper left corner in your example. And because they don't change the defaults of draw* methods those drawRect calls were drawing empty white on black rectangles.

It might be confusing actually, draw* calls always default to white on black without any exceptions. I could try changing it but because they're so frequently called that any added behaviors often have major impacts on the speed of the library.

I fixed the render_bar issues in the project you gave me, I basically commented out setColors and printStr and replaced them with only draw* calls and Python string formatting, you should see a pull request for it on GitHub somewhere soon.

If you have any other issues I'll be willing to help with them.

Kyle Stewart - 4b796c65+github@gmail.com