Changeset 538:c1b0ad1c0932


Ignore:
Timestamp:
04/09/11 22:33:06 (12 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Rebase:
34353632383964363832316266326439363461313662656636616532333031353738626261343631
Message:

Hook up projectile sounds.

Location:
skaapsteker/sprites
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/base.py

    r537 r538  
    1212from .. import data
    1313from .. import dialogue
     14from .. import sound
    1415
    1516
     
    181182            pos = pygame.Rect(self.rect.midright, (0, 0))
    182183        projectile = cls(pos, direction=self.facing, hits=Player, source=self)
     184        projectile.launch()
    183185        AddSpriteEvent.post(projectile)
    184186
     
    304306    collision_layer = PROJECTILE_LAYER
    305307    collides_with = set()
     308    launch_sound = None, None
    306309
    307310    gravitates = False
     
    317320        self.source = source # source of the projectile (may be None)
    318321        self._update_image(True)  # ensure we get the direction right
     322        if self.launch_sound[0]:
     323            sound.load_sound(self.launch_sound[0], self.launch_sound[0], self.launch_sound[1])
    319324
    320325        if isinstance(hits, tuple):
     
    333338        self.collide_rect.move_ip(shift)
    334339        self.deltav(dv)
     340
     341    def launch(self):
     342        if self.launch_sound[0]:
     343            sound.play_sound(self.launch_sound[0])
    335344
    336345    def explode(self):
  • skaapsteker/sprites/player.py

    r496 r538  
    376376            pos = pygame.Rect(self.rect.midright, (0, 0))
    377377        projectile = cls(pos, direction=self.facing, hits=(Monster, BreakableItem), source=self)
     378        projectile.launch()
    378379        AddSpriteEvent.post(projectile)
    379380
  • skaapsteker/sprites/projectiles.py

    r389 r538  
    55from .base import Projectile
    66
     7
    78class Fireball(Projectile):
    89
    910    gravitates = True
    1011
     12    launch_sound = 'sounds/woosh fireball.ogg', 0.5
    1113    image_dir = 'sprites/attacks/fireball'
    1214    animation_regexes = [
     
    2931    friction_coeff = (1.2, 1.2) # negative friction
    3032
     33    launch_sound = 'sounds/lightning.ogg', 0.25
    3134    image_dir = 'sprites/attacks'
    3235    animation_regexes = [
     
    4952    friction_coeff = (1.0, 1.0) # no friction
    5053
     54    launch_sound = 'sounds/woosh.ogg', 0.5
    5155    image_dir = 'sprites/attacks'
    5256    animation_regexes = [
Note: See TracChangeset for help on using the changeset viewer.