コード例 #1
0
ファイル: explosion.py プロジェクト: mappy13/nihil-ace
    def __init__(self, point, radius, velocity=Vec2d(0, 0), damage=0):
        self.radius = radius
        self.damage = damage

        inertia = pymunk.moment_for_circle(pymunk.inf, 0, radius)
        self._body = pymunk.Body(pymunk.inf, inertia)
        self._body.position = point
        self._body.velocity = velocity
        self._shape = pymunk.Circle(self._body, radius)
        self._shape.collision_type = COLLISION_TYPES['explosion']
        self._shape._get_explosion = ref(self)
        SPACE.add(self._body, self._shape)
        SPACE.register_explosion(self)

        # play SFX
        if settings.SOUND:
            sound = random.choice(EXPLOSION_SFX)
            # TODO: 3D sound
            #volume = (500 - (SPACE.camera_lock()._body.position - self._body.position).length) / 500
            #if volume > 0:
            #    print volume
            #    sound.volume = random.choice([1.0, .5, .25])
            sound.play()