0

I'm trying to implement some sort of animation or event queue such that somehow only the item that gets out of the queue does what it's supposed to do and the items in the queue don't do anything at all.

Here is some pseudocode

queue = (obj1.animation1(), obj2.animation(), obj1.animation2)

The idea is that obj2.animation() and obj1.animation2 don't run until they get to the first position of the queue or they get popped off.

Also main has to be running while the queue is executing the animations and popping them off.

David Meléndez
  • 389
  • 5
  • 15
  • 1
    Put these animations in a queue, and until the queue is empty, pop and call/execute the first animation. That's generally how queues work – Alex Mandelias Oct 14 '20 at 14:00
  • Then how to keep main running and only the animation on the front of the queue running? (Both at the same time) – David Meléndez Oct 14 '20 at 14:52
  • 1
    For this you might want to look into `https://docs.python.org/3/library/threading.html` or `https://docs.python.org/3/library/multiprocessing.html` (a youtube tutorial should be simpler than reading the docs though) – Alex Mandelias Oct 14 '20 at 15:21
  • If you want timed events, then [this answer](https://stackoverflow.com/a/63147361/7675174) has an example using pygame timers that might help. How often do you need to to pop your queue? – import random Oct 19 '20 at 01:49

0 Answers0