def _update_trails(self): if self.impulse: radius_to_use = self.radius + 75 rads = radians(self.facing_direction) dx, dy = (sin(rads) * radius_to_use) + self.pos.x, (cos(rads) * radius_to_use) + self.pos.y self.current_trail.add_point((dx, dy), 1) rads2 = radians(self.facing_direction + 30) dx2, dy2 = (sin(rads2) * radius_to_use) + self.pos.x, (cos(rads2) * radius_to_use) + self.pos.y self.current_trail.add_point((dx2, dy2), 2) rads3 = radians(self.facing_direction - 30) dx3, dy3 = (sin(rads3) * radius_to_use) + self.pos.x, (cos(rads3) * radius_to_use) + self.pos.y self.current_trail.add_point((dx3, dy3), 3) self.current_trail.draw(False) elif not self.impulse and self.current_trail.length(1) > 0: self.trails.add_trail(self.current_trail) self.current_trail = Trail(color1=(0, 255, 230), color2=(255, 0, 230), color3=(0, 255, 0)) self.trails.draw()
def __init__(self, sprite_name, controller, pos): BaseAnimatedObject.__init__( self, name=sprite_name, rows=9, cols=1, pos=pos, sprite_group=SPRITE_MANAGER.instance) # old image is used for quicker "rotations" of images, also stops the image from # being distorted when multiple images are rotated over and over agian. self.old_image = self.image self.joystick = controller # in degrees, 0 is top, 90 is left, 180 is down, 270 is right self.facing_direction = 0 self.moving_direction = 0 self.bullet_count = 0 self._rotate(self.facing_direction) self.radius = self.rect.centerx - self.rect.x self.begun_movement = False self.play_thrust = False # current trail could also be kicked out to trail manager, I think... self.current_trail = Trail(color1=(0, 255, 230), color2=(255, 0, 230), color3=(0, 255, 0)) self.trails = Trail_Manager() self.velocity = Vector(0, 0) self.acceleration = Vector(0, 0) self.impulse = False self.land = False # this isn't the proper place for cycle logic. Should kick this out somehow. self.can_cycle = -1 # ship properties.. self.mass = MASS self.thrust = THRUST self.engine_thrust = Vector(0, 0) self.first_pass = True self.camera_center = CameraCenter("Bullet.png", self)