def generate_bullet(self, target): # Set correct origin offset_angle = vectors.bound_angle( vectors.add_vectors(self._effect_offset_angle, self.facing)) origin_pos = vectors.add_vectors( self.get_offset_pos(use_effect_offset=True), self.actor.pos) # Get actual velocity we'll be using if type(target) == list or type(target) == tuple: direction = vectors.angle(origin_pos, target) target_pos = target else: direction = vectors.angle(origin_pos, target.pos) target_pos = target.pos velocity = vectors.move_to_vector(direction, self.bullet['velocity']) velocity[2] = math_lib.calc_trajectory( 0.1, vectors.distance(origin_pos, target_pos), self.bullet['velocity']) the_bullet = bullets.Shell( pos=origin_pos, velocity=velocity, image=self.bullet['image'], size=self.bullet['size'], blast_radius=self.bullet['blast_radius'], damage=self.bullet['damage'], dissipation_func=self.bullet.get('dissipation_func', "linear"), ) self.actor.bullets.append(the_bullet)
def generate_bullet(self, target): # Set correct origin offset_angle = vectors.bound_angle( vectors.add_vectors(self._effect_offset_angle, self.facing) ) origin_pos = vectors.add_vectors(self.get_offset_pos(use_effect_offset=True), self.actor.pos) # Get actual velocity we'll be using if type(target) == list or type(target) == tuple: direction = vectors.angle(origin_pos, target) target_pos = target else: direction = vectors.angle(origin_pos, target.pos) target_pos = target.pos velocity = vectors.move_to_vector(direction, self.bullet['velocity']) velocity[2] = math_lib.calc_trajectory(0.1, vectors.distance(origin_pos, target_pos), self.bullet['velocity']) the_bullet = bullets.Shell( pos=origin_pos, velocity=velocity, image = self.bullet['image'], size = self.bullet['size'], blast_radius = self.bullet['blast_radius'], damage = self.bullet['damage'], dissipation_func = self.bullet.get('dissipation_func', "linear"), ) self.actor.bullets.append(the_bullet)
def generate_bullet(self, target): if type(target) == list or type(target) == tuple: direction = vectors.angle(self.actor.pos, target) target_pos = target else: direction = vectors.angle(self.actor.pos, target.pos) target_pos = target.pos velocity = vectors.move_to_vector(direction, self.bullet['velocity']) velocity[2] = math_lib.calc_trajectory(0.1, vectors.distance(self.actor.pos, target_pos), self.bullet['velocity']) the_bullet = bullets.Shell( pos=self.actor.pos, velocity=velocity, image = self.bullet['image'], size = self.bullet['size'], blast_radius = self.bullet['blast_radius'], damage = self.bullet['damage'], dissipation_func = self.bullet.get('dissipation_func', "linear"), ) self.actor.bullets.append(the_bullet)