I'm coding my own Asteroids minigame using pygame (which is extremely inefficient with multiple sprites so wanted to use threading.
How do I access a function from another class (asteroids class) through my main class (handler) class.
If my class system is backwards or doesn't work using Threading, please explain to me how I could make it more efficient or easy to code in
class Asteroids():
def __init__(self):
....
def Update(self):
....
class Handler():
def __init__(self):
....
def Update_All(self):
x = threading.Thread(target = ##Asteroids.Update()
x.start()
thanks in advance
CodePudding user response:
You need to create an instance of Asteroids
astroid = Astroids()
# then you can use the function in your thread
x = threading.Thread(target = astroid.Update())