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

TypeError in tcod.console.Console.draw_rect() #89

Closed lfernandezpricco closed 4 years ago

lfernandezpricco commented 4 years ago

After passing the constant tcod.BKGND_NONE to bg_blend in tcod.console.Console.draw_rect() I keep getting a TypeError sayin that 'an integer is required' I've tried to cast tcod.BKGND_NONE to an integer, bg_blend=int(libtcod.BKGND_NONE) but the result is the same. Even after passing a plain integer I keep getting the same error.

File "/PycharmProjects/rogue/venv/lib/python3.7/site-packages/tcod/console.py", line 1134, in draw_rect bg_blend, TypeError: an integer is required

I'm using the last version of tcod (11.9.2) and these are the functions that calls the draw_rect() method:

def draw_entity(console, entity):
    console.draw_rect(entity.x, entity.y, 1, 1, entity.char, fg=entity.color, bg_blend=libtcod.BKGND_NONE)

def clear_entity(console, entity):
    # Erase the character
    console.put_char(entity.x, entity.y, 32, bg_blend=libtcod.BKGND_NONE)
lfernandezpricco commented 4 years ago

I'm closing this. Even though the error said "line 1134, in draw_rect bg_blend, TypeError: an integer is required" bg_blend was fine, what was requiring and integer was the parameter 'ch'.

Sorry for the noise.

HexDecimal commented 4 years ago

That's okay, this is the right place for these kinds of issues.

If you had used Python type hinting you might have caught this issue earlier. MyPy or your IDE could have told you which parameter had an incorrect type.