diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2018-01-21 20:38:51 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2018-01-21 20:43:21 +0700 |
commit | 7fe731137107b72704bc661d60a4da1f4674c9d9 (patch) | |
tree | 8b3f69ba297d7a0b108a3039938f5777d9130d70 /brutalmaze/weapons.py | |
parent | 966951db60b60bacfd2c8559acc46c47f62f3295 (diff) | |
download | brutalmaze-7fe731137107b72704bc661d60a4da1f4674c9d9.tar.gz |
Finish adding sound effects (#2) 0.3.0
Diffstat (limited to 'brutalmaze/weapons.py')
-rw-r--r-- | brutalmaze/weapons.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/brutalmaze/weapons.py b/brutalmaze/weapons.py index 8f1ee72..c0c860a 100644 --- a/brutalmaze/weapons.py +++ b/brutalmaze/weapons.py @@ -22,9 +22,10 @@ __doc__ = 'brutalmaze module for weapon classes' from math import cos, sin from pygame.time import get_ticks +from pygame.mixer import Sound -from .constants import BULLET_LIFETIME, BULLET_SPEED, ENEMY_HP, TANGO -from .utils import regpoly, fill_aapolygon +from .constants import * +from .misc import regpoly, fill_aapolygon class Bullet: @@ -36,11 +37,18 @@ class Bullet: angle (float): angle of the direction the bullet pointing (in radians) color (str): bullet's color name fall_time (int): the tick that the bullet will fall down + sfx_hit (Sound): sound effect indicating the bullet hits the target + sfx_missed (Sound): sound effect indicating the bullet hits the target """ def __init__(self, surface, x, y, angle, color): self.surface = surface self.x, self.y, self.angle, self.color = x, y, angle, color self.fall_time = get_ticks() + BULLET_LIFETIME + # Sound effects of bullets shot by hero are stored in Maze to avoid + # unnecessary duplication + if color != 'Aluminium': + self.sfx_hit = Sound(SFX_SHOT_HERO) + self.sfx_missed = Sound(SFX_MISSED) def update(self, fps, distance): """Update the bullet.""" |