diff options
Diffstat (limited to 'brutalmaze/misc.py')
-rw-r--r-- | brutalmaze/misc.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/brutalmaze/misc.py b/brutalmaze/misc.py index db1be00..94537db 100644 --- a/brutalmaze/misc.py +++ b/brutalmaze/misc.py @@ -1,5 +1,5 @@ -# misc.py - module for miscellaneous functions -# Copyright (C) 2017-2020 Nguyễn Gia Phong +# Miscellaneous functions +# Copyright (C) 2017-2021 Nguyễn Gia Phong # # This file is part of Brutal Maze. # @@ -19,6 +19,7 @@ __doc__ = 'Brutal Maze module for miscellaneous functions' from datetime import datetime +from importlib.resources import path as resource from itertools import chain from math import cos, degrees, pi, sin from os import path @@ -86,14 +87,15 @@ def json_rec(directory): """Return path to JSON file to be created inside the given directory based on current time local to timezone in ISO 8601 format. """ - return path.join( - directory, '{}.json'.format(datetime.now().isoformat()[:19])) + return path.join(directory, + '{}.json'.format(datetime.now().isoformat()[:19])) def play(sound: str, x: float = MIDDLE, y: float = MIDDLE, gain: float = 1.0) -> Source: """Play a sound at the given position.""" - source = Buffer(sound).play() + with resource('brutalmaze.soundfx', sound) as file: + source = Buffer(str(file)).play() source.spatialize = True source.position = x, -y, 0 source.gain = gain |