Adventure game written for ECE2035 at the Georgia Institute of Technology
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
speech.cpp@2:0876296d9473, 2018-04-17 (annotated)
- Committer:
- trmontgomery
- Date:
- Tue Apr 17 17:17:20 2018 +0000
- Revision:
- 2:0876296d9473
- Parent:
- 0:35660d7952f7
- Child:
- 4:cdc54191ff07
Baseline completed + 3 features
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rconnorlawson | 0:35660d7952f7 | 1 | #include "speech.h" |
rconnorlawson | 0:35660d7952f7 | 2 | |
rconnorlawson | 0:35660d7952f7 | 3 | #include "globals.h" |
rconnorlawson | 0:35660d7952f7 | 4 | #include "hardware.h" |
rconnorlawson | 0:35660d7952f7 | 5 | |
rconnorlawson | 0:35660d7952f7 | 6 | /** |
rconnorlawson | 0:35660d7952f7 | 7 | * Draw the speech bubble background. |
rconnorlawson | 0:35660d7952f7 | 8 | */ |
rconnorlawson | 0:35660d7952f7 | 9 | static void draw_speech_bubble(); |
rconnorlawson | 0:35660d7952f7 | 10 | |
rconnorlawson | 0:35660d7952f7 | 11 | /** |
rconnorlawson | 0:35660d7952f7 | 12 | * Erase the speech bubble. |
rconnorlawson | 0:35660d7952f7 | 13 | */ |
rconnorlawson | 0:35660d7952f7 | 14 | static void erase_speech_bubble(); |
rconnorlawson | 0:35660d7952f7 | 15 | |
rconnorlawson | 0:35660d7952f7 | 16 | /** |
rconnorlawson | 0:35660d7952f7 | 17 | * Draw a single line of the speech bubble. |
rconnorlawson | 0:35660d7952f7 | 18 | * @param line The text to display |
rconnorlawson | 0:35660d7952f7 | 19 | * @param which If TOP, the first line; if BOTTOM, the second line. |
rconnorlawson | 0:35660d7952f7 | 20 | */ |
rconnorlawson | 0:35660d7952f7 | 21 | #define TOP 0 |
rconnorlawson | 0:35660d7952f7 | 22 | #define BOTTOM 1 |
rconnorlawson | 0:35660d7952f7 | 23 | static void draw_speech_line(const char* line, int which); |
rconnorlawson | 0:35660d7952f7 | 24 | |
rconnorlawson | 0:35660d7952f7 | 25 | /** |
rconnorlawson | 0:35660d7952f7 | 26 | * Delay until it is time to scroll. |
rconnorlawson | 0:35660d7952f7 | 27 | */ |
rconnorlawson | 0:35660d7952f7 | 28 | static void speech_bubble_wait(); |
rconnorlawson | 0:35660d7952f7 | 29 | |
rconnorlawson | 0:35660d7952f7 | 30 | void draw_speech_bubble() |
rconnorlawson | 0:35660d7952f7 | 31 | { |
trmontgomery | 2:0876296d9473 | 32 | uLCD.filled_rectangle(0, 128, 128, 90, 0xFFFFFF); //(x1, y1, x2, y2) where (x1, y1) is bottom left corner and (x2, y2) is upper right corner |
rconnorlawson | 0:35660d7952f7 | 33 | } |
rconnorlawson | 0:35660d7952f7 | 34 | |
rconnorlawson | 0:35660d7952f7 | 35 | void erase_speech_bubble() |
rconnorlawson | 0:35660d7952f7 | 36 | { |
trmontgomery | 2:0876296d9473 | 37 | uLCD.filled_rectangle(0, 128, 128, 90, 0x000000); |
trmontgomery | 2:0876296d9473 | 38 | //uLCD.filled_rectangle(0, 128, 128, 90, 0x000000); |
rconnorlawson | 0:35660d7952f7 | 39 | } |
rconnorlawson | 0:35660d7952f7 | 40 | |
rconnorlawson | 0:35660d7952f7 | 41 | void draw_speech_line(const char* line, int which) |
rconnorlawson | 0:35660d7952f7 | 42 | { |
trmontgomery | 2:0876296d9473 | 43 | if (which == TOP){ |
trmontgomery | 2:0876296d9473 | 44 | uLCD.locate(1,12); //TO DO: the line overlaps with second line if too long |
trmontgomery | 2:0876296d9473 | 45 | } else if (which == BOTTOM){ |
trmontgomery | 2:0876296d9473 | 46 | uLCD.locate(1,13); |
trmontgomery | 2:0876296d9473 | 47 | } |
trmontgomery | 2:0876296d9473 | 48 | // basic printf demo = 16 by 18 characters on screen |
trmontgomery | 2:0876296d9473 | 49 | uLCD.text_mode(TRANSPARENT); |
trmontgomery | 2:0876296d9473 | 50 | uLCD.color(BLACK); |
trmontgomery | 2:0876296d9473 | 51 | uLCD.printf(line); |
rconnorlawson | 0:35660d7952f7 | 52 | } |
rconnorlawson | 0:35660d7952f7 | 53 | |
rconnorlawson | 0:35660d7952f7 | 54 | void speech_bubble_wait() |
rconnorlawson | 0:35660d7952f7 | 55 | { |
trmontgomery | 2:0876296d9473 | 56 | wait(2); |
rconnorlawson | 0:35660d7952f7 | 57 | } |
rconnorlawson | 0:35660d7952f7 | 58 | |
rconnorlawson | 0:35660d7952f7 | 59 | void speech(const char* line1, const char* line2) |
rconnorlawson | 0:35660d7952f7 | 60 | { |
rconnorlawson | 0:35660d7952f7 | 61 | draw_speech_bubble(); |
rconnorlawson | 0:35660d7952f7 | 62 | draw_speech_line(line1, TOP); |
rconnorlawson | 0:35660d7952f7 | 63 | draw_speech_line(line2, BOTTOM); |
rconnorlawson | 0:35660d7952f7 | 64 | speech_bubble_wait(); |
rconnorlawson | 0:35660d7952f7 | 65 | erase_speech_bubble(); |
rconnorlawson | 0:35660d7952f7 | 66 | } |
rconnorlawson | 0:35660d7952f7 | 67 | |
rconnorlawson | 0:35660d7952f7 | 68 | void long_speech(const char* lines[], int n) |
rconnorlawson | 0:35660d7952f7 | 69 | { |
rconnorlawson | 0:35660d7952f7 | 70 | } |