RU
games/doom-jumphp / src / Game / SoundBank.php · commit 8e1cb9f
<?phpnamespace App\Game;use JumPHP\Audio\SoundManager;use JumPHP\Kernel\GameConfig;/** Loads the sound effects (assets/sfx/*.wav, made by tools/make-art.php) once. */final class SoundBank{    public const NAMES = [        'pistol', 'shotgun', 'pump', 'rivet', 'ion', 'swing', 'punch', 'dooropen', 'doorclose', 'lift', 'liftstop', 'switch',        'item', 'weapon', 'powerup', 'oof', 'noway', 'plpain', 'pldeath', 'barrel', 'firesht', 'firexpl', 'plasma',        'husksit', 'huskact', 'huskpain', 'huskdie', 'gnshsit', 'gnshact', 'gnshpain', 'gnshdie', 'gnshbite',        'spitsit', 'spitact', 'spitpain', 'spitdie', 'claw', 'wardsit', 'wardact', 'wardpain', 'warddie', 'secret',    ];    public static function load(SoundManager $sound, GameConfig $config): void    {        if ($sound->hasSfx('pistol')) {            return;        }        foreach (self::NAMES as $name) {            $sound->loadSfx($name, $config->path("assets/sfx/$name.wav"));        }        $sound->loadSfx('menu_move', $config->path('assets/sfx/menu.wav'));        $sound->loadSfx('menu_confirm', $config->path('assets/sfx/menuok.wav'));    }}