From f2ccd902a5f9534e2a8e83c65ec3875a81fefc26 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 8 Oct 2015 03:46:57 -0400 Subject: Add "enemy defeated" sound Generated with Cfxr. Play a sound when an enemy is destroyed. Sounds are located in the "Resources" directory. Audio is played using `mplayer` if available. --- Resources/enemy-defeated.wav | Bin 0 -> 20068 bytes autoload/space_vlaze/audio.vim | 15 +++++++++++++++ autoload/space_vlaze/enemy.vim | 1 + 3 files changed, 16 insertions(+) create mode 100644 Resources/enemy-defeated.wav create mode 100644 autoload/space_vlaze/audio.vim diff --git a/Resources/enemy-defeated.wav b/Resources/enemy-defeated.wav new file mode 100644 index 0000000..9a07e1b Binary files /dev/null and b/Resources/enemy-defeated.wav differ diff --git a/autoload/space_vlaze/audio.vim b/autoload/space_vlaze/audio.vim new file mode 100644 index 0000000..18d3e7f --- /dev/null +++ b/autoload/space_vlaze/audio.vim @@ -0,0 +1,15 @@ +if !exists('s:AUDIO_PATH') + let s:AUDIO_PATH = resolve(expand(':p:h')) . '/../../Resources' +endif + + +function! space_vlaze#audio#Play(filename) + if executable('mplayer') + call system('mplayer ' . s:AUDIO_PATH . '/' . a:filename . ' &') + endif +endfunction + + +function! space_vlaze#audio#PlayEnemyDefeated() + call space_vlaze#audio#Play('enemy-defeated.wav') +endfunction diff --git a/autoload/space_vlaze/enemy.vim b/autoload/space_vlaze/enemy.vim index cbe03f3..c91abc3 100644 --- a/autoload/space_vlaze/enemy.vim +++ b/autoload/space_vlaze/enemy.vim @@ -69,6 +69,7 @@ endfunction " If an enemy lives at y, x, it needs to disappear and update the score. function! space_vlaze#enemy#HandleEnemyHitAt(y, x) if space_vlaze#enemy#IsEnemyAtCell(a:y, a:x) + call space_vlaze#audio#PlayEnemyDefeated() call space_vlaze#game#ClearBoardCell(a:y, a:x) call space_vlaze#score#IncrementScore( \ s:ENEMY_POINT_BASE * space_vlaze#enemy#PointMultiplier()) -- cgit v1.2.3