SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
MainGame.cpp@8:56a24df93680, 2016-10-28 (annotated)
- Committer:
- SeanBuckingham
- Date:
- Fri Oct 28 01:02:15 2016 +0000
- Revision:
- 8:56a24df93680
- Parent:
- main.cpp@1:8a3fa9e90572
- Child:
- 10:92538c02e6c8
started main game
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jboettcher | 0:137546fb5da1 | 1 | #include "mbed.h" |
jboettcher | 0:137546fb5da1 | 2 | #include "Speaker.h" |
jboettcher | 0:137546fb5da1 | 3 | #include "uLCD_4DGL.h" |
jboettcher | 0:137546fb5da1 | 4 | #include "SDFileSystem.h" |
jboettcher | 0:137546fb5da1 | 5 | #include "wave_player.h" |
jboettcher | 1:8a3fa9e90572 | 6 | #include "Nav_Switch.h" |
jboettcher | 1:8a3fa9e90572 | 7 | #include "rtos.h" |
jboettcher | 0:137546fb5da1 | 8 | |
SeanBuckingham | 8:56a24df93680 | 9 | /*INSTANTIATION*/ |
jboettcher | 0:137546fb5da1 | 10 | DigitalOut myled(LED1); |
jboettcher | 0:137546fb5da1 | 11 | uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin; |
jboettcher | 1:8a3fa9e90572 | 12 | Nav_Switch myNav( p24, p25, p26, p27, p28); //up, down, left, right, fire |
SeanBuckingham | 8:56a24df93680 | 13 | SDFileSystem sd(p5, p6, p7, p8, "sd"); |
jboettcher | 0:137546fb5da1 | 14 | AnalogOut DACout(p18); |
jboettcher | 0:137546fb5da1 | 15 | wave_player waver(&DACout); |
jboettcher | 0:137546fb5da1 | 16 | |
SeanBuckingham | 8:56a24df93680 | 17 | /*LOCAL VARIABLES*/ |
SeanBuckingham | 8:56a24df93680 | 18 | int numTries; |
SeanBuckingham | 8:56a24df93680 | 19 | int levelNum; |
SeanBuckingham | 8:56a24df93680 | 20 | int bulletLocation; |
SeanBuckingham | 8:56a24df93680 | 21 | int obstacleLocations; |
SeanBuckingham | 8:56a24df93680 | 22 | int targetLocations; |
SeanBuckingham | 8:56a24df93680 | 23 | |
SeanBuckingham | 8:56a24df93680 | 24 | void startGame() { |
SeanBuckingham | 8:56a24df93680 | 25 | uLCD.locate(34,34); |
SeanBuckingham | 8:56a24df93680 | 26 | uLCD.set_font_size(4, 4); |
SeanBuckingham | 8:56a24df93680 | 27 | uLCD.printf("\nSharp Shooter!!\n"); |
SeanBuckingham | 8:56a24df93680 | 28 | |
SeanBuckingham | 8:56a24df93680 | 29 | FILE *wave_file; |
SeanBuckingham | 8:56a24df93680 | 30 | wave_file=fopen("/sd/wavfiles/def_swar.wav","r"); |
SeanBuckingham | 8:56a24df93680 | 31 | waver.play(wave_file); |
SeanBuckingham | 8:56a24df93680 | 32 | fclose(wave_file); |
jboettcher | 0:137546fb5da1 | 33 | } |
jboettcher | 0:137546fb5da1 | 34 | |
SeanBuckingham | 8:56a24df93680 | 35 | void createTargets(); |
SeanBuckingham | 8:56a24df93680 | 36 | |
SeanBuckingham | 8:56a24df93680 | 37 | void checkIfHit(); |
SeanBuckingham | 8:56a24df93680 | 38 | |
SeanBuckingham | 8:56a24df93680 | 39 | void gameOver(); |
SeanBuckingham | 8:56a24df93680 | 40 | |
SeanBuckingham | 8:56a24df93680 | 41 | void initializeLevel(); |
SeanBuckingham | 8:56a24df93680 | 42 | |
SeanBuckingham | 8:56a24df93680 | 43 | void handleObstacleHit(); |
SeanBuckingham | 8:56a24df93680 | 44 | |
SeanBuckingham | 8:56a24df93680 | 45 | void handleTargetHit(); |
SeanBuckingham | 8:56a24df93680 | 46 | |
SeanBuckingham | 8:56a24df93680 | 47 | void redrawTarget(); |
SeanBuckingham | 8:56a24df93680 | 48 | |
SeanBuckingham | 8:56a24df93680 | 49 | /*if(myNav.fire()) myled=!myled; |
jboettcher | 1:8a3fa9e90572 | 50 | if(myNav.up()) myled=!myled; |
jboettcher | 1:8a3fa9e90572 | 51 | if(myNav.down()) myled=!myled; |
jboettcher | 1:8a3fa9e90572 | 52 | if(myNav.right()) myled=!myled; |
jboettcher | 1:8a3fa9e90572 | 53 | if(myNav.left()) myled=!myled; |
SeanBuckingham | 8:56a24df93680 | 54 | */ |
jboettcher | 1:8a3fa9e90572 | 55 | |
jboettcher | 0:137546fb5da1 | 56 | int main() { |
jboettcher | 1:8a3fa9e90572 | 57 | myled=0; |
jboettcher | 1:8a3fa9e90572 | 58 | while(1) { |
jboettcher | 1:8a3fa9e90572 | 59 | |
SeanBuckingham | 8:56a24df93680 | 60 | startGame(); |
SeanBuckingham | 8:56a24df93680 | 61 | |
SeanBuckingham | 8:56a24df93680 | 62 | |
SeanBuckingham | 8:56a24df93680 | 63 | |
SeanBuckingham | 8:56a24df93680 | 64 | |
SeanBuckingham | 8:56a24df93680 | 65 | |
SeanBuckingham | 8:56a24df93680 | 66 | |
SeanBuckingham | 8:56a24df93680 | 67 | |
SeanBuckingham | 8:56a24df93680 | 68 | } |
jboettcher | 0:137546fb5da1 | 69 | } |