Beispiel #1
0
    def Update(self):
        newvars = interpolate.InterpolateKeyframes(
            self.curframe, {
                'pos_x': self.pos[0],
                'pos_y': self.pos[1],
                'initspeed': self.initspeed,
                'initdirection': self.initdirection,
                'initspeedrandrange': self.initspeedrandrange,
                'initdirectionrandrange': self.initdirectionrandrange,
                'particlesperframe': self.particlesperframe,
                'genspacing': self.genspacing
            }, self.keyframes)
        self.pos = (newvars['pos_x'], newvars['pos_y'])
        self.initspeed = newvars['initspeed']
        self.initdirection = newvars['initdirection']
        self.initspeedrandrange = newvars['initspeedrandrange']
        self.initdirectionrandrange = newvars['initdirectionrandrange']
        self.particlesperframe = newvars['particlesperframe']
        self.genspacing = newvars['genspacing']

        particlesperframe = self.particlesperframe

        if (self.genspacing == 0) or (
            (self.curframe % self.genspacing) == 0) and self.emitting is True:
            for i in range(0, int(particlesperframe)):
                self.CreateParticle()

        self.curframe = self.curframe + 1
Beispiel #2
0
    def Update(self):
        newvars = interpolate.InterpolateKeyframes(
            self.curframe, {
                'strength': self.initstrength,
                'strengthrandrange': self.strengthrandrange,
                'direction_x': self.direction[0],
                'direction_y': self.direction[1]
            }, self.keyframes)
        self.initstrength = newvars['strength']
        self.strengthrandrange = newvars['strengthrandrange']
        self.direction = [newvars['direction_x'], newvars['direction_y']]

        if self.strengthrandrange != 0.0:
            self.strength = RandomiseStrength(self.initstrength,
                                              self.strengthrandrange)

        self.curframe = self.curframe + 1
Beispiel #3
0
    def Update(self):
        newvars = interpolate.InterpolateKeyframes(
            self.curframe, {
                'pos_x': self.pos[0],
                'pos_y': self.pos[1],
                'colour_r': self.colour[0],
                'colour_g': self.colour[1],
                'colour_b': self.colour[2],
                'bounce': self.bounce,
                'radius': self.radius
            }, self.keyframes)
        self.pos = (newvars['pos_x'], newvars['pos_y'])
        self.colour = (newvars['colour_r'], newvars['colour_g'],
                       newvars['colour_b'])
        self.bounce = newvars['bounce']
        self.radius = newvars['radius']

        Obstacle.Update(self)
Beispiel #4
0
    def Update(self):
        newvars = interpolate.InterpolateKeyframes(
            self.curframe, {
                'strength': self.initstrength,
                'strengthrandrange': self.strengthrandrange,
                'pos_x': self.pos[0],
                'pos_y': self.pos[1]
            }, self.keyframes)
        self.initstrength = newvars['strength']
        self.strengthrandrange = newvars['strengthrandrange']
        self.pos = (newvars['pos_x'], newvars['pos_y'])

        if self.strengthrandrange != 0.0:
            self.strength = RandomiseStrength(self.initstrength,
                                              self.strengthrandrange)
        else:
            self.strength = self.initstrength

        self.curframe = self.curframe + 1
Beispiel #5
0
    def PreCalculateParticles(self):
        self.particlecache = []  # Clear the cache

        # If the particle has infinite life, interpolate for each frame up until its last keyframe
        if self.particlelife == -1:
            particlelife = max(self.particlekeyframes,
                               key=self.GetKeyframeValue).frame
        else:  # Otherwise, interpolate the particle variables for each frame of its life
            particlelife = self.particlelife

        for i in range(0, particlelife + 1):
            vars = interpolate.InterpolateKeyframes(
                i, {
                    'colour_r': 0,
                    'colour_g': 0,
                    'colour_b': 0,
                    'radius': 0,
                    'length': 0
                }, self.particlekeyframes)
            self.particlecache.append(vars)
Beispiel #6
0
    def Update(self):
        newvars = interpolate.InterpolateKeyframes(
            self.curframe, {
                'pos_x': self.pos[0],
                'pos_y': self.pos[1],
                'colour_r': self.colour[0],
                'colour_g': self.colour[1],
                'colour_b': self.colour[2],
                'bounce': self.bounce,
                'normal_x': self.normal[0],
                'normal_y': self.normal[1]
            }, self.keyframes)
        self.pos = (newvars['pos_x'], newvars['pos_y'])
        self.colour = (newvars['colour_r'], newvars['colour_g'],
                       newvars['colour_b'])
        self.bounce = newvars['bounce']
        oldnormal = self.normal[:]
        self.normal = [newvars['normal_x'], newvars['normal_y']]
        if self.normal != oldnormal:
            self.hascontacts = False

        Obstacle.Update(self)
Beispiel #7
0
    def Update(self):
        newvars = interpolate.InterpolateKeyframes(
            self.curframe, {
                'pos_x': self.pos[0],
                'pos_y': self.pos[1],
                'colour_r': self.colour[0],
                'colour_g': self.colour[1],
                'colour_b': self.colour[2],
                'bounce': self.bounce,
                'width': self.width,
                'height': self.height
            }, self.keyframes)
        self.pos = (newvars['pos_x'], newvars['pos_y'])
        self.colour = (newvars['colour_r'], newvars['colour_g'],
                       newvars['colour_b'])
        self.bounce = newvars['bounce']
        self.width = newvars['width']
        self.halfwidth = self.width / 2.0
        self.height = newvars['height']
        self.halfheight = self.height / 2.0
        self.maxdist = max(self.halfwidth, self.halfheight) + MAXDIST

        Obstacle.Update(self)