Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
speech.cpp
00001 #include "speech.h" 00002 00003 #include "globals.h" 00004 #include "hardware.h" 00005 GameInputs in; 00006 Timer waitTime; 00007 /** 00008 * Draw the speech bubble background. 00009 */ 00010 static void draw_speech_bubble(); 00011 00012 /** 00013 * Erase the speech bubble. 00014 */ 00015 static void erase_speech_bubble(); 00016 00017 /** 00018 * Draw a single line of the speech bubble. 00019 * @param line The text to display 00020 * @param which If TOP, the first line; if BOTTOM, the second line. 00021 */ 00022 #define TOP 0 00023 #define BOTTOM 1 00024 static void draw_speech_line(const char* line, int which); 00025 00026 /** 00027 * Delay until it is time to scroll. 00028 */ 00029 static int speech_bubble_wait(GameInputs input); 00030 00031 void draw_speech_bubble() 00032 { 00033 uLCD.filled_rectangle(0, 113, 128, 93, 0x000000); 00034 00035 uLCD.filled_rectangle(0, 93, 128, 94, 0x00FF7F); 00036 uLCD.filled_rectangle(0, 113, 128, 111, 0x00FF7F); 00037 uLCD.filled_rectangle(0, 113, 1, 93, 0x00FF7F); 00038 uLCD.filled_rectangle(128, 113, 128, 93, 0x00FF7F); 00039 } 00040 00041 void erase_speech_bubble() 00042 { 00043 GameInputs in = read_inputs(); 00044 while(in.b1) { 00045 in = read_inputs(); 00046 wait_ms(300); 00047 } 00048 uLCD.filled_rectangle(0, 113, 128, 93, 0x000000); 00049 } 00050 00051 void draw_speech_line(const char* line, int which) 00052 { 00053 uLCD.textbackground_color(0x000000); 00054 uLCD.color(GREEN); 00055 uLCD.text_bold(TEXTBOLD); 00056 if(which == BOTTOM) { 00057 uLCD.locate(1,13); 00058 uLCD.printf(line); 00059 } else { 00060 uLCD.locate(1,12); 00061 uLCD.printf(line); 00062 } 00063 } 00064 00065 int speech_bubble_wait(GameInputs inputs) { 00066 00067 } 00068 void speech(const char* line1, const char* line2) 00069 { 00070 draw_speech_bubble(); 00071 draw_speech_line(line1, TOP); 00072 draw_speech_line(line2, BOTTOM); 00073 wait_ms(300); 00074 erase_speech_bubble(); 00075 } 00076 00077 void long_speech(const char* lines[], int n) 00078 { 00079 }
Generated on Thu Jul 14 2022 01:43:17 by
1.7.2