It is best, perhaps, to process everything at once in one update operation, rather than trying to use Threads. This is primarily due to the fact that Global Interpreter Lock will prevent the simultaneous processing of multiple threads. What you after looks something like this:
def tick(): for box in randomBoxes: box.relocate() specialBlock1.relocate() specialBlock2.relocate() specialBlock3.relocate()
Then we define the second function, which will endlessly run our first function:
def worker(): while True: tick() sleep(0.1)
Now that we have an interval or sort, we will run Thread, which runs in the background and processes our updates on the screen.
from threading import Thread t = Thread(target = worker, name = "Grid Worker") t.daemon = True
In our tick() function, we worked on the fact that specialBlocks 1, 2, and 3 work in the established order. The remaining fields accept their actions regardless of what others do.
source share