![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Guitar Hero Project on LPC1768 using push buttons, analog joystick. speaker and LCD Display
Dependencies: mbed wave_player mbed-rtos 4DGL-uLCD-SE SparkfunAnalogJoystick SDFileSystem_OldbutworkswithRTOS PinDetect
Diff: main.cpp
- Revision:
- 6:4bc137ec1022
- Parent:
- 5:2f09b457f690
- Child:
- 7:5ac5056cde2c
--- a/main.cpp Fri Nov 20 17:19:58 2020 +0000 +++ b/main.cpp Thu Nov 26 16:40:43 2020 +0000 @@ -12,8 +12,6 @@ Mutex lcd_mut; //SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card uLCD_4DGL uLCD(p28,p27,p30); // serial tx, serial rx, reset pin; -//AnalogOut DACout(p18); -//wave_player waver(&DACout); AnalogOut speaker(p18); PinDetect pb_1(p9, PullUp); PinDetect pb_2(p10, PullUp); @@ -47,6 +45,10 @@ volatile bool draw_enable = true; volatile int Speed = Easy; +volatile int score = 0; +volatile int high_score = 0; +volatile int hits = 0; +volatile int misses = 0; int i=0; void audio_sample () { @@ -83,14 +85,30 @@ uLCD.text_width(1); uLCD.text_height(2); uLCD.text_string("Game Over",4,0,FONT_8X8, BLUE); - + uLCD.text_width(1); uLCD.text_height(1); - uLCD.text_string("Score:",2,6,FONT_8X8, YELLOW); - uLCD.text_string("Hits:",2,8,FONT_8X8, GREEN); - uLCD.text_string("Misses:",2,10,FONT_8X8, RED); + uLCD.color(YELLOW); + uLCD.locate(2,3); + uLCD.printf("Score:%d", score); + + uLCD.color(GREEN); + uLCD.locate(2,5); + uLCD.printf("Hits:%d", hits); + + uLCD.color(RED); + uLCD.locate(2,7); + uLCD.printf("Misses:%d", misses); uLCD.text_height(2); - uLCD.text_string("High Score:",2,6,FONT_8X8, WHITE); + + uLCD.color(WHITE); + uLCD.text_underline(ON); + uLCD.text_string("High Score",4,5,FONT_8X8, WHITE); + uLCD.text_underline(OFF); + uLCD.text_height(1); + uLCD.locate(4,13); + uLCD.text_height(2); + uLCD.printf("%d", high_score); uLCD.text_height(1); lcd_mut.unlock(); @@ -253,7 +271,6 @@ switch (Game_State) { case Start_Game : draw_enable = true; - Game_State = Game_Over; break; case Game_Over : draw_enable = true; @@ -284,7 +301,6 @@ switch (Game_State) { case Start_Game : draw_enable = true; - Game_State = Game_Over; break; case Game_Over : draw_enable = true; @@ -315,7 +331,6 @@ switch (Game_State) { case Start_Game : draw_enable = true; - Game_State = Game_Over; break; case Game_Over : draw_enable = true; @@ -346,7 +361,6 @@ switch (Game_State) { case Start_Game : draw_enable = true; - Game_State = Game_Over; break; case Game_Over : draw_enable = true;