Engine
Animationsthread
Engine.py — text/python-source, 1 KB
Dateiinhalt
from time import * from threading import * from Objects import * class Engine(Thread): def __init__ (self,FPS): Thread.__init__(self) self.objectList=[] self.FPS=FPS self.interrupted = False def addObject(self,obj): self.objectList.append(obj) obj.engine = self def run(self): while not self.interrupted: for i in self.objectList: i.step(1.0/self.FPS) for x in self.objectList: if (i.col_radius + x.col_radius) > abs(i.position - x.position) and i != x: i.collisionWith(x) sleep(1.0/self.FPS)