simon says
Dependencies: 4DGL-uLCD-SE Joystick SDFileSystem mbed wave_player
main.cpp@0:aa7531dac907, 2017-03-09 (annotated)
- Committer:
- elirobelo
- Date:
- Thu Mar 09 21:53:59 2017 +0000
- Revision:
- 0:aa7531dac907
- Child:
- 1:6a079fb5542e
simon says
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elirobelo | 0:aa7531dac907 | 1 | #include "mbed.h" |
elirobelo | 0:aa7531dac907 | 2 | #include "SDFileSystem.h" |
elirobelo | 0:aa7531dac907 | 3 | #include "uLCD_4DGL.h" |
elirobelo | 0:aa7531dac907 | 4 | #include "wave_player.h" |
elirobelo | 0:aa7531dac907 | 5 | #include "Joystick.h" |
elirobelo | 0:aa7531dac907 | 6 | |
elirobelo | 0:aa7531dac907 | 7 | |
elirobelo | 0:aa7531dac907 | 8 | Nav_Switch myNav( p9, p6, p7, p5, p8); |
elirobelo | 0:aa7531dac907 | 9 | uLCD_4DGL uLCD(p28, p27, p29); |
elirobelo | 0:aa7531dac907 | 10 | SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card |
elirobelo | 0:aa7531dac907 | 11 | |
elirobelo | 0:aa7531dac907 | 12 | int arrowVec[20]; |
elirobelo | 0:aa7531dac907 | 13 | |
elirobelo | 0:aa7531dac907 | 14 | |
elirobelo | 0:aa7531dac907 | 15 | int arrow; |
elirobelo | 0:aa7531dac907 | 16 | |
elirobelo | 0:aa7531dac907 | 17 | void mainMenu() { |
elirobelo | 0:aa7531dac907 | 18 | uLCD.baudrate(BAUD_3000000); |
elirobelo | 0:aa7531dac907 | 19 | while(1){ |
elirobelo | 0:aa7531dac907 | 20 | uLCD.locate(3,2); |
elirobelo | 0:aa7531dac907 | 21 | uLCD.puts("Simon Says"); |
elirobelo | 0:aa7531dac907 | 22 | uLCD.locate(3,6); |
elirobelo | 0:aa7531dac907 | 23 | uLCD.puts("Start"); |
elirobelo | 0:aa7531dac907 | 24 | if(myNav.fire()) { |
elirobelo | 0:aa7531dac907 | 25 | uLCD.cls(); |
elirobelo | 0:aa7531dac907 | 26 | return; |
elirobelo | 0:aa7531dac907 | 27 | } |
elirobelo | 0:aa7531dac907 | 28 | } |
elirobelo | 0:aa7531dac907 | 29 | } |
elirobelo | 0:aa7531dac907 | 30 | void createArrows(int lev) { |
elirobelo | 0:aa7531dac907 | 31 | |
elirobelo | 0:aa7531dac907 | 32 | for (int i = 0; i < lev; i++) { |
elirobelo | 0:aa7531dac907 | 33 | if (arrowVec[i] == 1) { |
elirobelo | 0:aa7531dac907 | 34 | uLCD.triangle(15, 50, 35, 45, 35, 75, RED); |
elirobelo | 0:aa7531dac907 | 35 | uLCD.rectangle(35,50,85,70,RED); |
elirobelo | 0:aa7531dac907 | 36 | } else if (arrowVec[i] == 2) { |
elirobelo | 0:aa7531dac907 | 37 | //uLCD.triangle(int x1, int y1 , int x2, int y2, int x3, int y3, RED); |
elirobelo | 0:aa7531dac907 | 38 | uLCD.rectangle(35,50,85,70,BLUE); |
elirobelo | 0:aa7531dac907 | 39 | } else if (arrowVec[i] == 3) { |
elirobelo | 0:aa7531dac907 | 40 | //uLCD.triangle(); |
elirobelo | 0:aa7531dac907 | 41 | uLCD.rectangle(35,50,85,70,GREEN); |
elirobelo | 0:aa7531dac907 | 42 | } else { |
elirobelo | 0:aa7531dac907 | 43 | uLCD.rectangle(35,50,85,70,WHITE); |
elirobelo | 0:aa7531dac907 | 44 | } |
elirobelo | 0:aa7531dac907 | 45 | } |
elirobelo | 0:aa7531dac907 | 46 | } |
elirobelo | 0:aa7531dac907 | 47 | |
elirobelo | 0:aa7531dac907 | 48 | |
elirobelo | 0:aa7531dac907 | 49 | int main() { |
elirobelo | 0:aa7531dac907 | 50 | bool game = true; |
elirobelo | 0:aa7531dac907 | 51 | int level = 0; |
elirobelo | 0:aa7531dac907 | 52 | //int arrowVec[20]; |
elirobelo | 0:aa7531dac907 | 53 | //void mainMenu(); |
elirobelo | 0:aa7531dac907 | 54 | |
elirobelo | 0:aa7531dac907 | 55 | |
elirobelo | 0:aa7531dac907 | 56 | while(game) { |
elirobelo | 0:aa7531dac907 | 57 | level++; |
elirobelo | 0:aa7531dac907 | 58 | // for (int i = 0; i < level; i++) { |
elirobelo | 0:aa7531dac907 | 59 | // arrow = (rand() % 4) + 1; |
elirobelo | 0:aa7531dac907 | 60 | // arrowVec[i] = arrow; |
elirobelo | 0:aa7531dac907 | 61 | // } |
elirobelo | 0:aa7531dac907 | 62 | arrowVec[0] = 1; |
elirobelo | 0:aa7531dac907 | 63 | createArrows(level); |
elirobelo | 0:aa7531dac907 | 64 | game = false; |
elirobelo | 0:aa7531dac907 | 65 | } |
elirobelo | 0:aa7531dac907 | 66 | |
elirobelo | 0:aa7531dac907 | 67 | |
elirobelo | 0:aa7531dac907 | 68 | } |