I am trying to make a game where two scripts are running at the same time.
For example, one script takes in the user's inputs and other variables and the other script updates the screen,controls objects, and runs any needed tasks.
I need to be able to pass variables back and forth between the scripts while they are running.
Here is an example of my code:
main.py
#main
Num = 0
while True:
if (#/up key is pressed/#):
Num=1
control.py
#control script
while True:
if main.Num==1:
main.Num=0
Move_object()
I have tried saving the data to a file then reading the data from another script but problems occur because, sometimes the scripts try to read the file at the same time and it causes my code to crash.
By having two or more scripts running simultaneously it splits the tasks and helps increase frame-rate because instead of one script processing all functions it shares the processes out between scripts.
Edit:
My only goal is to pass variables back and forth between the scripts while they are running.
Does anyone know how I could accomplish my goal?