projects
/
koperkapel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of ctpug.org.za:koperkapel
[koperkapel.git]
/
koperkapel
/
weapons.py
diff --git
a/koperkapel/weapons.py
b/koperkapel/weapons.py
index 0050879b068b4b22d6a7903528d4f59cfb269f6a..f07caedb2404ae802bc94f280ea839fc9a38f621 100644
(file)
--- a/
koperkapel/weapons.py
+++ b/
koperkapel/weapons.py
@@
-1,6
+1,6
@@
""" Tools for dealing with weapons. """
""" Tools for dealing with weapons. """
-from pgzero.loaders import images
+from pgzero.loaders import images
, sounds
from .actors.animsurf import AnimatedSurfActor
from .util import safepath
from .actors.animsurf import AnimatedSurfActor
from .util import safepath
@@
-14,7
+14,9
@@
class Weapon:
self.damage = damage
self.bullet_range = bullet_range
self.can_tape = can_tape
self.damage = damage
self.bullet_range = bullet_range
self.can_tape = can_tape
- self.sound = sound
+ self.sound = None
+ if sound:
+ self.sound = sounds.load(sound)
WEAPONS = [
WEAPONS = [
@@
-22,12
+24,16
@@
WEAPONS = [
image_name="blank", frames=("",), sound="fire_spit"),
Weapon("butter_knife", damage=2),
Weapon("crowbar", damage=4),
image_name="blank", frames=("",), sound="fire_spit"),
Weapon("butter_knife", damage=2),
Weapon("crowbar", damage=4),
- Weapon("gun", damage=4, bullet_range=4),
+ Weapon("gun", damage=4, bullet_range=4
, sound='gun_fire'
),
]
WEAPON_LOOKUP = {w.name: w for w in WEAPONS}
]
WEAPON_LOOKUP = {w.name: w for w in WEAPONS}
+def weapon_by_name(weapon_name):
+ return WEAPON_LOOKUP[weapon_name]
+
+
class WeaponActor(AnimatedSurfActor):
def __init__(self, weapon, **kw):
super().__init__(**kw)
class WeaponActor(AnimatedSurfActor):
def __init__(self, weapon, **kw):
super().__init__(**kw)
@@
-38,7
+44,7
@@
class WeaponFactory:
def assemble_frame(self, suffix, weapon, tape):
surf = images.load(safepath("weapons/%s%s")
def assemble_frame(self, suffix, weapon, tape):
surf = images.load(safepath("weapons/%s%s")
-
% (weapon.image_name, suffix))
+ % (weapon.image_name, suffix))
frame = surf.copy()
if tape:
tape_surf = images.load(safepath("weapons/tape"))
frame = surf.copy()
if tape:
tape_surf = images.load(safepath("weapons/tape"))
@@
-46,7
+52,7
@@
class WeaponFactory:
return frame
def assemble(self, weapon_name, tape=False):
return frame
def assemble(self, weapon_name, tape=False):
- weapon =
WEAPON_LOOKUP[weapon_name]
+ weapon =
weapon_by_name(weapon_name)
tape = tape and weapon.can_tape
frames = [
self.assemble_frame(suffix, weapon, tape)
tape = tape and weapon.can_tape
frames = [
self.assemble_frame(suffix, weapon, tape)