Faizan and Pages fun little game
Dependencies: 4DGL-uLCD-SE mbed SDFileSystem wave_player
Diff: main.cpp
- Revision:
- 17:95948ed73911
- Parent:
- 16:702313ea97b9
- Child:
- 18:2e42ec5e2311
--- a/main.cpp Mon Oct 31 19:07:47 2016 +0000 +++ b/main.cpp Mon Oct 31 20:03:20 2016 +0000 @@ -61,7 +61,6 @@ lcd.filled_rectangle(34, 98, 44, 97, BROWN); FILE *wave_file; - lcd.printf("\n\n\nHello, wave world!\n"); // for debug right now wave_file=fopen("/sd/start.wav","r"); waver.play(wave_file); fclose(wave_file); @@ -103,9 +102,19 @@ updateScore(0); while(lives) { - if (joystick.left()) { + if (!pause) { // pause game + lcd.text_string("PAUSED", 6, 7, FONT_7X8, WHITE); + int paused = 1; + while (paused) { + wait(.2); + paused = pause; + } + lcd.text_string("PAUSED", 6, 7, FONT_7X8, BLACK); + } + + if (joystick.up()) { sandwich.move(-1); - } else if (joystick.right()) { + } else if (joystick.down()) { sandwich.move(+1); } if (collisionCheck()) { @@ -175,13 +184,8 @@ void updateScore(int sandwichSize) { char scoreString[2]; // max 2-digit score -// // C#, D#, F, A, D, E, F#, A#, _, A, Bb, B, C -// float notes[14] = {554.4, 622.3, 698.5, 880, 587.3, 659.3, 740, 932.3, 0, 440, 466.2, 493.9, 523.3, 0}; -// float times[14] = {0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.48, 0.48, 0.48, 0.48, 0.48, 0}; -// speaker.PlaySong(notes, times); FILE *wave_file; - lcd.printf("\n\n\nHello, wave world!\n"); // for debug right now wave_file=fopen("/sd/score.wav","r"); waver.play(wave_file); fclose(wave_file); @@ -193,15 +197,8 @@ } void drawLives() { - // G, D, _, D, D, C, B, G, E, _, E, C, _ -// float notes[13] = {195.9, 293.6, 0, 293.6, 293.6, 261.6, 246.9, 195.9, 164.8, 0, 164.8, 130.8, 0}; -// float times[13] = {0.24, 0.24, 0.24, 0.24, 0.32, 0.32, 0.32, 0.24, 0.24, 0.24, 0.24, 0.24, 0}; -// -// speaker.PlaySong(notes, times); -// FILE *wave_file; - lcd.printf("\n\n\nHello, wave world!\n"); // for debug right now wave_file=fopen("/sd/life.wav","r"); waver.play(wave_file); fclose(wave_file);