SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Diff: MainGame.cpp
- Revision:
- 8:56a24df93680
- Parent:
- 1:8a3fa9e90572
- Child:
- 10:92538c02e6c8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MainGame.cpp Fri Oct 28 01:02:15 2016 +0000 @@ -0,0 +1,69 @@ +#include "mbed.h" +#include "Speaker.h" +#include "uLCD_4DGL.h" +#include "SDFileSystem.h" +#include "wave_player.h" +#include "Nav_Switch.h" +#include "rtos.h" + +/*INSTANTIATION*/ +DigitalOut myled(LED1); +uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin; +Nav_Switch myNav( p24, p25, p26, p27, p28); //up, down, left, right, fire +SDFileSystem sd(p5, p6, p7, p8, "sd"); +AnalogOut DACout(p18); +wave_player waver(&DACout); + +/*LOCAL VARIABLES*/ +int numTries; +int levelNum; +int bulletLocation; +int obstacleLocations; +int targetLocations; + +void startGame() { + uLCD.locate(34,34); + uLCD.set_font_size(4, 4); + uLCD.printf("\nSharp Shooter!!\n"); + + FILE *wave_file; + wave_file=fopen("/sd/wavfiles/def_swar.wav","r"); + waver.play(wave_file); + fclose(wave_file); +} + +void createTargets(); + +void checkIfHit(); + +void gameOver(); + +void initializeLevel(); + +void handleObstacleHit(); + +void handleTargetHit(); + +void redrawTarget(); + +/*if(myNav.fire()) myled=!myled; + if(myNav.up()) myled=!myled; + if(myNav.down()) myled=!myled; + if(myNav.right()) myled=!myled; + if(myNav.left()) myled=!myled; + */ + +int main() { + myled=0; + while(1) { + + startGame(); + + + + + + + + } +}