def __init__(self, group, coord, color_palette): Particle.__init__(self, group, coord) self.duration = 10 self.palette = color_palette self.color = self.palette.high self.mid_switch = int(self.duration * .8) self.low_switch = self.duration / 2
def __init__(self, group, coord, color_palette, weight=0): Particle.__init__(self, group, coord) self.duration = ExplosionParticle.duration - weight/2 self.palette = color_palette self.base_color = self.palette.high self.color = self.palette.vary_color(self.base_color) self.mid_switch = int(self.duration * .9) self.low_switch = int(self.duration * .7) self.smoke_switch = int(self.duration * .5)
def __init__(self, collection, point, color): Particle.__init__(self, collection, point) self.tick = 1 self.flashes = [] self.color = color self.ani_map = None self.w = 0 self.h = 0 self.image = None self.rect = None
def __init__(self): # Parent Classes initialized by __init__() method Particle.__init__(self) # Particle Class Inherited Parameters.__init__(self) # Parameters Class Inherited # emptyParticle Template for Particle Initialization self.emptyParticle = {} self.emptyParticle["Position"] = None # Particle Position self.emptyParticle["Velocity"] = None # Particle Velocity self.emptyParticle["Cost"] = None # Particle Cost self.emptyParticle["Best"] = {} # Particle Personal Best self.emptyParticle["Best"][ "Position"] = None # Particle Personal Best Position self.emptyParticle["Best"][ "Cost"] = None # Particle Personal Best Cost
def __init__(self, body, pos, radius, color, material, texture, showTrail, rings): Particle.__init__(self, body, pos, radius, color, material, texture, showTrail) self.rings = rings if rings: self.rings = vs.ellipsoid(pos=self.pos, size=(self.radius * 4, 0.01, self.radius * 4), opacity=0.95) width = 512 # must be power of 2 height = 512 # must be power of 2 image = Image.open(rings) image = image.resize((width, height), Image.ANTIALIAS) material = vs.materials.texture(data=image, mapping="cubic") self.rings.material = material
def __init__(self, collection, points): if isinstance(points, tuple): self.points = [points] point = points elif isinstance(points, list): self.points = points point = points[0] Particle.__init__(self, collection, point) self.dot = pygame.Surface((SCALE, SCALE)) # self.dot.set_colorkey(WHITE) self.dot = self.dot.convert() self.rect = self.dot.get_rect() self.rect.topleft = self.point self.color_sequence = None self.sequence = PixelFlash.blue_sweep # default color sequence self.color = None self.set_color()
from particle import Particle import pygame from random import choice class Spark(Particle): def __init__(self, group, (x, y), d=60): Particle.__init__(self, group, (x, y)) self.color = (0, 200, 200) self.rect = pygame.Rect((x, y), (2, 2)) self.duration = d def on_update(self): self.color = choice(((0, 200, 200), (0, 150, 200), (255, 255, 255))) self.duration -= 1 def draw(self, surf): pygame.draw.rect(surf, self.color, self.rect) def check_end_condition(self): return self.duration <= 0
def __init__(self, x, y, theta): Particle.__init__(self, x, y, theta, 0)
def __init__(self, *args, **kwargs): Particle.__init__(self, *args, **kwargs)