Shell code for the Tanks game
Dependencies: 4DGL-uLCD-SE EthernetInterface Game_Synchronizer MMA8452 SDFileSystem mbed-rtos mbed wave_player
misc/misc.cpp@23:77049670cae6, 2015-10-30 (annotated)
- Committer:
- jford38
- Date:
- Fri Oct 30 08:54:10 2015 +0000
- Revision:
- 23:77049670cae6
- Parent:
- 22:3c68eea5a609
Final final final version. Maybe. For now. Ugh.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jford38 | 20:6a58052b0140 | 1 | #include "misc.h" |
jford38 | 22:3c68eea5a609 | 2 | #include "uLCD_4DGL.h" |
jford38 | 22:3c68eea5a609 | 3 | #include "SDFileSystem.h" |
jford38 | 22:3c68eea5a609 | 4 | #include "wave_player.h" |
jford38 | 22:3c68eea5a609 | 5 | |
jford38 | 22:3c68eea5a609 | 6 | extern uLCD_4DGL uLCD; |
jford38 | 22:3c68eea5a609 | 7 | extern wave_player player; |
jford38 | 22:3c68eea5a609 | 8 | |
jford38 | 22:3c68eea5a609 | 9 | // Given the filename of a .wav file in the SD card, play the file over the speaker. |
jford38 | 22:3c68eea5a609 | 10 | void playSound(char * wav) |
jford38 | 22:3c68eea5a609 | 11 | { |
jford38 | 22:3c68eea5a609 | 12 | // open wav file |
jford38 | 22:3c68eea5a609 | 13 | FILE *wave_file; |
jford38 | 22:3c68eea5a609 | 14 | wave_file=fopen(wav,"r"); |
jford38 | 22:3c68eea5a609 | 15 | |
jford38 | 22:3c68eea5a609 | 16 | if(wave_file == NULL){ |
jford38 | 22:3c68eea5a609 | 17 | uLCD.locate(0,4); |
jford38 | 22:3c68eea5a609 | 18 | uLCD.printf("Error in SD"); |
jford38 | 22:3c68eea5a609 | 19 | return; |
jford38 | 22:3c68eea5a609 | 20 | } |
jford38 | 22:3c68eea5a609 | 21 | // play wav file |
jford38 | 22:3c68eea5a609 | 22 | player.play(wave_file); |
jford38 | 22:3c68eea5a609 | 23 | |
jford38 | 22:3c68eea5a609 | 24 | // close wav file |
jford38 | 22:3c68eea5a609 | 25 | fclose(wave_file); |
jford38 | 14:36c306e26317 | 26 | } |