Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win stop responding when there is no tcod.event.get() #114

Closed
UcyElak opened this issue Mar 8, 2022 · 4 comments
Closed

win stop responding when there is no tcod.event.get() #114

UcyElak opened this issue Mar 8, 2022 · 4 comments

Comments

@UcyElak
Copy link

UcyElak commented Mar 8, 2022

Hi, HexDec!
I find that the window will stop responding if no tcod.event.get() is called in the main loop, on Win10 and python3.7. I'm new to python-tcod, so I do not actually know what happened in sdl event functions or whether it is expected.

It might be better to add a comment on getting started or add protect on related functions.

@HexDecimal
Copy link
Collaborator

This is normal behavior for SDL-based programs. Event polling is how your program tells Windows that your app isn't hanging.

SDL has SDL_PumpEvents which lets you keep the window awake without needing to handle the events immediately. You can call this function from tcod using tcod.lib.SDL_PumpEvents().

@HexDecimal
Copy link
Collaborator

There isn't much more to add. A program does need to check events at least to respond to quit events and other windowing events. SDL_PumpEvents causes important side-effects so I won't add it to non-event functions.

A main loop without event polling might be considered invalid. Something like a long loading screen might use SDL_PumpEvents or it might check events normally for its duration. What example do you have for a program which doesn't check events?

@UcyElak
Copy link
Author

UcyElak commented Mar 8, 2022

Hi, HexDec
I'm working on the first demo, so there is no event handle function yet. I agree that it at least need to respond for quit, and maybe I have to learn more on SDL to work better with tcod. XD
Thanks for your help!

@UcyElak UcyElak closed this as completed Mar 8, 2022
@HexDecimal
Copy link
Collaborator

No problem. Keeping the event loop from the getting started examples should be enough. You only need to replace tcod.event.wait with tcod.event.get.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants