from kivy.config import Config
from erdslangetjie.level import LevelList
-from erdslangetjie.data import load_image
+from erdslangetjie.data import load_image, load_sound
from erdslangetjie.player import ThePlayer, Nemesis
self.mouse_move = False
+ self.caught = load_sound('sounds/caught.ogg')
+
self.player = ThePlayer()
- self.nemesis = Nemesis()
+ self.nemesis = Nemesis(self.app.config)
if not self.level_obj.enter_pos:
raise RuntimeError('No entry point')
self.player_tile = None
return
elif self.check_caught():
# Caught
+ if self.app.config.getdefault('bane', 'sound', '0') != '0':
+ self.caught.play()
self.reset_level()
app = self.app
self.app = None
import os
from kivy.core.image import ImageLoader
+from kivy.core.audio import SoundLoader
data_py = os.path.abspath(os.path.dirname(__file__))
data_dir = os.path.normpath(os.path.join(data_py, '..', 'data'))
loader = ImageLoader()
+soundloader = SoundLoader()
def filepath(filename):
'''Load an image into a kivy texture. We rely on kivy's caching
infrastructure'''
return loader.load(filepath(filename))
+
+
+def load_sound(filename):
+ return soundloader.load(filepath(filename))
# Player and Player-like objects
-
-from erdslangetjie.data import load_image
+from erdslangetjie.data import load_image, load_sound
class GameSprite(object):
class Nemesis(FigureSprite):
- def __init__(self):
+ def __init__(self, config):
super(Nemesis, self).__init__()
self.sprite = load_image('sprites/nemesis.png')
self.reset_pos()
+ self._config = config
self._deadends = set([])
self._been = {}
+ self._bend = load_sound('sounds/bend.ogg')
def move(self, level, player_pos):
if not self.on_board():
for cand in neighbours:
if level.is_gate(cand) and level.blocked(cand):
level.damage_gate(cand)
+ if self._config.getdefault('bane', 'sound', False):
+ self._bend.play()
return
# check for dead-ends
if self._in_dead_end(level):