Mercurial > hg > beaglert
diff projects/tank_wars/render.cpp @ 268:8d80eda512cd prerelease
Added new overlay for using PRU0 or PRU1, a script to halt board on button press, and several example projects
author | andrewm |
---|---|
date | Tue, 17 May 2016 14:46:26 +0100 |
parents | 3c3a1357657d |
children |
line wrap: on
line diff
--- a/projects/tank_wars/render.cpp Tue May 17 14:38:03 2016 +0100 +++ b/projects/tank_wars/render.cpp Tue May 17 14:46:26 2016 +0100 @@ -68,10 +68,13 @@ extern int gMusicBufferLength; extern float *gSoundBoomBuffer; extern int gSoundBoomBufferLength; +extern float *gSoundHitBuffer; +extern int gSoundHitBufferLength; // Current state for sound and music int gMusicBufferPointer = 0; // 0 means start of buffer... int gSoundBoomBufferPointer = -1; // -1 means don't play... +int gSoundHitBufferPointer = -1; float gSoundProjectileOscillatorPhase = 0; float gSoundProjectileOscillatorGain = 0.2; float gOscillatorPhaseScaler = 0; @@ -178,6 +181,12 @@ gSoundBoomBufferPointer = -1; } + if(gSoundHitBuffer != 0 && gSoundHitBufferPointer >= 0) { + audioSample += gSoundHitBuffer[gSoundHitBufferPointer++]; + if(gSoundHitBufferPointer >= gSoundHitBufferLength) + gSoundHitBufferPointer = -1; + } + // Oscillator plays to indicate projectile height if(gameStatusProjectileInMotion()) { audioSample += gSoundProjectileOscillatorGain * sinf(gSoundProjectileOscillatorPhase); @@ -237,6 +246,10 @@ if(gameStatusCollisionOccurred()) { gSoundBoomBufferPointer = 0; } + + if(gameStatusTankHitOccurred()) { + gSoundHitBufferPointer = 0; + } } if(gScreenBufferReadPointer >= gScreenBufferReadLength - 1