ECE 2035 final project
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: speech.cpp
- Revision:
- 2:22d36e7740f1
- Parent:
- 0:35660d7952f7
--- a/speech.cpp Wed Apr 04 21:11:07 2018 +0000 +++ b/speech.cpp Mon Apr 15 12:25:08 2019 +0000 @@ -29,25 +29,78 @@ void draw_speech_bubble() { + //draw speech bubble borders + uLCD.line(0, 114, 127, 114, GREEN); // Bottom + uLCD.line(0, 70, 127, 70, GREEN); // Top + uLCD.line(0, 71, 0, 113, GREEN); // Left + uLCD.line(127, 71, 127, 113, GREEN); // Right + + //fill speech bubble borders + uLCD.filled_rectangle(1, 71, 126, 113, 5); } void erase_speech_bubble() { + //restore original color at speech bubble borders + uLCD.line(0, 114, 127, 114, WHITE); // Bottom + uLCD.line(0, 94, 127, 94, BLACK); // Top + uLCD.line(0, 95, 0, 113, WHITE); // Left + uLCD.line(127, 95, 127, 113, WHITE); // Right + + uLCD.filled_rectangle(1, 95, 126, 113, BLACK); + } void draw_speech_line(const char* line, int which) { + if(which == TOP) + { + uLCD.locate(1,9); + uLCD.printf(line); + } + else if(which == BOTTOM) + { + uLCD.locate(1,10); + uLCD.printf(line); + } + else if(which == 3) + { + uLCD.locate(1,11); + uLCD.printf(line); + } + else + { + uLCD.locate(1,12); + uLCD.printf(line); + } + } void speech_bubble_wait() { + GameInputs inputs; + inputs = read_inputs(); + int blink = 1; + while(inputs.b1) + { + blink = !blink; + wait_ms(200); + if(blink) + uLCD.filled_circle(123, 114, 3, GREEN); + else + uLCD.filled_circle(123, 114, 3, BLACK); + inputs = read_inputs(); + + } } -void speech(const char* line1, const char* line2) +void speech(const char* line1, const char* line2, const char* line3, const char* line4) { draw_speech_bubble(); draw_speech_line(line1, TOP); draw_speech_line(line2, BOTTOM); + draw_speech_line(line3, 3); + draw_speech_line(line4, 4); speech_bubble_wait(); erase_speech_bubble(); }