def emit(self): s = self._sprites[self._particle]; s.exists = true; s.x = self.x - (s.width>>1); if(self.width != 0): s.x += Math.random()*self.width; s.y = self.y - (s.height>>1); if(self.height != 0): s.y += Math.random()*self.height; s.velocity.x = self.minVelocity.x; if(self.minVelocity.x != self.maxVelocity.x): s.velocity.x += Math.random()*(self.maxVelocity.x-self.minVelocity.x); s.velocity.y = self.minVelocity.y; if(self.minVelocity.y != self.maxVelocity.y): s.velocity.y += Math.random()*(self.maxVelocity.y-self.minVelocity.y); s.acceleration.y = self._gravity; s.angularVelocity = self._minRotation; if(self._minRotation != self._maxRotation): s.angularVelocity += Math.random()*(self._maxRotation-self._minRotation); if(s.angularVelocity != 0): s.angle = Math.random()*360-180; s.drag.x = self._drag; s.drag.y = self._drag; self._particle+=1 if(self._particle >= len(self._sprites)): self._particle = 0; s.onEmit();
def emit(self): s = self._sprites[self._particle] s.exists = true s.x = self.x - (s.width >> 1) if (self.width != 0): s.x += Math.random() * self.width s.y = self.y - (s.height >> 1) if (self.height != 0): s.y += Math.random() * self.height s.velocity.x = self.minVelocity.x if (self.minVelocity.x != self.maxVelocity.x): s.velocity.x += Math.random() * (self.maxVelocity.x - self.minVelocity.x) s.velocity.y = self.minVelocity.y if (self.minVelocity.y != self.maxVelocity.y): s.velocity.y += Math.random() * (self.maxVelocity.y - self.minVelocity.y) s.acceleration.y = self._gravity s.angularVelocity = self._minRotation if (self._minRotation != self._maxRotation): s.angularVelocity += Math.random() * (self._maxRotation - self._minRotation) if (s.angularVelocity != 0): s.angle = Math.random() * 360 - 180 s.drag.x = self._drag s.drag.y = self._drag self._particle += 1 if (self._particle >= len(self._sprites)): self._particle = 0 s.onEmit()
def randomFrame(self): self._pixels=self.pixels.get_region(Math.floor(Math.random()*(self.pixels.width/self._bw))*self._bw,0,self._bw,self._bh)