def __init__(self, world, shooter, angle, offset2sz=0, spread=0): offset = geometry.Vec2d(0, shooter.collision.radius) offset.rotate(angle) offset2 = geometry.Vec2d(0, shooter.collision.radius / 2.0) offset2.rotate(angle + 90) spreadn = max(spread, 1.0) vertical_sep = offset2sz / spreadn self.collision.radius = 2.0 self.states.exploded = False self.position.position = shooter.position.position + offset * ( 2.5 - abs(offset2sz / 16)) + offset2 * vertical_sep self.movement.velocity = (offset.normalized() * self.SPEED + shooter.movement.velocity) self.movement.accel = offset2 * -offset2sz / 2.0 + offset.normalized( ) * (40.0 - abs(offset2sz) * 5) / spreadn self.shape.verts = [(0, 1.5), (1.5, -1.5), (-1.5, -1.5)] self.collision.from_mask = Asteroid.COLLIDE_INTO_MASK self.collision.into_mask = Shot.COLLIDE_INTO_MASK self.renderable.color = "#ffc" if "--cheat1" in sys.argv: world.clock.schedule_once( self.expire, self.TIME_TO_LIVE * 2 / (1 + abs(offset2sz) / 50.0)) else: world.clock.schedule_once( self.expire, self.TIME_TO_LIVE / (1 + abs(offset2sz) / 50.0))
def __init__(self, world, shooter, angle): offset = geometry.Vec2d(0, shooter.collision.radius) offset.rotate(angle) self.position.position = shooter.position.position + offset self.movement.velocity = ( offset.normalized() * self.SPEED + shooter.movement.velocity) self.shape.verts = [(0, 1.5), (1.5, -1.5), (-1.5, -1.5)] self.collision.radius = 2.0 self.collision.from_mask = ~shooter.collision.into_mask self.renderable.color = "#ffc" world.clock.schedule_once(self.expire, self.TIME_TO_LIVE)
def brake(self): thrust_vec = geometry.Vec2d(0, -self.engine.thrust) thrust_vec.rotate(self.position.angle) self.movement.accel = thrust_vec self.shape.verts[2] = (0, 0 - random.random() * 16) self.THRUST_SOUND.play()
def thrust_on(self): thrust_vec = geometry.Vec2d(0, self.THRUST_ACCEL) thrust_vec.rotate(self.position.angle) self.movement.accel = thrust_vec self.shape.verts[2] = (0, -16 - random.random() * 16) self.THRUST_SOUND.play()