0

There is no API for asynchronous Clock.tick() in pygame, how could I implement something like this? (This could be useful for things like pygbag that require async main loop.)

8
  • 1
    Depending your tick on something asynchronous just sounds incredibly wrong. Commented Apr 17, 2024 at 7:36
  • 1
    Can you explain the actual use case for that? Commented Apr 17, 2024 at 7:40
  • I don't think I can add more on an actual use case than what I've already said in the question without repeating myself, but I can try: making asynchronous version of pygame API would allow running games/projects in pygame concurrently. Where this could be useful? I can think of a few examples: gluing multiple programs (like launcher, etc...) without spawning a new process and limitations of communication that comes with it), debuggers (halting execution on pygame API calls and maybe logging it or adding debug information), running pygame projects in the frameworks that require asynchronicity Commented Apr 17, 2024 at 21:02
  • Right. In an async main loop, you might want to skip tick() altogether and instead just compute the time it took for execution to get back to you, and use that as your delta time value. Commented Apr 18, 2024 at 8:38
  • @AKX True, didn't think about this option. In that case, I probably would have to implement my own tick() method, that would inform the wrapper that the frame is finished. I wonder if it would be useful to asyncify some of the pygame API, like load calls. Commented Apr 18, 2024 at 21:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.