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

while not tdl.event.isWindowClosed() hangs the console window #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This code makes the windows freeze.

import tdl

SCREEN_WIDTH = 80
SCREEN_HEIGHT = 50
LIMIT_FPS = 20

if __name__ == '__main__':
    tdl.setFont("arial10x10.png", None, None, False, False, False)
    tdl.setFPS(LIMIT_FPS)
    con = tdl.init(SCREEN_WIDTH, SCREEN_HEIGHT, "Test", False, "SDL")
    while not tdl.event.isWindowClosed():
        tdl.Console.drawChar(con, 1,1, '@', None, None )
        tdl.flush()

Is setFPS in tdl works not the same way as in libcod?

Windows XP, Python 3.3.2 win32, tdl 1.1.6r84

Original issue reported on code.google.com by istorika...@gmail.com on 4 Mar 2015 at 8:35

GoogleCodeExporter commented 9 years ago
Sorry, I was wrong. Nothing to do with setFPS. I should just add keyWait() in 
the and of the cycle.
First think, then create an issue.
Closed.

Original comment by istorika...@gmail.com on 4 Mar 2015 at 8:50

GoogleCodeExporter commented 9 years ago
Don't worry about it.  Forgetting to call the event subsystem is actually a 
common beginner mistake with SDL.  I've even seen it happen in modern 
roguelikes where an animation or simulation (sleeping, worldgen) is run for a 
long time without checking for user input causing Windows to believe the 
program is hanging if the user clicks or hits a key during it.

I'm not sure how you're feeling about it, but I tend to be inspired by 
accidental feedback like this since this is actually a real issue that can and 
was triggered from normal use.  I already have the event module fine-tuned to 
work with modal environments so adding a simple call to tdl.event.get from 
tdl.flush could prevent the hangs in the examples I mentioned as well as the 
one you gave.

Or, you know, keyWait works fine too.  So I'll probably just put this idea on 
hold for a while.

Original comment by 4B796...@gmail.com on 5 Mar 2015 at 9:06

GoogleCodeExporter commented 9 years ago
Actually uploaded the fix.  I'll need to work on a lot of regressions before I 
can make a new release.

Original comment by 4B796...@gmail.com on 14 Mar 2015 at 2:23