INNER CODE UNIT · Python
update
tuangauss/DataScienceProjects · Python/fireworks.py:58
def update(self, dt):
self.age += dt
# particle expansions
if self.alive() and self.expand():
move_x = cos(radians(self.id*360/self.total))*self.initial_speed
move_y = sin(radians(self.id*360/self.total))*self.initial_speed
self.cv.move(self.cid, move_x, move_y)
self.vx = move_x/(float(dt)*1000)
# falling down in projectile motion
elif self.alive():
move_x = cos(radians(self.id*360/self.total))
# we technically don't need to update x, y because move will do the job
self.cv.move(self.cid, self.vx + move_x, self.vy+GRAVITY*dt)
self.vy += GRAVITY*dt
# remove article if it is over the lifespan