def __init__(self, start, angle, range, lifespan, color_list, target = None): self.start = start self.angle = angle self.range = range self.vec = helper.ang2vec(angle) self.vec = [self.vec[0] * self.range, self.vec[1] * self.range] self.stop = [self.start[0] + self.vec[0], self.start[1] + self.vec[1]] self.lifespan = lifespan self.age = 0 self.color_list = color_list self.target = target self.hit_delay = 0
def update(self): """Update the ship every tick.""" # you are now 1 tick older! self.age += 1 if self.glow: self.glow -= 1 # ballistic motion self.pos[0] += int(self.vel[0]) self.pos[1] += int(self.vel[1]) self.angle += self.angvel # we need to update vel # acceleration if self.accel: vec = helper.ang2vec(self.angle) self.vel[0] += vec[0] * self.accel self.vel[1] += vec[1] * self.accel self.glow = max(self.glow, self.GLOW) # friction self.vel[0] *= GAME.zone.friction self.vel[1] *= GAME.zone.friction