Mercurial > hg > beaglert
comparison 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 |
comparison
equal
deleted
inserted
replaced
267:247a182adb6d | 268:8d80eda512cd |
---|---|
66 // Buffers for music and sound effects | 66 // Buffers for music and sound effects |
67 extern float *gMusicBuffer; | 67 extern float *gMusicBuffer; |
68 extern int gMusicBufferLength; | 68 extern int gMusicBufferLength; |
69 extern float *gSoundBoomBuffer; | 69 extern float *gSoundBoomBuffer; |
70 extern int gSoundBoomBufferLength; | 70 extern int gSoundBoomBufferLength; |
71 extern float *gSoundHitBuffer; | |
72 extern int gSoundHitBufferLength; | |
71 | 73 |
72 // Current state for sound and music | 74 // Current state for sound and music |
73 int gMusicBufferPointer = 0; // 0 means start of buffer... | 75 int gMusicBufferPointer = 0; // 0 means start of buffer... |
74 int gSoundBoomBufferPointer = -1; // -1 means don't play... | 76 int gSoundBoomBufferPointer = -1; // -1 means don't play... |
77 int gSoundHitBufferPointer = -1; | |
75 float gSoundProjectileOscillatorPhase = 0; | 78 float gSoundProjectileOscillatorPhase = 0; |
76 float gSoundProjectileOscillatorGain = 0.2; | 79 float gSoundProjectileOscillatorGain = 0.2; |
77 float gOscillatorPhaseScaler = 0; | 80 float gOscillatorPhaseScaler = 0; |
78 | 81 |
79 void screen_update(); | 82 void screen_update(); |
174 // Sound effect plays until finished, then stops | 177 // Sound effect plays until finished, then stops |
175 if(gSoundBoomBuffer != 0 && gSoundBoomBufferPointer >= 0) { | 178 if(gSoundBoomBuffer != 0 && gSoundBoomBufferPointer >= 0) { |
176 audioSample += gSoundBoomBuffer[gSoundBoomBufferPointer++]; | 179 audioSample += gSoundBoomBuffer[gSoundBoomBufferPointer++]; |
177 if(gSoundBoomBufferPointer >= gSoundBoomBufferLength) | 180 if(gSoundBoomBufferPointer >= gSoundBoomBufferLength) |
178 gSoundBoomBufferPointer = -1; | 181 gSoundBoomBufferPointer = -1; |
182 } | |
183 | |
184 if(gSoundHitBuffer != 0 && gSoundHitBufferPointer >= 0) { | |
185 audioSample += gSoundHitBuffer[gSoundHitBufferPointer++]; | |
186 if(gSoundHitBufferPointer >= gSoundHitBufferLength) | |
187 gSoundHitBufferPointer = -1; | |
179 } | 188 } |
180 | 189 |
181 // Oscillator plays to indicate projectile height | 190 // Oscillator plays to indicate projectile height |
182 if(gameStatusProjectileInMotion()) { | 191 if(gameStatusProjectileInMotion()) { |
183 audioSample += gSoundProjectileOscillatorGain * sinf(gSoundProjectileOscillatorPhase); | 192 audioSample += gSoundProjectileOscillatorGain * sinf(gSoundProjectileOscillatorPhase); |
235 | 244 |
236 // Check for collision and start sound accordingly | 245 // Check for collision and start sound accordingly |
237 if(gameStatusCollisionOccurred()) { | 246 if(gameStatusCollisionOccurred()) { |
238 gSoundBoomBufferPointer = 0; | 247 gSoundBoomBufferPointer = 0; |
239 } | 248 } |
249 | |
250 if(gameStatusTankHitOccurred()) { | |
251 gSoundHitBufferPointer = 0; | |
252 } | |
240 } | 253 } |
241 | 254 |
242 if(gScreenBufferReadPointer >= gScreenBufferReadLength - 1 | 255 if(gScreenBufferReadPointer >= gScreenBufferReadLength - 1 |
243 && gScreenNextBufferReady) { | 256 && gScreenNextBufferReady) { |
244 // Got to the end; swap buffers | 257 // Got to the end; swap buffers |