rendered paste bodytesting = 0if not testing: import clr from PythonInterop import xObjectimport random, math, timeif testing: mx = 300 my = 200 class xObject: x=0 y=0#layers on top of xObject because we can't override incoming functionsinsts = []class pyObj(xObject): ax = 0 ay = 0 vx = 0 vy = 0 def __init__(self): insts.append(self) self.x = random.randint(0,800) self.y = random.randint(0,600) self.sx = 0.1 self.sy = 0.1/3 #a test game object class myObj(pyObj): def step(self): #orbit mx, my in some manner dx = self.x - mx dy = self.y - my dir = math.atan2(dy, dx) dist = math.sqrt(dx*dx + dy*dy)/6 if dist<10: dist = 10 self.ax = -math.cos(dir) * 400 / (dist*dist) self.ay = -math.sin(dir) * 400 / (dist*dist) + 0.2 #speed limit lim = 10 if self.vx<-lim: self.vx=-lim if self.vx>lim : self.vx= lim if self.vy<-lim: self.vy=-lim if self.vy>lim : self.vy= lim #mcBounce damp = 0.9 if self.x<0: self.x=0 self.vx*=-damp elif self.x>800: self.x=800 self.vx*=-damp if self.y<0: self.y=0 self.vy*=-damp elif self.y>600: self.y=600 self.vy*=-damp #integrate self.vx += self.ax self.vy += self.ay self.x += self.vx self.y += self.vy self.angle = math.atan2(self.vx,self.vy)+3.1416/2#call the step function on our objects when C# says todef stepper(): for inst in insts: inst.step()#make N instances when the script is startedfor i in xrange(0,1000): this = myObj()if testing: frames = 30 start = time.time() for i in range(0,frames): stepper() length = time.time() - start fps = frames/length print str(frames)+" frames in "+str(length)+" seconds" print str(fps)+" fps"