def step(self): self.checkTimeOut() self.x += self.delta[0] self.y += self.delta[1] if self.x >= self.app.width or self.x <= 0: self.delta[0] *= -1 self.rotation = utilities.getAng((0, 0), self.delta) if self.y >= self.app.height or self.y <= 0: self.delta[1] *= -1 self.rotation = utilities.getAng((0, 0), self.delta)
def step(self): self.checkTimeOut() self.x += self.delta[0] self.y += self.delta[1] if self.x >= self.app.width or self.x <= 0 : self.delta[0] *= -1 self.rotation = utilities.getAng((0,0), self.delta) if self.y >= self.app.height or self.y <= 0 : self.delta[1] *= -1 self.rotation = utilities.getAng((0,0), self.delta)
def step(self): a = (self.app.massCenter[0] - self.x) * self.app.followtheflockF b = (self.app.massCenter[1] - self.y) * self.app.followtheflockF self.f1 = a, b c, d = self.avoidOthers() self.f2 = c * self.app.avoidothersF, d * self.app.avoidothersF e = (self.app.flockSpeed[0] - self.nextstep[0]) * self.app.matchyrspeedF f = (self.app.flockSpeed[1] - self.nextstep[1]) * self.app.matchyrspeedF self.f3 = e, f ## if self.app.followmouse : ## mouse = self.tend_to_point(self.app.mouseLoc) ## else: ## mouse = self.avoid_point(self.app.mouseLoc) x = self.nextstep[0] + self.f1[0] + self.f2[0] + self.f3[0] #\ ## + mouse[0] + self.app.wind[0] y = self.nextstep[1] + self.f1[1] + self.f2[1] + self.f3[1] #\ ## + mouse[1] + self.app.wind[1] + self.app.gravityF self.nextstep = self.limitSpeed([x, y]) #limit if too fast nextx = self.x + self.nextstep[0] nexty = self.y + self.nextstep[1] # calc new step self.rotation = utilities.getAng(self.loc, (nextx, nexty)) limitedX, limitedY = utilities.constrainToRect( nextx, nexty, (0, 0, self.app.width, self.app.height)) self.loc = limitedX, limitedY # here we go
def step(self) : a = (self.app.massCenter[0] - self.x)* self.app.followtheflockF b = (self.app.massCenter[1] - self.y)* self.app.followtheflockF self.f1 = a,b c,d = self.avoidOthers() self.f2 = c * self.app.avoidothersF, d * self.app.avoidothersF e = (self.app.flockSpeed[0] - self.nextstep[0])* self.app.matchyrspeedF f = (self.app.flockSpeed[1] - self.nextstep[1])* self.app.matchyrspeedF self.f3 = e,f ## if self.app.followmouse : ## mouse = self.tend_to_point(self.app.mouseLoc) ## else: ## mouse = self.avoid_point(self.app.mouseLoc) x = self.nextstep[0] + self.f1[0] + self.f2[0] + self.f3[0] #\ ## + mouse[0] + self.app.wind[0] y = self.nextstep[1] + self.f1[1] + self.f2[1] + self.f3[1] #\ ## + mouse[1] + self.app.wind[1] + self.app.gravityF self.nextstep = self.limitSpeed( [x,y] ) #limit if too fast nextx = self.x + self.nextstep[0] nexty = self.y + self.nextstep[1] # calc new step self.rotation = utilities.getAng(self.loc, (nextx, nexty)) limitedX, limitedY = utilities.constrainToRect(nextx, nexty, (0,0,self.app.width, self.app.height)) self.loc = limitedX, limitedY # here we go
def __init__(self, f, x=1, y=0, z=0, width=10, height=10, color=(0, 0, 0)): super(ImageBlob, self).__init__(f, x, y, z, width, height, color) #init superclass self.delta = self.calcDelta() self.rotation = utilities.getAng(self.delta, (0, 0)) self.timeOut = self.doTimeOut() self.sq = 1
def checkTimeOut(self): if time.time() >= self.timeOut : self.delta = self.calcDelta() self.timeOut = self.doTimeOut() # again self.rotation = utilities.getAng((0,0), self.delta)
def __init__(self, x=1, y=0, z=0, width=10, height=10, color=(0, 0, 0)) : super(Blob, self).__init__(x,y, z, width, height, color) #init superclass self.delta = self.calcDelta() self.rotation = utilities.getAng((0,0), self.delta) self.timeOut = self.doTimeOut()
def checkTimeOut(self): if time.time() >= self.timeOut: self.delta = self.calcDelta() self.timeOut = self.doTimeOut() # again self.rotation = utilities.getAng((0, 0), self.delta)