Add enemy spawn sound
This commit is contained in:
parent
f483f62ff5
commit
66d77f78b6
|
@ -169,6 +169,8 @@ class Enemy:
|
||||||
if get_distance(x - self.maze.x, y - self.maze.y) <= mind:
|
if get_distance(x - self.maze.x, y - self.maze.y) <= mind:
|
||||||
return False
|
return False
|
||||||
self.awake = True
|
self.awake = True
|
||||||
|
play(self.maze.sfx_spawn, self.maze.get_distance(*self.get_pos()),
|
||||||
|
self.get_angle() + pi)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def fire(self):
|
def fire(self):
|
||||||
|
|
|
@ -25,6 +25,7 @@ from pkg_resources import resource_filename
|
||||||
|
|
||||||
ICON = image.load(resource_filename('brutalmaze', 'icon.png'))
|
ICON = image.load(resource_filename('brutalmaze', 'icon.png'))
|
||||||
MUSIC = resource_filename('brutalmaze', 'soundfx/music.ogg')
|
MUSIC = resource_filename('brutalmaze', 'soundfx/music.ogg')
|
||||||
|
SFX_SPAWN = resource_filename('brutalmaze', 'soundfx/spawn.ogg')
|
||||||
SFX_SLASH_ENEMY = resource_filename('brutalmaze', 'soundfx/slash-enemy.ogg')
|
SFX_SLASH_ENEMY = resource_filename('brutalmaze', 'soundfx/slash-enemy.ogg')
|
||||||
SFX_SLASH_HERO = resource_filename('brutalmaze', 'soundfx/slash-hero.ogg')
|
SFX_SLASH_HERO = resource_filename('brutalmaze', 'soundfx/slash-hero.ogg')
|
||||||
SFX_SHOT_ENEMY = resource_filename('brutalmaze', 'soundfx/shot-enemy.ogg')
|
SFX_SHOT_ENEMY = resource_filename('brutalmaze', 'soundfx/shot-enemy.ogg')
|
||||||
|
|
|
@ -25,7 +25,7 @@ from random import choice, getrandbits, uniform
|
||||||
|
|
||||||
import pygame
|
import pygame
|
||||||
from pygame import RESIZABLE
|
from pygame import RESIZABLE
|
||||||
from pygame.mixer import Sound, set_num_channels
|
from pygame.mixer import Sound
|
||||||
from pygame.time import get_ticks
|
from pygame.time import get_ticks
|
||||||
|
|
||||||
from .characters import Hero, new_enemy
|
from .characters import Hero, new_enemy
|
||||||
|
@ -105,6 +105,7 @@ class Maze:
|
||||||
self.next_move = self.next_slashfx = 0
|
self.next_move = self.next_slashfx = 0
|
||||||
self.slashd = self.hero.R + self.distance/SQRT2
|
self.slashd = self.hero.R + self.distance/SQRT2
|
||||||
|
|
||||||
|
self.sfx_spawn = Sound(SFX_SPAWN)
|
||||||
self.sfx_slash = Sound(SFX_SLASH_ENEMY)
|
self.sfx_slash = Sound(SFX_SLASH_ENEMY)
|
||||||
self.sfx_shot = Sound(SFX_SHOT_ENEMY)
|
self.sfx_shot = Sound(SFX_SHOT_ENEMY)
|
||||||
self.sfx_lose = Sound(SFX_LOSE)
|
self.sfx_lose = Sound(SFX_LOSE)
|
||||||
|
@ -126,7 +127,6 @@ class Maze:
|
||||||
walls.remove((x, y))
|
walls.remove((x, y))
|
||||||
else:
|
else:
|
||||||
self.map[x][y] = WALL
|
self.map[x][y] = WALL
|
||||||
set_num_channels(int(num * 3))
|
|
||||||
|
|
||||||
def get_pos(self, x, y):
|
def get_pos(self, x, y):
|
||||||
"""Return coordinate of the center of the grid (x, y)."""
|
"""Return coordinate of the center of the grid (x, y)."""
|
||||||
|
|
|
@ -85,6 +85,8 @@ def choices(d):
|
||||||
|
|
||||||
def play(sound, volume, angle=None):
|
def play(sound, volume, angle=None):
|
||||||
"""Play a pygame.mixer.Sound at the given volume."""
|
"""Play a pygame.mixer.Sound at the given volume."""
|
||||||
|
if pygame.mixer.find_channel() is None:
|
||||||
|
pygame.mixer.set_num_channels(pygame.mixer.get_num_channels() + 1)
|
||||||
if angle is None:
|
if angle is None:
|
||||||
sound.set_volume(volume)
|
sound.set_volume(volume)
|
||||||
sound.play()
|
sound.play()
|
||||||
|
|
Binary file not shown.
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ with open('README.rst') as f:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='brutalmaze',
|
name='brutalmaze',
|
||||||
version='0.3.4',
|
version='0.3.5',
|
||||||
description='A hash and slash game with fast-paced action and a minimalist art style',
|
description='A hash and slash game with fast-paced action and a minimalist art style',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
url='https://github.com/McSinyx/brutalmaze',
|
url='https://github.com/McSinyx/brutalmaze',
|
||||||
|
|
Loading…
Reference in New Issue