Robin Milward Cooney 200849894
Dependencies: N5110 SDFileSystem gameCharacters mbed
main.cpp@3:4b254b4bd6d4, 2016-05-05 (annotated)
- Committer:
- robinmc
- Date:
- Thu May 05 14:59:45 2016 +0000
- Revision:
- 3:4b254b4bd6d4
- Parent:
- 2:158d57cdbf1e
Fun game
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
robinmc | 3:4b254b4bd6d4 | 1 | /** |
robinmc | 3:4b254b4bd6d4 | 2 | @file main.cpp |
robinmc | 3:4b254b4bd6d4 | 3 | @brief Revision 1.0. |
robinmc | 3:4b254b4bd6d4 | 4 | @author Robin Milward Cooney |
robinmc | 3:4b254b4bd6d4 | 5 | @date May 2015 |
robinmc | 3:4b254b4bd6d4 | 6 | */ |
robinmc | 3:4b254b4bd6d4 | 7 | |
robinmc | 0:28392431dbad | 8 | /* ELEC2645 Game - Shooty shooty bang bang (priliminary name) |
robinmc | 0:28392431dbad | 9 | |
robinmc | 0:28392431dbad | 10 | Week 19 - initial version, basic testing of sensor and display |
robinmc | 0:28392431dbad | 11 | |
robinmc | 0:28392431dbad | 12 | (c) Robni Milward Cooney Uniersity of Leeds, 06/03/16 |
robinmc | 0:28392431dbad | 13 | |
robinmc | 0:28392431dbad | 14 | */ |
robinmc | 0:28392431dbad | 15 | |
robinmc | 3:4b254b4bd6d4 | 16 | #include "main.h" |
robinmc | 0:28392431dbad | 17 | |
robinmc | 3:4b254b4bd6d4 | 18 | int main() //main function, currently used to test different functions |
robinmc | 3:4b254b4bd6d4 | 19 | { |
robinmc | 3:4b254b4bd6d4 | 20 | initialize_values(); //Call the initialize_values funtion |
robinmc | 3:4b254b4bd6d4 | 21 | lcd.init(); //Initialize the LCD |
robinmc | 3:4b254b4bd6d4 | 22 | b_A.mode(PullDown); //Declare the Pull down state of the digital in b_A |
robinmc | 3:4b254b4bd6d4 | 23 | b_B.mode(PullDown); //Declare the Pull down state of the digital in b_B |
robinmc | 3:4b254b4bd6d4 | 24 | swJoy.mode(PullDown); //Declare the Pull down state of the digital in swJoy |
robinmc | 3:4b254b4bd6d4 | 25 | Ticker_Menu.attach(&Ticker_Menu_isr,0.15); //Set the ticker for menus to flag every 0.15 seconds |
robinmc | 3:4b254b4bd6d4 | 26 | Ticker_Game.attach(&Ticker_Game_isr,0.1); //Set the ticker for the game to flag every 0.1 seconds |
robinmc | 3:4b254b4bd6d4 | 27 | Ticker_ds.attach(&Ticker_ds_isr,0.1); //Set the ticker for the ticker_wait funtion to flag every 0.1 seconds |
robinmc | 3:4b254b4bd6d4 | 28 | press_b_A.fall(&press_b_A_isr); //Set interrupt to flag when buttion A pressed |
robinmc | 3:4b254b4bd6d4 | 29 | press_b_A.mode(PullDown); // Declare that button A is pulldown |
robinmc | 3:4b254b4bd6d4 | 30 | press_b_B.fall(&press_b_B_isr); //Set interrupt to flag when buttion B pressed |
robinmc | 3:4b254b4bd6d4 | 31 | press_b_B.mode(PullDown); // Declare that button A is pulldown |
robinmc | 3:4b254b4bd6d4 | 32 | calibrateJoystick(); //Initialize the joystick, allocating a defalut possition for xJoy and yJoy |
robinmc | 3:4b254b4bd6d4 | 33 | intro(); //Prints the name of the game before the manin menu runs |
robinmc | 3:4b254b4bd6d4 | 34 | main_menu(); //Funtion that runs the main menu, the game itself it called within the main_menu() funtion |
robinmc | 3:4b254b4bd6d4 | 35 | } |
robinmc | 0:28392431dbad | 36 | |
robinmc | 3:4b254b4bd6d4 | 37 | |
robinmc | 3:4b254b4bd6d4 | 38 | // ----------------------------------------------------------------------------------------------------------------------------------------- |
robinmc | 3:4b254b4bd6d4 | 39 | |
robinmc | 3:4b254b4bd6d4 | 40 | // Funtion that initializes all values so when the game ends and is re_played all the variables are in there initial state |
robinmc | 0:28392431dbad | 41 | void initialize_values() |
robinmc | 0:28392431dbad | 42 | { |
robinmc | 3:4b254b4bd6d4 | 43 | |
robinmc | 3:4b254b4bd6d4 | 44 | //the movements of all the interactive elements are arranged so they start off screen and as the value _movement values increases |
robinmc | 3:4b254b4bd6d4 | 45 | //they begin to appear on screen |
robinmc | 1:046e66f1ca76 | 46 | rat_movement=85; |
robinmc | 1:046e66f1ca76 | 47 | hound_hMovement=90; |
robinmc | 1:046e66f1ca76 | 48 | hound_vMovement=40; |
robinmc | 1:046e66f1ca76 | 49 | hound_jump=0; |
robinmc | 0:28392431dbad | 50 | bear_movement=100; |
robinmc | 0:28392431dbad | 51 | bird_hMovement=95; |
robinmc | 0:28392431dbad | 52 | bird_vMovement=20; |
robinmc | 0:28392431dbad | 53 | cactus_movement=110; |
robinmc | 0:28392431dbad | 54 | t_rex_movement=120; |
robinmc | 3:4b254b4bd6d4 | 55 | quick_sand_movement=85; |
robinmc | 0:28392431dbad | 56 | fire_ball_hMovement=t_rex_movement-6; |
robinmc | 1:046e66f1ca76 | 57 | fire_ball_vMovement=25; |
robinmc | 0:28392431dbad | 58 | heart_movement=90; |
robinmc | 0:28392431dbad | 59 | ammo_movement=100; |
robinmc | 3:4b254b4bd6d4 | 60 | |
robinmc | 3:4b254b4bd6d4 | 61 | //Thenu state is reset to 0 so that the first menu option is highlited when returned to the main menu |
robinmc | 3:4b254b4bd6d4 | 62 | menuState=0; |
robinmc | 3:4b254b4bd6d4 | 63 | |
robinmc | 3:4b254b4bd6d4 | 64 | //All action flags are re-set to 0 |
robinmc | 0:28392431dbad | 65 | jump_flag=0; |
robinmc | 0:28392431dbad | 66 | shoot_flag=0; |
robinmc | 2:158d57cdbf1e | 67 | shield_flag=0; |
robinmc | 3:4b254b4bd6d4 | 68 | hound_jump_flag=0; |
robinmc | 3:4b254b4bd6d4 | 69 | |
robinmc | 3:4b254b4bd6d4 | 70 | |
robinmc | 3:4b254b4bd6d4 | 71 | //All print flags are set to 0 |
robinmc | 1:046e66f1ca76 | 72 | print_rat_flag=0; |
robinmc | 1:046e66f1ca76 | 73 | print_hound_flag=0; |
robinmc | 0:28392431dbad | 74 | print_bear_flag=0; |
robinmc | 0:28392431dbad | 75 | print_bird_flag=0; |
robinmc | 0:28392431dbad | 76 | print_heart_flag=0; |
robinmc | 0:28392431dbad | 77 | print_ammo_flag=0; |
robinmc | 2:158d57cdbf1e | 78 | print_speed_boost_flag=0; |
robinmc | 0:28392431dbad | 79 | print_cactus_flag=0; |
robinmc | 0:28392431dbad | 80 | print_t_rex_flag=0; |
robinmc | 3:4b254b4bd6d4 | 81 | print_quick_sand_flag=0; |
robinmc | 0:28392431dbad | 82 | print_fire_ball_flag=0; |
robinmc | 3:4b254b4bd6d4 | 83 | fire_on_screen=0; |
robinmc | 3:4b254b4bd6d4 | 84 | |
robinmc | 3:4b254b4bd6d4 | 85 | //Score and relevant score variable are set to 0 |
robinmc | 3:4b254b4bd6d4 | 86 | score=0; |
robinmc | 3:4b254b4bd6d4 | 87 | kill_score=0; |
robinmc | 3:4b254b4bd6d4 | 88 | shield_score=0; |
robinmc | 3:4b254b4bd6d4 | 89 | |
robinmc | 3:4b254b4bd6d4 | 90 | //Other miscellaneous varaivles relevent to the game are set |
robinmc | 3:4b254b4bd6d4 | 91 | red_led = 1; |
robinmc | 3:4b254b4bd6d4 | 92 | green_led=1; |
robinmc | 3:4b254b4bd6d4 | 93 | i=0; |
robinmc | 3:4b254b4bd6d4 | 94 | g_shoot_loop=0; |
robinmc | 3:4b254b4bd6d4 | 95 | recks_movement=2; |
robinmc | 3:4b254b4bd6d4 | 96 | fall=37; |
robinmc | 3:4b254b4bd6d4 | 97 | g_jump=36; |
robinmc | 3:4b254b4bd6d4 | 98 | accel=0; |
robinmc | 3:4b254b4bd6d4 | 99 | bullet=9; |
robinmc | 3:4b254b4bd6d4 | 100 | h_movement=0; |
robinmc | 3:4b254b4bd6d4 | 101 | ammo=24; |
robinmc | 0:28392431dbad | 102 | lose_lives_delay_flag=0; |
robinmc | 0:28392431dbad | 103 | lives_delay_loop=0; |
robinmc | 0:28392431dbad | 104 | lives=4; |
robinmc | 0:28392431dbad | 105 | bear_lives=0; |
robinmc | 3:4b254b4bd6d4 | 106 | shield_counter=0; |
robinmc | 3:4b254b4bd6d4 | 107 | |
robinmc | 0:28392431dbad | 108 | } |
robinmc | 0:28392431dbad | 109 | |
robinmc | 3:4b254b4bd6d4 | 110 | //Funtion that uses a ticker to create a ticker based wait() funtion, less power consumtion then normal wait() funtion |
robinmc | 3:4b254b4bd6d4 | 111 | //Input t in 0.1*number of seconds to wait |
robinmc | 2:158d57cdbf1e | 112 | void ticker_wait(int t) |
robinmc | 2:158d57cdbf1e | 113 | { |
robinmc | 3:4b254b4bd6d4 | 114 | for (int q=0; q<=t; q++) { //for loop stops when q<=t |
robinmc | 3:4b254b4bd6d4 | 115 | if (g_Ticker_ds_flag) { //ticker_ds_flag flags every 0.1seconds |
robinmc | 2:158d57cdbf1e | 116 | g_Ticker_ds_flag=0; |
robinmc | 3:4b254b4bd6d4 | 117 | q++; //q increases every loop until q=t |
robinmc | 2:158d57cdbf1e | 118 | } |
robinmc | 3:4b254b4bd6d4 | 119 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 120 | } |
robinmc | 2:158d57cdbf1e | 121 | } |
robinmc | 3:4b254b4bd6d4 | 122 | |
robinmc | 3:4b254b4bd6d4 | 123 | //Funtion that reads the story_progress variable form the SD card |
robinmc | 2:158d57cdbf1e | 124 | void readSD_progress() |
robinmc | 2:158d57cdbf1e | 125 | { |
robinmc | 3:4b254b4bd6d4 | 126 | Progress=fopen("/sd/Progress.txt", "r"); //Opens the file Progress.txt (read only) |
robinmc | 3:4b254b4bd6d4 | 127 | if (Progress!=NULL) { //If file exists |
robinmc | 3:4b254b4bd6d4 | 128 | green_led=0; //Turn green led on mbed on |
robinmc | 3:4b254b4bd6d4 | 129 | fscanf(Progress,"%d, ",&story_progress); //Retrive the story_progress variable |
robinmc | 3:4b254b4bd6d4 | 130 | fclose(Progress); //Close the file Progress.txt |
robinmc | 3:4b254b4bd6d4 | 131 | ticker_wait(5); //wait 0.5s |
robinmc | 3:4b254b4bd6d4 | 132 | green_led=1; //Turn green led on mbed off |
robinmc | 3:4b254b4bd6d4 | 133 | } else { //If flie doesn't exist |
robinmc | 3:4b254b4bd6d4 | 134 | red_led=0; //Turn red led on mebed on |
robinmc | 3:4b254b4bd6d4 | 135 | ticker_wait(5); //wait 0.5s |
robinmc | 3:4b254b4bd6d4 | 136 | red_led=1; //Turn red led on mebed off |
robinmc | 2:158d57cdbf1e | 137 | } |
robinmc | 2:158d57cdbf1e | 138 | } |
robinmc | 3:4b254b4bd6d4 | 139 | |
robinmc | 3:4b254b4bd6d4 | 140 | //Funtion that reads the story_progress variable on the SD card |
robinmc | 2:158d57cdbf1e | 141 | void writeSD_progress() |
robinmc | 2:158d57cdbf1e | 142 | { |
robinmc | 3:4b254b4bd6d4 | 143 | Progress=fopen("/sd/Progress.txt", "w"); //Opens the file Progress.txt (write) |
robinmc | 3:4b254b4bd6d4 | 144 | if (Progress!=NULL) { //If file exists |
robinmc | 3:4b254b4bd6d4 | 145 | green_led=0; //Turn green led on mbed on |
robinmc | 3:4b254b4bd6d4 | 146 | fprintf(Progress,"%d, ",story_progress); //Write the story_progress variable to the file |
robinmc | 3:4b254b4bd6d4 | 147 | fclose(Progress); //Close the file Progress.txt |
robinmc | 3:4b254b4bd6d4 | 148 | ticker_wait(5); //wait 0.5s |
robinmc | 3:4b254b4bd6d4 | 149 | green_led=1; //Turn red led on mebed off |
robinmc | 3:4b254b4bd6d4 | 150 | } else { //If the file doesn't exist |
robinmc | 3:4b254b4bd6d4 | 151 | red_led=0; //Turn red led on mebed on |
robinmc | 3:4b254b4bd6d4 | 152 | ticker_wait(5); //wait 0.5s |
robinmc | 3:4b254b4bd6d4 | 153 | red_led=1; //Turn red led on mebed off |
robinmc | 2:158d57cdbf1e | 154 | } |
robinmc | 2:158d57cdbf1e | 155 | } |
robinmc | 3:4b254b4bd6d4 | 156 | |
robinmc | 3:4b254b4bd6d4 | 157 | //Funtion that reads and prints the g_top_score[6] array on the SD card and prints the higest 5 values |
robinmc | 3:4b254b4bd6d4 | 158 | //on the LCD |
robinmc | 2:158d57cdbf1e | 159 | void readSD_and_print_top_score() |
robinmc | 2:158d57cdbf1e | 160 | { |
robinmc | 3:4b254b4bd6d4 | 161 | Highscores=fopen("/sd/Highscores.txt", "r"); //Opens the file Highscores.txt (read only) from SD card |
robinmc | 3:4b254b4bd6d4 | 162 | if (Highscores!=NULL) { //If file exists |
robinmc | 3:4b254b4bd6d4 | 163 | green_led=0; //Turn green led on mbed on |
robinmc | 3:4b254b4bd6d4 | 164 | ticker_wait(3); //wait 0.3s |
robinmc | 3:4b254b4bd6d4 | 165 | green_led=1; //Turn green led on mbed oFF |
robinmc | 3:4b254b4bd6d4 | 166 | for (int j=0; j<=5; j++) { //Go through all the values of the array and reads them |
robinmc | 2:158d57cdbf1e | 167 | fscanf(Highscores,"%d, ",&g_top_scores[j]); |
robinmc | 2:158d57cdbf1e | 168 | } |
robinmc | 3:4b254b4bd6d4 | 169 | lcd.printString("Highscores:",0,0); //Prints Highscores |
robinmc | 3:4b254b4bd6d4 | 170 | for (int j=1; j<=5; j++) { //Goes through the top 5 values |
robinmc | 3:4b254b4bd6d4 | 171 | char buffer[14]; //Declares buffer to store the values of the g_top_score array |
robinmc | 3:4b254b4bd6d4 | 172 | int temp = sprintf(buffer,"%d",g_top_scores[j]); //Stores them in the buffer |
robinmc | 3:4b254b4bd6d4 | 173 | lcd.printString(buffer,12,j); //Prints the values on the LCD screen in order |
robinmc | 2:158d57cdbf1e | 174 | } |
robinmc | 3:4b254b4bd6d4 | 175 | fclose(Highscores); //Close Highscores file |
robinmc | 3:4b254b4bd6d4 | 176 | } else { //If the file doesn't exist |
robinmc | 3:4b254b4bd6d4 | 177 | red_led=0; //Turn the red led on mbed off |
robinmc | 3:4b254b4bd6d4 | 178 | ticker_wait(3); //wait 0.3s |
robinmc | 3:4b254b4bd6d4 | 179 | red_led=1; //Turn the red led on mebed off |
robinmc | 3:4b254b4bd6d4 | 180 | lcd.printString("NO HIGHSCORES",3,2); //Print error message on LCD |
robinmc | 2:158d57cdbf1e | 181 | lcd.printString("SET YET!!",18,3); |
robinmc | 2:158d57cdbf1e | 182 | } |
robinmc | 2:158d57cdbf1e | 183 | } |
robinmc | 2:158d57cdbf1e | 184 | |
robinmc | 3:4b254b4bd6d4 | 185 | |
robinmc | 3:4b254b4bd6d4 | 186 | //Funtion that writes the highscore[6] array on the SD |
robinmc | 2:158d57cdbf1e | 187 | void writeSD() |
robinmc | 2:158d57cdbf1e | 188 | { |
robinmc | 3:4b254b4bd6d4 | 189 | Highscores=fopen("/sd/Highscores.txt", "w"); //Opens the file Highscores.txt (write only) from SD card |
robinmc | 3:4b254b4bd6d4 | 190 | if (Highscores!=NULL) { //If file exists |
robinmc | 3:4b254b4bd6d4 | 191 | green_led=0; //Turn green led on mbed on |
robinmc | 3:4b254b4bd6d4 | 192 | ticker_wait(3); //wait 0.3s |
robinmc | 3:4b254b4bd6d4 | 193 | green_led=1; //Turn green led on mbed off |
robinmc | 3:4b254b4bd6d4 | 194 | for (int j=0; j<=5; j++) { //Goes through the all values |
robinmc | 3:4b254b4bd6d4 | 195 | fprintf(Highscores,"%d, ",g_top_scores[j]); //Retrive the g_top_score array |
robinmc | 2:158d57cdbf1e | 196 | } |
robinmc | 3:4b254b4bd6d4 | 197 | fclose(Highscores); //Close file |
robinmc | 3:4b254b4bd6d4 | 198 | } else { //If file doesn't exists |
robinmc | 3:4b254b4bd6d4 | 199 | red_led=0; //Turns red led on |
robinmc | 3:4b254b4bd6d4 | 200 | ticker_wait(3); //Waits 0.3s |
robinmc | 3:4b254b4bd6d4 | 201 | red_led=1; //Turns red led off |
robinmc | 2:158d57cdbf1e | 202 | } |
robinmc | 2:158d57cdbf1e | 203 | } |
robinmc | 2:158d57cdbf1e | 204 | |
robinmc | 3:4b254b4bd6d4 | 205 | //Funtion that deletes a file |
robinmc | 2:158d57cdbf1e | 206 | void delete_file(char filename[]) |
robinmc | 2:158d57cdbf1e | 207 | { |
robinmc | 3:4b254b4bd6d4 | 208 | lcd.printString("Deleting file",0,1); //print deleting file |
robinmc | 3:4b254b4bd6d4 | 209 | ticker_wait(5); //wait 05s |
robinmc | 2:158d57cdbf1e | 210 | FILE *fp = fopen(filename, "r"); // try and open file |
robinmc | 2:158d57cdbf1e | 211 | if (fp != NULL) { // if it does open... |
robinmc | 2:158d57cdbf1e | 212 | fclose(fp); // close it |
robinmc | 2:158d57cdbf1e | 213 | remove(filename); // and then delete |
robinmc | 2:158d57cdbf1e | 214 | lcd.printString("Done!",0,5); |
robinmc | 2:158d57cdbf1e | 215 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 216 | } |
robinmc | 2:158d57cdbf1e | 217 | // if we can't open it, it doesn't exist and so we can't delete it |
robinmc | 2:158d57cdbf1e | 218 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 219 | } |
robinmc | 2:158d57cdbf1e | 220 | |
robinmc | 2:158d57cdbf1e | 221 | void Delete_Highscores() |
robinmc | 2:158d57cdbf1e | 222 | { |
robinmc | 3:4b254b4bd6d4 | 223 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 224 | while (1) { |
robinmc | 3:4b254b4bd6d4 | 225 | if (g_Ticker_Menu_flag) { //ticker flags every 0.15s |
robinmc | 2:158d57cdbf1e | 226 | g_Ticker_Menu_flag=0; |
robinmc | 2:158d57cdbf1e | 227 | lcd.printString("Delete all",0,2); |
robinmc | 2:158d57cdbf1e | 228 | lcd.printString("high scores?",0,3); |
robinmc | 3:4b254b4bd6d4 | 229 | if (b_A==1) { //if dlete highscores is selected |
robinmc | 3:4b254b4bd6d4 | 230 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 231 | while (1) { |
robinmc | 2:158d57cdbf1e | 232 | if (g_Ticker_Menu_flag) { |
robinmc | 2:158d57cdbf1e | 233 | g_Ticker_Menu_flag=0; |
robinmc | 3:4b254b4bd6d4 | 234 | lcd.printString("Are you sure?",0,1); //Print are you sure message |
robinmc | 3:4b254b4bd6d4 | 235 | if (b_A==1) { //Are you sure is selected |
robinmc | 3:4b254b4bd6d4 | 236 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 3:4b254b4bd6d4 | 237 | delete_file("/sd/Highscores.txt"); //deletes the file |
robinmc | 2:158d57cdbf1e | 238 | return; |
robinmc | 3:4b254b4bd6d4 | 239 | } else if (b_B==1) { //If it's not, returns to the main menu |
robinmc | 2:158d57cdbf1e | 240 | return; |
robinmc | 2:158d57cdbf1e | 241 | } |
robinmc | 2:158d57cdbf1e | 242 | } |
robinmc | 2:158d57cdbf1e | 243 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 244 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 245 | } |
robinmc | 3:4b254b4bd6d4 | 246 | } else if (b_B==1) { //If it's not, returns to the main menu |
robinmc | 2:158d57cdbf1e | 247 | return; |
robinmc | 2:158d57cdbf1e | 248 | } |
robinmc | 2:158d57cdbf1e | 249 | } |
robinmc | 2:158d57cdbf1e | 250 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 251 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 252 | } |
robinmc | 2:158d57cdbf1e | 253 | } |
robinmc | 2:158d57cdbf1e | 254 | |
robinmc | 3:4b254b4bd6d4 | 255 | //Sorts all the top scores in descending order |
robinmc | 2:158d57cdbf1e | 256 | void sort_top_scores() |
robinmc | 2:158d57cdbf1e | 257 | { |
robinmc | 3:4b254b4bd6d4 | 258 | g_top_scores[5]=score; //The 5 element is equal to the score |
robinmc | 2:158d57cdbf1e | 259 | int temp; |
robinmc | 3:4b254b4bd6d4 | 260 | for (int j=0; j<=5; j++) { //for each array element |
robinmc | 3:4b254b4bd6d4 | 261 | for (int n=1; n<=5; n++) { //for each array element+1 (except for when the array element=5 as there is no further one) |
robinmc | 3:4b254b4bd6d4 | 262 | if (g_top_scores[j]>g_top_scores[n]) { //if array element is greater then the next element |
robinmc | 3:4b254b4bd6d4 | 263 | temp = g_top_scores[j]; //store the element |
robinmc | 3:4b254b4bd6d4 | 264 | g_top_scores[j] = g_top_scores[n]; //make the element equal to the next element |
robinmc | 3:4b254b4bd6d4 | 265 | g_top_scores[n] = temp; //stores element equals the nest elememnt |
robinmc | 2:158d57cdbf1e | 266 | } |
robinmc | 2:158d57cdbf1e | 267 | } |
robinmc | 2:158d57cdbf1e | 268 | } |
robinmc | 2:158d57cdbf1e | 269 | } |
robinmc | 3:4b254b4bd6d4 | 270 | |
robinmc | 3:4b254b4bd6d4 | 271 | |
robinmc | 3:4b254b4bd6d4 | 272 | //Funtion that plays the song1 |
robinmc | 2:158d57cdbf1e | 273 | void play_music() |
robinmc | 2:158d57cdbf1e | 274 | { |
robinmc | 3:4b254b4bd6d4 | 275 | tOut.attach(&music_tOut, (song1[0]/2)); //the note will play for the the ammount of time specified in the first |
robinmc | 3:4b254b4bd6d4 | 276 | //element of the song1 |
robinmc | 3:4b254b4bd6d4 | 277 | PWM.period (1.0/1000); //sets the frequancy to 1kHz |
robinmc | 3:4b254b4bd6d4 | 278 | PWM.write(0.0); //Changes the time that the buzzer is on to 0 |
robinmc | 3:4b254b4bd6d4 | 279 | if (song1[g_music_count]!=0) { //Checks if there is a note to be played at a ceratain position in the song1 array |
robinmc | 3:4b254b4bd6d4 | 280 | PWM.period(1/(song1[g_music_count])); //Sets the period to the corret frequency from the song array |
robinmc | 3:4b254b4bd6d4 | 281 | PWM.write(0.5); //Changes PWM to square wave |
robinmc | 2:158d57cdbf1e | 282 | } |
robinmc | 3:4b254b4bd6d4 | 283 | if (g_music_count<(sizeof(song1)/sizeof(song1[1]))) { //If the current count of the music is less then the array size |
robinmc | 3:4b254b4bd6d4 | 284 | g_music_count++; //increases the music line by one |
robinmc | 2:158d57cdbf1e | 285 | } else { |
robinmc | 3:4b254b4bd6d4 | 286 | g_music_count=1; //otherwise it sets it back to one |
robinmc | 2:158d57cdbf1e | 287 | } |
robinmc | 2:158d57cdbf1e | 288 | } |
robinmc | 2:158d57cdbf1e | 289 | |
robinmc | 3:4b254b4bd6d4 | 290 | |
robinmc | 3:4b254b4bd6d4 | 291 | //Generates a random number between 0 and 9999 |
robinmc | 0:28392431dbad | 292 | void generate_random_number() |
robinmc | 0:28392431dbad | 293 | { |
robinmc | 3:4b254b4bd6d4 | 294 | time_t seconds = time(NULL); //Get time in seconds from mbed |
robinmc | 3:4b254b4bd6d4 | 295 | srand(seconds); //Use time as soucre for srand() funtion |
robinmc | 3:4b254b4bd6d4 | 296 | random_num=rand()%10000; //create random number between 1 and 9999 |
robinmc | 0:28392431dbad | 297 | } |
robinmc | 3:4b254b4bd6d4 | 298 | |
robinmc | 3:4b254b4bd6d4 | 299 | //Converts the socre value so it can be dysplayed as a bar |
robinmc | 3:4b254b4bd6d4 | 300 | void led_bar() |
robinmc | 0:28392431dbad | 301 | { |
robinmc | 3:4b254b4bd6d4 | 302 | led=pow(2,lives)-1; //lives^2 -1 will turn all the led on thats the value of lives |
robinmc | 3:4b254b4bd6d4 | 303 | if (lives>5) { //the value of lives cannot exceed 5 |
robinmc | 0:28392431dbad | 304 | lives=5; |
robinmc | 0:28392431dbad | 305 | } |
robinmc | 0:28392431dbad | 306 | } |
robinmc | 0:28392431dbad | 307 | |
robinmc | 0:28392431dbad | 308 | |
robinmc | 0:28392431dbad | 309 | void ground() //funtion to print the ground |
robinmc | 0:28392431dbad | 310 | { |
robinmc | 0:28392431dbad | 311 | for (int x = 0; x<=84 ; x++) { |
robinmc | 3:4b254b4bd6d4 | 312 | lcd.setPixel(x,47); //prints a line 84 pixels long at the bottom of the screen |
robinmc | 0:28392431dbad | 313 | } |
robinmc | 0:28392431dbad | 314 | } |
robinmc | 0:28392431dbad | 315 | |
robinmc | 3:4b254b4bd6d4 | 316 | /* |
robinmc | 3:4b254b4bd6d4 | 317 | ==========================EXAMPLE OF PRINTING FUNTION=========================== |
robinmc | 3:4b254b4bd6d4 | 318 | |
robinmc | 3:4b254b4bd6d4 | 319 | THIS EXAMPLE CODE APPLIES FOR ALL THE "print_" FUNTIONS |
robinmc | 3:4b254b4bd6d4 | 320 | |
robinmc | 3:4b254b4bd6d4 | 321 | //Prints the item on the LCD screen |
robinmc | 3:4b254b4bd6d4 | 322 | void print_item() |
robinmc | 3:4b254b4bd6d4 | 323 | { |
robinmc | 3:4b254b4bd6d4 | 324 | //Goes through all the columns in the g_item array |
robinmc | 3:4b254b4bd6d4 | 325 | for (int c=0; c<=(1-g_item number of columns in array); c++) { |
robinmc | 3:4b254b4bd6d4 | 326 | //Goes through all the rows in the g_item array |
robinmc | 3:4b254b4bd6d4 | 327 | for (int r=0; r<=(1-g_item number of rows in array);r++) { |
robinmc | 3:4b254b4bd6d4 | 328 | //if the element of the g_item array corresponding to row r and column c is o |
robinmc | 3:4b254b4bd6d4 | 329 | if (g_item[r][c]==0) { |
robinmc | 3:4b254b4bd6d4 | 330 | // then the pixel is checked, this is to allow arrays to overlap. If the checked pixel = 1 |
robinmc | 3:4b254b4bd6d4 | 331 | //then the pixel is set rather then cleared, however if it's 0 then it is cleared |
robinmc | 3:4b254b4bd6d4 | 332 | //the location on the LCD that the item is printed is dependant on the 2 global variables |
robinmc | 3:4b254b4bd6d4 | 333 | //item_hMovement (contolles the horizontal possition) and item_vMovement (contolles the |
robinmc | 3:4b254b4bd6d4 | 334 | //vertical movemrnt). If either of those values are constants it means that the |
robinmc | 3:4b254b4bd6d4 | 335 | //vertical/horizontal displacement of the object is constant |
robinmc | 3:4b254b4bd6d4 | 336 | if (lcd.getPixel(c+item_hMovement,r+item_vMovement)!=0) { |
robinmc | 3:4b254b4bd6d4 | 337 | lcd.setPixel(c+item_hMovement,r+item_vMovement); |
robinmc | 3:4b254b4bd6d4 | 338 | } else { |
robinmc | 3:4b254b4bd6d4 | 339 | lcd.clearPixel(c+item_hMovement,r+item_vMovement); |
robinmc | 3:4b254b4bd6d4 | 340 | } |
robinmc | 3:4b254b4bd6d4 | 341 | //else if the array element g_item[r][c] is 1 then the pixel is set no matter what |
robinmc | 3:4b254b4bd6d4 | 342 | } else if (g_item[r][c]==1) { |
robinmc | 3:4b254b4bd6d4 | 343 | lcd.setPixel(c+item_hMovement,r+item_vMovement); |
robinmc | 3:4b254b4bd6d4 | 344 | } |
robinmc | 3:4b254b4bd6d4 | 345 | } |
robinmc | 3:4b254b4bd6d4 | 346 | } |
robinmc | 3:4b254b4bd6d4 | 347 | } |
robinmc | 3:4b254b4bd6d4 | 348 | ================================================================================ |
robinmc | 3:4b254b4bd6d4 | 349 | */ |
robinmc | 3:4b254b4bd6d4 | 350 | |
robinmc | 3:4b254b4bd6d4 | 351 | //Funtion that prints the heart pickup |
robinmc | 0:28392431dbad | 352 | void print_heart() |
robinmc | 0:28392431dbad | 353 | { |
robinmc | 0:28392431dbad | 354 | for(int c=0; c<=4; c++) { //4 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 355 | for(int r=0; r<=4; r++) { |
robinmc | 0:28392431dbad | 356 | if (g_heart[r][c]==0) { |
robinmc | 0:28392431dbad | 357 | if (lcd.getPixel(c+heart_movement,r+35)!=0) { |
robinmc | 0:28392431dbad | 358 | lcd.setPixel(c+heart_movement,r+35); |
robinmc | 0:28392431dbad | 359 | } else { |
robinmc | 0:28392431dbad | 360 | lcd.clearPixel(c+heart_movement,r+35); |
robinmc | 0:28392431dbad | 361 | } |
robinmc | 0:28392431dbad | 362 | } else if (g_heart[r][c]==1) { |
robinmc | 0:28392431dbad | 363 | lcd.setPixel(c+heart_movement,r+35); |
robinmc | 0:28392431dbad | 364 | } |
robinmc | 0:28392431dbad | 365 | } |
robinmc | 0:28392431dbad | 366 | } |
robinmc | 0:28392431dbad | 367 | } |
robinmc | 0:28392431dbad | 368 | |
robinmc | 3:4b254b4bd6d4 | 369 | //Funtion that prints the ammo pickup |
robinmc | 0:28392431dbad | 370 | void print_ammo_pickUp() |
robinmc | 0:28392431dbad | 371 | { |
robinmc | 0:28392431dbad | 372 | for(int c=0; c<=6; c++) { //6 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 373 | for(int r=0; r<=7; r++) { |
robinmc | 0:28392431dbad | 374 | if (g_ammo_pickUp[r][c]==0) { |
robinmc | 0:28392431dbad | 375 | if (lcd.getPixel(c+ammo_movement,r+35)!=0) { |
robinmc | 0:28392431dbad | 376 | lcd.setPixel(c+ammo_movement,r+35); |
robinmc | 0:28392431dbad | 377 | } else { |
robinmc | 0:28392431dbad | 378 | lcd.clearPixel(c+ammo_movement,r+35); |
robinmc | 0:28392431dbad | 379 | } |
robinmc | 0:28392431dbad | 380 | } else if (g_ammo_pickUp[r][c]==1) { |
robinmc | 0:28392431dbad | 381 | lcd.setPixel(c+ammo_movement,r+35); |
robinmc | 0:28392431dbad | 382 | } |
robinmc | 0:28392431dbad | 383 | } |
robinmc | 0:28392431dbad | 384 | } |
robinmc | 0:28392431dbad | 385 | } |
robinmc | 0:28392431dbad | 386 | |
robinmc | 3:4b254b4bd6d4 | 387 | //Funtion that prints the speed boost pickup |
robinmc | 2:158d57cdbf1e | 388 | void print_speed_boost() |
robinmc | 2:158d57cdbf1e | 389 | { |
robinmc | 2:158d57cdbf1e | 390 | for (int c=0; c<=13; c++) { |
robinmc | 2:158d57cdbf1e | 391 | for (int r=0; r<=6; r++) { |
robinmc | 2:158d57cdbf1e | 392 | if (g_speed_boost[r][c]==0) { |
robinmc | 2:158d57cdbf1e | 393 | if (lcd.getPixel(c+speed_boost_movement,r+38)!=0) { |
robinmc | 2:158d57cdbf1e | 394 | lcd.setPixel(c+speed_boost_movement,r+38); |
robinmc | 2:158d57cdbf1e | 395 | } else { |
robinmc | 2:158d57cdbf1e | 396 | lcd.clearPixel(c+speed_boost_movement,r+38); |
robinmc | 2:158d57cdbf1e | 397 | } |
robinmc | 2:158d57cdbf1e | 398 | } else if (g_speed_boost[r][c]==1) { |
robinmc | 2:158d57cdbf1e | 399 | lcd.setPixel(c+speed_boost_movement,r+38); |
robinmc | 2:158d57cdbf1e | 400 | } |
robinmc | 2:158d57cdbf1e | 401 | } |
robinmc | 2:158d57cdbf1e | 402 | } |
robinmc | 2:158d57cdbf1e | 403 | } |
robinmc | 3:4b254b4bd6d4 | 404 | //Funtion that prints recks still |
robinmc | 0:28392431dbad | 405 | void print_recks_still_gun() |
robinmc | 0:28392431dbad | 406 | { |
robinmc | 0:28392431dbad | 407 | |
robinmc | 0:28392431dbad | 408 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 409 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 410 | if (g_recks_still_gun[r][c]==0) { |
robinmc | 0:28392431dbad | 411 | if (lcd.getPixel(c+3,r+37)!=0) { |
robinmc | 0:28392431dbad | 412 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 413 | } else { |
robinmc | 0:28392431dbad | 414 | lcd.clearPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 415 | } |
robinmc | 0:28392431dbad | 416 | } else if (g_recks_still_gun[r][c]==1) { |
robinmc | 0:28392431dbad | 417 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 418 | } |
robinmc | 0:28392431dbad | 419 | } |
robinmc | 0:28392431dbad | 420 | } |
robinmc | 0:28392431dbad | 421 | } |
robinmc | 0:28392431dbad | 422 | |
robinmc | 3:4b254b4bd6d4 | 423 | //Funtion that prints recks moveing |
robinmc | 0:28392431dbad | 424 | void print_recks_moving_gun() |
robinmc | 0:28392431dbad | 425 | { |
robinmc | 0:28392431dbad | 426 | |
robinmc | 0:28392431dbad | 427 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 428 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 429 | if (g_recks_moving_gun[r][c]==0) { |
robinmc | 0:28392431dbad | 430 | if (lcd.getPixel(c+3,r+37)!=0) { |
robinmc | 0:28392431dbad | 431 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 432 | } else { |
robinmc | 0:28392431dbad | 433 | lcd.clearPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 434 | } |
robinmc | 0:28392431dbad | 435 | } else if (g_recks_moving_gun[r][c]==1) { |
robinmc | 0:28392431dbad | 436 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 437 | } |
robinmc | 0:28392431dbad | 438 | } |
robinmc | 0:28392431dbad | 439 | } |
robinmc | 0:28392431dbad | 440 | } |
robinmc | 0:28392431dbad | 441 | |
robinmc | 3:4b254b4bd6d4 | 442 | //Funtion that prints recks crouching |
robinmc | 0:28392431dbad | 443 | void print_recks_crouch_gun() |
robinmc | 0:28392431dbad | 444 | { |
robinmc | 0:28392431dbad | 445 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 446 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 447 | if (g_recks_crouch_gun[r][c]==0) { |
robinmc | 0:28392431dbad | 448 | if (lcd.getPixel(c+3,r+37)!=0) { |
robinmc | 0:28392431dbad | 449 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 450 | } else { |
robinmc | 0:28392431dbad | 451 | lcd.clearPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 452 | } |
robinmc | 0:28392431dbad | 453 | } else if (g_recks_crouch_gun[r][c]==1) { |
robinmc | 0:28392431dbad | 454 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 455 | } |
robinmc | 0:28392431dbad | 456 | } |
robinmc | 0:28392431dbad | 457 | } |
robinmc | 0:28392431dbad | 458 | } |
robinmc | 0:28392431dbad | 459 | |
robinmc | 3:4b254b4bd6d4 | 460 | //Funtion that prints recks with the shield |
robinmc | 2:158d57cdbf1e | 461 | void print_recks_shield() |
robinmc | 2:158d57cdbf1e | 462 | { |
robinmc | 2:158d57cdbf1e | 463 | for(int c=0; c<=14; c++) { |
robinmc | 2:158d57cdbf1e | 464 | for(int r=0; r<=14; r++) { |
robinmc | 2:158d57cdbf1e | 465 | if (g_recks_shield[r][c]==0) { |
robinmc | 2:158d57cdbf1e | 466 | if (lcd.getPixel(c,r+33)!=0) { |
robinmc | 2:158d57cdbf1e | 467 | lcd.setPixel(c,r+33); |
robinmc | 2:158d57cdbf1e | 468 | } else { |
robinmc | 2:158d57cdbf1e | 469 | lcd.clearPixel(c,r+33); |
robinmc | 2:158d57cdbf1e | 470 | } |
robinmc | 2:158d57cdbf1e | 471 | } else if (g_recks_shield[r][c]==1) { |
robinmc | 2:158d57cdbf1e | 472 | lcd.setPixel(c,r+33); |
robinmc | 2:158d57cdbf1e | 473 | } |
robinmc | 2:158d57cdbf1e | 474 | } |
robinmc | 2:158d57cdbf1e | 475 | } |
robinmc | 2:158d57cdbf1e | 476 | } |
robinmc | 2:158d57cdbf1e | 477 | |
robinmc | 3:4b254b4bd6d4 | 478 | //Funtion that prints recks in the jumping position |
robinmc | 0:28392431dbad | 479 | void print_recks_jump_gun() |
robinmc | 0:28392431dbad | 480 | { |
robinmc | 0:28392431dbad | 481 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 482 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 483 | if (g_recks_jump_gun[r][c]==0) { |
robinmc | 0:28392431dbad | 484 | if (lcd.getPixel(c+3,r+g_jump)!=0) { |
robinmc | 0:28392431dbad | 485 | lcd.setPixel(c+3,r+g_jump); |
robinmc | 0:28392431dbad | 486 | } else { |
robinmc | 0:28392431dbad | 487 | lcd.clearPixel(c+3,r+g_jump); |
robinmc | 0:28392431dbad | 488 | } |
robinmc | 0:28392431dbad | 489 | } else if (g_recks_jump_gun[r][c]==1) { |
robinmc | 0:28392431dbad | 490 | lcd.setPixel(c+3,r+g_jump); |
robinmc | 0:28392431dbad | 491 | } |
robinmc | 0:28392431dbad | 492 | } |
robinmc | 0:28392431dbad | 493 | } |
robinmc | 0:28392431dbad | 494 | } |
robinmc | 0:28392431dbad | 495 | |
robinmc | 3:4b254b4bd6d4 | 496 | //Funtion that recks falling (different to recks still because vertical movement is variable) |
robinmc | 2:158d57cdbf1e | 497 | void print_recks_falling() |
robinmc | 2:158d57cdbf1e | 498 | { |
robinmc | 2:158d57cdbf1e | 499 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 2:158d57cdbf1e | 500 | for(int r=0; r<=9; r++) { |
robinmc | 2:158d57cdbf1e | 501 | if (g_recks_still_gun[r][c]==0) { |
robinmc | 2:158d57cdbf1e | 502 | if (lcd.getPixel(c+3,r+fall)!=0) { |
robinmc | 2:158d57cdbf1e | 503 | lcd.setPixel(c+3,r+fall); |
robinmc | 2:158d57cdbf1e | 504 | } else { |
robinmc | 2:158d57cdbf1e | 505 | lcd.clearPixel(c+3,r+fall); |
robinmc | 2:158d57cdbf1e | 506 | } |
robinmc | 2:158d57cdbf1e | 507 | } else if (g_recks_still_gun[r][c]==1) { |
robinmc | 2:158d57cdbf1e | 508 | lcd.setPixel(c+3,r+fall); |
robinmc | 2:158d57cdbf1e | 509 | } |
robinmc | 2:158d57cdbf1e | 510 | } |
robinmc | 2:158d57cdbf1e | 511 | } |
robinmc | 2:158d57cdbf1e | 512 | } |
robinmc | 2:158d57cdbf1e | 513 | |
robinmc | 3:4b254b4bd6d4 | 514 | //Funtion that prints the rat in position 1 |
robinmc | 3:4b254b4bd6d4 | 515 | void print_mob_rat_p1() |
robinmc | 1:046e66f1ca76 | 516 | { |
robinmc | 1:046e66f1ca76 | 517 | for(int c=0; c<=7; c++) { // 7 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 518 | for(int r=0; r<=2; r++) { |
robinmc | 1:046e66f1ca76 | 519 | if (g_mob_rat_p1[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 520 | if (lcd.getPixel(c+rat_movement,r+44)!=0) { |
robinmc | 1:046e66f1ca76 | 521 | lcd.setPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 522 | } else { |
robinmc | 1:046e66f1ca76 | 523 | lcd.clearPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 524 | } |
robinmc | 1:046e66f1ca76 | 525 | } else if (g_mob_rat_p1[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 526 | lcd.setPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 527 | } |
robinmc | 1:046e66f1ca76 | 528 | } |
robinmc | 1:046e66f1ca76 | 529 | } |
robinmc | 1:046e66f1ca76 | 530 | } |
robinmc | 1:046e66f1ca76 | 531 | |
robinmc | 3:4b254b4bd6d4 | 532 | //Funtion that prints the rat in position 2 |
robinmc | 3:4b254b4bd6d4 | 533 | void print_mob_rat_p2() |
robinmc | 1:046e66f1ca76 | 534 | { |
robinmc | 1:046e66f1ca76 | 535 | for(int c=0; c<=7; c++) { // 7 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 536 | for(int r=0; r<=2; r++) { |
robinmc | 1:046e66f1ca76 | 537 | if (g_mob_rat_p2[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 538 | if (lcd.getPixel(c+rat_movement,r+44)!=0) { |
robinmc | 1:046e66f1ca76 | 539 | lcd.setPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 540 | } else { |
robinmc | 1:046e66f1ca76 | 541 | lcd.clearPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 542 | } |
robinmc | 1:046e66f1ca76 | 543 | } else if (g_mob_rat_p2[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 544 | lcd.setPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 545 | } |
robinmc | 1:046e66f1ca76 | 546 | } |
robinmc | 1:046e66f1ca76 | 547 | } |
robinmc | 1:046e66f1ca76 | 548 | } |
robinmc | 1:046e66f1ca76 | 549 | |
robinmc | 3:4b254b4bd6d4 | 550 | //Funtion that prints the still hound |
robinmc | 3:4b254b4bd6d4 | 551 | void print_mob_hound_p1() |
robinmc | 1:046e66f1ca76 | 552 | { |
robinmc | 1:046e66f1ca76 | 553 | for(int c=0; c<=12; c++) { // 12 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 554 | for(int r=0; r<=7; r++) { |
robinmc | 1:046e66f1ca76 | 555 | if (g_mob_hound_p1[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 556 | if (lcd.getPixel(c+hound_hMovement,r+hound_vMovement)!=0) { |
robinmc | 1:046e66f1ca76 | 557 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 558 | } else { |
robinmc | 1:046e66f1ca76 | 559 | lcd.clearPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 560 | } |
robinmc | 1:046e66f1ca76 | 561 | } else if (g_mob_hound_p1[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 562 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 563 | } |
robinmc | 1:046e66f1ca76 | 564 | } |
robinmc | 1:046e66f1ca76 | 565 | } |
robinmc | 1:046e66f1ca76 | 566 | } |
robinmc | 1:046e66f1ca76 | 567 | |
robinmc | 3:4b254b4bd6d4 | 568 | //Funtion that prints the moving hound |
robinmc | 3:4b254b4bd6d4 | 569 | void print_mob_hound_p2() |
robinmc | 1:046e66f1ca76 | 570 | { |
robinmc | 1:046e66f1ca76 | 571 | for(int c=0; c<=12; c++) { // 12 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 572 | for(int r=0; r<=7; r++) { |
robinmc | 1:046e66f1ca76 | 573 | if (g_mob_hound_p2[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 574 | if (lcd.getPixel(c+hound_hMovement,r+hound_vMovement)!=0) { |
robinmc | 1:046e66f1ca76 | 575 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 576 | } else { |
robinmc | 1:046e66f1ca76 | 577 | lcd.clearPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 578 | } |
robinmc | 1:046e66f1ca76 | 579 | } else if (g_mob_hound_p2[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 580 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 581 | } |
robinmc | 1:046e66f1ca76 | 582 | } |
robinmc | 1:046e66f1ca76 | 583 | } |
robinmc | 1:046e66f1ca76 | 584 | } |
robinmc | 1:046e66f1ca76 | 585 | |
robinmc | 3:4b254b4bd6d4 | 586 | //Funtion that prints the dead hound |
robinmc | 3:4b254b4bd6d4 | 587 | void print_mob_hound_dead() |
robinmc | 1:046e66f1ca76 | 588 | { |
robinmc | 1:046e66f1ca76 | 589 | for(int c=0; c<=12; c++) { // 12 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 590 | for(int r=0; r<=7; r++) { |
robinmc | 1:046e66f1ca76 | 591 | if (g_mob_hound_dead[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 592 | if (lcd.getPixel(c+hound_hMovement,r+hound_vMovement)!=0) { |
robinmc | 1:046e66f1ca76 | 593 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 594 | } else { |
robinmc | 1:046e66f1ca76 | 595 | lcd.clearPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 596 | } |
robinmc | 1:046e66f1ca76 | 597 | } else if (g_mob_hound_dead[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 598 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 599 | } |
robinmc | 1:046e66f1ca76 | 600 | } |
robinmc | 1:046e66f1ca76 | 601 | } |
robinmc | 1:046e66f1ca76 | 602 | } |
robinmc | 1:046e66f1ca76 | 603 | |
robinmc | 3:4b254b4bd6d4 | 604 | //Funtion to print the still bear (position 1) on the LCD |
robinmc | 3:4b254b4bd6d4 | 605 | void print_mob_bear_p1() |
robinmc | 0:28392431dbad | 606 | { |
robinmc | 0:28392431dbad | 607 | for(int c=0; c<=18; c++) { //18 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 608 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 609 | if (g_mob_bear_p1[r][c]==0) { |
robinmc | 0:28392431dbad | 610 | if (lcd.getPixel(c+bear_movement,r+37)!=0) { |
robinmc | 0:28392431dbad | 611 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 612 | } else { |
robinmc | 0:28392431dbad | 613 | lcd.clearPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 614 | } |
robinmc | 0:28392431dbad | 615 | } else if (g_mob_bear_p1[r][c]==1) { |
robinmc | 0:28392431dbad | 616 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 617 | } |
robinmc | 0:28392431dbad | 618 | } |
robinmc | 0:28392431dbad | 619 | } |
robinmc | 0:28392431dbad | 620 | } |
robinmc | 0:28392431dbad | 621 | |
robinmc | 3:4b254b4bd6d4 | 622 | //Funtion to print the moving bear (position 2) on the LCD |
robinmc | 3:4b254b4bd6d4 | 623 | void print_mob_bear_p2() |
robinmc | 0:28392431dbad | 624 | { |
robinmc | 0:28392431dbad | 625 | for(int c=0; c<=18; c++) { //18 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 626 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 627 | if (g_mob_bear_p2[r][c]==0) { |
robinmc | 0:28392431dbad | 628 | if (lcd.getPixel(c+bear_movement,r+37)!=0) { |
robinmc | 0:28392431dbad | 629 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 630 | } else { |
robinmc | 0:28392431dbad | 631 | lcd.clearPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 632 | } |
robinmc | 0:28392431dbad | 633 | } else if (g_mob_bear_p2[r][c]==1) { |
robinmc | 0:28392431dbad | 634 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 635 | } |
robinmc | 0:28392431dbad | 636 | } |
robinmc | 0:28392431dbad | 637 | } |
robinmc | 0:28392431dbad | 638 | } |
robinmc | 0:28392431dbad | 639 | |
robinmc | 3:4b254b4bd6d4 | 640 | //Funtion to print the dead bear |
robinmc | 3:4b254b4bd6d4 | 641 | void print_mob_bear_dead() |
robinmc | 0:28392431dbad | 642 | { |
robinmc | 0:28392431dbad | 643 | for(int c=0; c<=18; c++) { //18 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 644 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 645 | if (g_mob_bear_dead[r][c]==0) { |
robinmc | 0:28392431dbad | 646 | if (lcd.getPixel(c+bear_movement,r+37)!=0) { |
robinmc | 0:28392431dbad | 647 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 648 | } else { |
robinmc | 0:28392431dbad | 649 | lcd.clearPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 650 | } |
robinmc | 0:28392431dbad | 651 | } else if (g_mob_bear_dead[r][c]==1) { |
robinmc | 0:28392431dbad | 652 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 653 | } |
robinmc | 0:28392431dbad | 654 | } |
robinmc | 0:28392431dbad | 655 | } |
robinmc | 0:28392431dbad | 656 | } |
robinmc | 0:28392431dbad | 657 | |
robinmc | 3:4b254b4bd6d4 | 658 | //Funtion to print the moving (position 1) bird on the LCD |
robinmc | 3:4b254b4bd6d4 | 659 | void print_mob_bird_p1() |
robinmc | 0:28392431dbad | 660 | { |
robinmc | 0:28392431dbad | 661 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 662 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 663 | if (g_mob_bird_p1[r][c]==0) { |
robinmc | 0:28392431dbad | 664 | if (lcd.getPixel(c+bird_hMovement,r+bird_vMovement)!=0) { |
robinmc | 0:28392431dbad | 665 | lcd.setPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 666 | } else { |
robinmc | 0:28392431dbad | 667 | lcd.clearPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 668 | } |
robinmc | 0:28392431dbad | 669 | } else if (g_mob_bird_p1[r][c]==1) { |
robinmc | 0:28392431dbad | 670 | lcd.setPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 671 | } |
robinmc | 0:28392431dbad | 672 | } |
robinmc | 0:28392431dbad | 673 | } |
robinmc | 0:28392431dbad | 674 | } |
robinmc | 0:28392431dbad | 675 | |
robinmc | 3:4b254b4bd6d4 | 676 | //Funtion to print the moving (position 2) bird on the LCD |
robinmc | 3:4b254b4bd6d4 | 677 | void print_mob_bird_p2() |
robinmc | 0:28392431dbad | 678 | { |
robinmc | 0:28392431dbad | 679 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 680 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 681 | if (g_mob_bird_p2[r][c]==0) { |
robinmc | 0:28392431dbad | 682 | if (lcd.getPixel(c+bird_hMovement,r+bird_vMovement)!=0) { |
robinmc | 0:28392431dbad | 683 | lcd.setPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 684 | } else { |
robinmc | 0:28392431dbad | 685 | lcd.clearPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 686 | } |
robinmc | 0:28392431dbad | 687 | } else if (g_mob_bird_p2[r][c]==1) { |
robinmc | 0:28392431dbad | 688 | lcd.setPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 689 | } |
robinmc | 0:28392431dbad | 690 | } |
robinmc | 0:28392431dbad | 691 | } |
robinmc | 0:28392431dbad | 692 | } |
robinmc | 0:28392431dbad | 693 | |
robinmc | 3:4b254b4bd6d4 | 694 | //Funtion to print the dead bird on the LCD |
robinmc | 3:4b254b4bd6d4 | 695 | void print_mob_bird_dead() |
robinmc | 0:28392431dbad | 696 | { |
robinmc | 0:28392431dbad | 697 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 698 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 699 | if (g_mob_bird_dead[r][c]==0) { |
robinmc | 0:28392431dbad | 700 | lcd.clearPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 701 | } else if (g_mob_bird_dead[r][c]==1) { |
robinmc | 0:28392431dbad | 702 | lcd.setPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 703 | } |
robinmc | 0:28392431dbad | 704 | } |
robinmc | 0:28392431dbad | 705 | } |
robinmc | 0:28392431dbad | 706 | } |
robinmc | 0:28392431dbad | 707 | |
robinmc | 3:4b254b4bd6d4 | 708 | //Funtion to print the cactus |
robinmc | 3:4b254b4bd6d4 | 709 | void print_cactus() |
robinmc | 0:28392431dbad | 710 | { |
robinmc | 0:28392431dbad | 711 | for(int c=0; c<=4; c++) { //4 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 712 | for(int r=0; r<=11; r++) { |
robinmc | 3:4b254b4bd6d4 | 713 | if (g_cactus[r][c]==0) { |
robinmc | 0:28392431dbad | 714 | if (lcd.getPixel(c+cactus_movement,r+35)!=0) { |
robinmc | 0:28392431dbad | 715 | lcd.setPixel(c+cactus_movement,r+35); |
robinmc | 0:28392431dbad | 716 | } else { |
robinmc | 0:28392431dbad | 717 | lcd.clearPixel(c+cactus_movement,r+35); |
robinmc | 0:28392431dbad | 718 | } |
robinmc | 3:4b254b4bd6d4 | 719 | } else if (g_cactus[r][c]==1) { |
robinmc | 0:28392431dbad | 720 | lcd.setPixel(c+cactus_movement,r+35); |
robinmc | 0:28392431dbad | 721 | } |
robinmc | 0:28392431dbad | 722 | } |
robinmc | 0:28392431dbad | 723 | } |
robinmc | 0:28392431dbad | 724 | } |
robinmc | 0:28392431dbad | 725 | |
robinmc | 3:4b254b4bd6d4 | 726 | //Funtion to print the quick sand |
robinmc | 3:4b254b4bd6d4 | 727 | void print_quick_sand() |
robinmc | 3:4b254b4bd6d4 | 728 | { |
robinmc | 3:4b254b4bd6d4 | 729 | for(int x=0; x<=16; x++) { |
robinmc | 3:4b254b4bd6d4 | 730 | lcd.setPixel(x+quick_sand_movement,46); |
robinmc | 3:4b254b4bd6d4 | 731 | } |
robinmc | 3:4b254b4bd6d4 | 732 | } |
robinmc | 3:4b254b4bd6d4 | 733 | |
robinmc | 3:4b254b4bd6d4 | 734 | //Funtion to print the T Rex still |
robinmc | 0:28392431dbad | 735 | void print_t_rex() |
robinmc | 0:28392431dbad | 736 | { |
robinmc | 0:28392431dbad | 737 | for(int c=0; c<=24; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 738 | for(int r=0; r<=27; r++) { |
robinmc | 0:28392431dbad | 739 | if (g_t_rex[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 740 | if (lcd.getPixel(c+t_rex_movement,r+19)!=0) { |
robinmc | 1:046e66f1ca76 | 741 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 742 | } else { |
robinmc | 1:046e66f1ca76 | 743 | lcd.clearPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 744 | } |
robinmc | 0:28392431dbad | 745 | } else if (g_t_rex[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 746 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 747 | } |
robinmc | 0:28392431dbad | 748 | } |
robinmc | 0:28392431dbad | 749 | } |
robinmc | 0:28392431dbad | 750 | } |
robinmc | 0:28392431dbad | 751 | |
robinmc | 3:4b254b4bd6d4 | 752 | //Funtion to print the T Rex moving |
robinmc | 0:28392431dbad | 753 | void print_t_rex_moving() |
robinmc | 0:28392431dbad | 754 | { |
robinmc | 0:28392431dbad | 755 | for(int c=0; c<=24; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 756 | for(int r=0; r<=27; r++) { |
robinmc | 0:28392431dbad | 757 | if (g_t_rex_moving[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 758 | if (lcd.getPixel(c+t_rex_movement,r+19)!=0) { |
robinmc | 1:046e66f1ca76 | 759 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 760 | } else { |
robinmc | 1:046e66f1ca76 | 761 | lcd.clearPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 762 | } |
robinmc | 0:28392431dbad | 763 | } else if (g_t_rex_moving[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 764 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 765 | } |
robinmc | 0:28392431dbad | 766 | } |
robinmc | 0:28392431dbad | 767 | } |
robinmc | 0:28392431dbad | 768 | } |
robinmc | 0:28392431dbad | 769 | |
robinmc | 3:4b254b4bd6d4 | 770 | //Funtion to print the T Rex attack |
robinmc | 0:28392431dbad | 771 | void print_t_rex_attack() |
robinmc | 0:28392431dbad | 772 | { |
robinmc | 0:28392431dbad | 773 | for(int c=0; c<=24; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 774 | for(int r=0; r<=27; r++) { |
robinmc | 0:28392431dbad | 775 | if (g_t_rex_attack[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 776 | if (lcd.getPixel(c+t_rex_movement,r+19)!=0) { |
robinmc | 1:046e66f1ca76 | 777 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 778 | } else { |
robinmc | 1:046e66f1ca76 | 779 | lcd.clearPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 780 | } |
robinmc | 0:28392431dbad | 781 | } else if (g_t_rex_attack[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 782 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 783 | } |
robinmc | 0:28392431dbad | 784 | } |
robinmc | 0:28392431dbad | 785 | } |
robinmc | 0:28392431dbad | 786 | } |
robinmc | 0:28392431dbad | 787 | |
robinmc | 3:4b254b4bd6d4 | 788 | //Funtion to print the fire ball (position 1) |
robinmc | 0:28392431dbad | 789 | void print_fire_ball_p1() |
robinmc | 0:28392431dbad | 790 | { |
robinmc | 0:28392431dbad | 791 | for(int c=0; c<=8; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 792 | for(int r=0; r<=8; r++) { |
robinmc | 0:28392431dbad | 793 | if (g_fire_ball_p1[r][c]==0) { |
robinmc | 0:28392431dbad | 794 | if (lcd.getPixel(c+fire_ball_hMovement,r+fire_ball_vMovement)!=0) { |
robinmc | 0:28392431dbad | 795 | lcd.setPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 796 | } else { |
robinmc | 0:28392431dbad | 797 | lcd.clearPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 798 | } |
robinmc | 0:28392431dbad | 799 | } else if (g_fire_ball_p1[r][c]==1) { |
robinmc | 0:28392431dbad | 800 | lcd.setPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 801 | } |
robinmc | 0:28392431dbad | 802 | } |
robinmc | 0:28392431dbad | 803 | } |
robinmc | 0:28392431dbad | 804 | } |
robinmc | 0:28392431dbad | 805 | |
robinmc | 3:4b254b4bd6d4 | 806 | //Funtion to print the fire ball (position 2) |
robinmc | 0:28392431dbad | 807 | void print_fire_ball_p2() |
robinmc | 0:28392431dbad | 808 | { |
robinmc | 2:158d57cdbf1e | 809 | for(int c=0; c<=8; c++) { //24 beacause the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 810 | for(int r=0; r<=8; r++) { |
robinmc | 0:28392431dbad | 811 | if (g_fire_ball_p2[r][c]==0) { |
robinmc | 0:28392431dbad | 812 | if (lcd.getPixel(c+fire_ball_hMovement,r+fire_ball_vMovement)!=0) { |
robinmc | 0:28392431dbad | 813 | lcd.setPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 814 | } else { |
robinmc | 0:28392431dbad | 815 | lcd.clearPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 816 | } |
robinmc | 0:28392431dbad | 817 | } else if (g_fire_ball_p2[r][c]==1) { |
robinmc | 0:28392431dbad | 818 | lcd.setPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 819 | } |
robinmc | 0:28392431dbad | 820 | } |
robinmc | 0:28392431dbad | 821 | } |
robinmc | 0:28392431dbad | 822 | } |
robinmc | 0:28392431dbad | 823 | |
robinmc | 3:4b254b4bd6d4 | 824 | //Funtion to print the clouds |
robinmc | 0:28392431dbad | 825 | void print_clouds() |
robinmc | 0:28392431dbad | 826 | { |
robinmc | 3:4b254b4bd6d4 | 827 | //8 bit unsigned integer that loops round to 0 when the h_movement variable is > than 255 |
robinmc | 3:4b254b4bd6d4 | 828 | //this means that the cloud array loops round when it finishes |
robinmc | 3:4b254b4bd6d4 | 829 | uint8_t clouds_movement=h_movement; |
robinmc | 0:28392431dbad | 830 | for(int c=clouds_movement; c<=clouds_movement+83; c++) { |
robinmc | 0:28392431dbad | 831 | for(int r=0; r<=2; r++) { |
robinmc | 0:28392431dbad | 832 | if (g_clouds[r][c]==0) { |
robinmc | 0:28392431dbad | 833 | lcd.clearPixel(c-clouds_movement,r+6); |
robinmc | 0:28392431dbad | 834 | } else if (g_clouds[r][c]==1) { |
robinmc | 0:28392431dbad | 835 | lcd.setPixel(c-clouds_movement,r+6); |
robinmc | 0:28392431dbad | 836 | } |
robinmc | 0:28392431dbad | 837 | } |
robinmc | 0:28392431dbad | 838 | } |
robinmc | 0:28392431dbad | 839 | } |
robinmc | 0:28392431dbad | 840 | |
robinmc | 1:046e66f1ca76 | 841 | void print_locks() |
robinmc | 0:28392431dbad | 842 | { |
robinmc | 3:4b254b4bd6d4 | 843 | //depending on the value of story_progress locked padlocks are printed or unlocked ones |
robinmc | 1:046e66f1ca76 | 844 | int sp=8*story_progress; |
robinmc | 1:046e66f1ca76 | 845 | for(int c=0; c<=3; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 846 | for(int r=0; r<=5; r++) { |
robinmc | 1:046e66f1ca76 | 847 | for (int n=1; n<=33; n+=8) { |
robinmc | 1:046e66f1ca76 | 848 | if (g_padlock_p1[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 849 | lcd.clearPixel(c+8,r+n); |
robinmc | 1:046e66f1ca76 | 850 | } else if (g_padlock_p1[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 851 | lcd.setPixel(c+8,r+n); |
robinmc | 1:046e66f1ca76 | 852 | } |
robinmc | 1:046e66f1ca76 | 853 | } |
robinmc | 0:28392431dbad | 854 | } |
robinmc | 0:28392431dbad | 855 | } |
robinmc | 1:046e66f1ca76 | 856 | for(int c=0; c<=3; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 857 | for(int r=0; r<=5; r++) { |
robinmc | 1:046e66f1ca76 | 858 | for (int n=1; n<=sp; n+=8) { |
robinmc | 1:046e66f1ca76 | 859 | if (g_padlock_p2[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 860 | lcd.clearPixel(c+8,r+n); |
robinmc | 1:046e66f1ca76 | 861 | } else if (g_padlock_p2[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 862 | lcd.setPixel(c+8,r+n); |
robinmc | 1:046e66f1ca76 | 863 | } |
robinmc | 1:046e66f1ca76 | 864 | } |
robinmc | 1:046e66f1ca76 | 865 | } |
robinmc | 1:046e66f1ca76 | 866 | } |
robinmc | 0:28392431dbad | 867 | } |
robinmc | 0:28392431dbad | 868 | |
robinmc | 1:046e66f1ca76 | 869 | |
robinmc | 3:4b254b4bd6d4 | 870 | //Funtion that is called when the player walks or jumps on quick sand, Recks falls and |
robinmc | 3:4b254b4bd6d4 | 871 | //looses all lives |
robinmc | 3:4b254b4bd6d4 | 872 | void falling_animation() |
robinmc | 0:28392431dbad | 873 | { |
robinmc | 3:4b254b4bd6d4 | 874 | while (fall<60) { |
robinmc | 3:4b254b4bd6d4 | 875 | if (g_Ticker_Game_flag) { |
robinmc | 3:4b254b4bd6d4 | 876 | g_Ticker_Game_flag=0; |
robinmc | 3:4b254b4bd6d4 | 877 | print_recks_falling(); |
robinmc | 3:4b254b4bd6d4 | 878 | fall+=3; //vertical poition of recks increases (goes down) every loop |
robinmc | 3:4b254b4bd6d4 | 879 | } |
robinmc | 3:4b254b4bd6d4 | 880 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 881 | sleep(); //puts mbed to sleep |
robinmc | 3:4b254b4bd6d4 | 882 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 3:4b254b4bd6d4 | 883 | } |
robinmc | 0:28392431dbad | 884 | } |
robinmc | 0:28392431dbad | 885 | |
robinmc | 3:4b254b4bd6d4 | 886 | //Funtion that is called before the main menu the start and dislplayes the name of the game |
robinmc | 0:28392431dbad | 887 | void intro() |
robinmc | 0:28392431dbad | 888 | { |
robinmc | 3:4b254b4bd6d4 | 889 | lcd.clear(); //clears all pixels on LCD |
robinmc | 3:4b254b4bd6d4 | 890 | lcd.printString("ROBOZOEC",18,2); |
robinmc | 3:4b254b4bd6d4 | 891 | lcd.printString("ERA",33,3); |
robinmc | 3:4b254b4bd6d4 | 892 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 893 | ticker_wait(30); |
robinmc | 0:28392431dbad | 894 | } |
robinmc | 0:28392431dbad | 895 | |
robinmc | 3:4b254b4bd6d4 | 896 | //Interrupt service routine for the menus ticker |
robinmc | 0:28392431dbad | 897 | void Ticker_Menu_isr() |
robinmc | 0:28392431dbad | 898 | { |
robinmc | 3:4b254b4bd6d4 | 899 | //sets the menu flag to 1 |
robinmc | 0:28392431dbad | 900 | g_Ticker_Menu_flag=1; |
robinmc | 0:28392431dbad | 901 | } |
robinmc | 0:28392431dbad | 902 | |
robinmc | 3:4b254b4bd6d4 | 903 | //Interrupt service routine for the game ticker |
robinmc | 0:28392431dbad | 904 | void Ticker_Game_isr() |
robinmc | 0:28392431dbad | 905 | { |
robinmc | 3:4b254b4bd6d4 | 906 | //sets the menu flag to 1 |
robinmc | 0:28392431dbad | 907 | g_Ticker_Game_flag=1; |
robinmc | 0:28392431dbad | 908 | } |
robinmc | 0:28392431dbad | 909 | |
robinmc | 3:4b254b4bd6d4 | 910 | //Interrupt service routine for the ticker_wait funtion ticker |
robinmc | 2:158d57cdbf1e | 911 | void Ticker_ds_isr() |
robinmc | 2:158d57cdbf1e | 912 | { |
robinmc | 3:4b254b4bd6d4 | 913 | //sets ds flag to 1 |
robinmc | 2:158d57cdbf1e | 914 | g_Ticker_ds_flag=1; |
robinmc | 2:158d57cdbf1e | 915 | } |
robinmc | 2:158d57cdbf1e | 916 | |
robinmc | 3:4b254b4bd6d4 | 917 | //Funtion that is called when the time out is timed out |
robinmc | 2:158d57cdbf1e | 918 | void music_tOut() |
robinmc | 2:158d57cdbf1e | 919 | { |
robinmc | 3:4b254b4bd6d4 | 920 | //Turns the note off |
robinmc | 2:158d57cdbf1e | 921 | PWM.write(0.0); |
robinmc | 2:158d57cdbf1e | 922 | } |
robinmc | 2:158d57cdbf1e | 923 | |
robinmc | 3:4b254b4bd6d4 | 924 | //Interrupt service routine for the press_b_A interrupt |
robinmc | 0:28392431dbad | 925 | void press_b_A_isr() |
robinmc | 0:28392431dbad | 926 | { |
robinmc | 3:4b254b4bd6d4 | 927 | //sets the g_press_b_A_flag to 1 |
robinmc | 0:28392431dbad | 928 | g_press_b_A_flag=1; |
robinmc | 0:28392431dbad | 929 | } |
robinmc | 0:28392431dbad | 930 | |
robinmc | 3:4b254b4bd6d4 | 931 | //Interrupt service routine for the press_b_B interrupt |
robinmc | 2:158d57cdbf1e | 932 | void press_b_B_isr() |
robinmc | 2:158d57cdbf1e | 933 | { |
robinmc | 3:4b254b4bd6d4 | 934 | //sets the g_press_b_B_flag to 1 |
robinmc | 2:158d57cdbf1e | 935 | g_press_b_B_flag=1; |
robinmc | 2:158d57cdbf1e | 936 | } |
robinmc | 2:158d57cdbf1e | 937 | |
robinmc | 0:28392431dbad | 938 | // read default positions of the joystick to calibrate later readings |
robinmc | 0:28392431dbad | 939 | void calibrateJoystick() |
robinmc | 0:28392431dbad | 940 | { |
robinmc | 0:28392431dbad | 941 | swJoy.mode(PullDown); |
robinmc | 0:28392431dbad | 942 | // must not move during calibration |
robinmc | 0:28392431dbad | 943 | joystick.x0 = xPot; // initial positions in the range 0.0 to 1.0 (0.5 if centred exactly) |
robinmc | 0:28392431dbad | 944 | joystick.y0 = yPot; |
robinmc | 0:28392431dbad | 945 | } |
robinmc | 0:28392431dbad | 946 | void updateJoystick() |
robinmc | 0:28392431dbad | 947 | { |
robinmc | 0:28392431dbad | 948 | // read current joystick values relative to calibrated values (in range -0.5 to 0.5, 0.0 is centred) |
robinmc | 0:28392431dbad | 949 | joystick.x = xPot - joystick.x0; |
robinmc | 0:28392431dbad | 950 | joystick.y = yPot - joystick.y0; |
robinmc | 0:28392431dbad | 951 | // read button state |
robinmc | 0:28392431dbad | 952 | joystick.swJoy = swJoy; |
robinmc | 0:28392431dbad | 953 | |
robinmc | 0:28392431dbad | 954 | // calculate direction depending on x,y values |
robinmc | 0:28392431dbad | 955 | // tolerance allows a little lee-way in case joystick not exactly in the stated direction |
robinmc | 0:28392431dbad | 956 | if ( fabs(joystick.y) < joystickTolerance && fabs(joystick.x) < joystickTolerance) { |
robinmc | 0:28392431dbad | 957 | joystick.direction = CENTRE; |
robinmc | 0:28392431dbad | 958 | } else if ( joystick.y > joystickTolerance && fabs(joystick.x) < joystickTolerance) { |
robinmc | 0:28392431dbad | 959 | joystick.direction = UP; |
robinmc | 0:28392431dbad | 960 | } else if ( joystick.y < joystickTolerance && fabs(joystick.x) < joystickTolerance) { |
robinmc | 0:28392431dbad | 961 | joystick.direction = DOWN; |
robinmc | 0:28392431dbad | 962 | } else if ( joystick.x > joystickTolerance && fabs(joystick.y) < joystickTolerance) { |
robinmc | 0:28392431dbad | 963 | joystick.direction = LEFT; |
robinmc | 0:28392431dbad | 964 | } else if ( joystick.x < joystickTolerance && fabs(joystick.y) < joystickTolerance) { |
robinmc | 0:28392431dbad | 965 | joystick.direction = RIGHT; |
robinmc | 0:28392431dbad | 966 | } |
robinmc | 0:28392431dbad | 967 | } |
robinmc | 0:28392431dbad | 968 | |
robinmc | 3:4b254b4bd6d4 | 969 | //Funtion that prints the main menu and all other funtions are called from it |
robinmc | 2:158d57cdbf1e | 970 | void main_menu() |
robinmc | 2:158d57cdbf1e | 971 | { |
robinmc | 1:046e66f1ca76 | 972 | menuState=0; |
robinmc | 0:28392431dbad | 973 | while(1) { |
robinmc | 2:158d57cdbf1e | 974 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 975 | g_press_b_A_flag=0; |
robinmc | 0:28392431dbad | 976 | if (g_Ticker_Menu_flag) { |
robinmc | 0:28392431dbad | 977 | g_Ticker_Menu_flag=0; |
robinmc | 0:28392431dbad | 978 | updateJoystick(); |
robinmc | 1:046e66f1ca76 | 979 | lcd.setBrightness(brightness); |
robinmc | 0:28392431dbad | 980 | menu_select = fsm_main_menu[menuState].menu_select; // set ouput depending on current state |
robinmc | 0:28392431dbad | 981 | menuState = fsm_main_menu[menuState].nextState[joystick.direction]; // when joystick.direction has a vaule of CENTRE/RIGHT/LEFT the state machine input is 0 when it has a value of DOWN it is 0b01 when it has a value of UP is is 0b10 |
robinmc | 3:4b254b4bd6d4 | 982 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 3:4b254b4bd6d4 | 983 | //Print the options on the main menu |
robinmc | 0:28392431dbad | 984 | lcd.printString("Story mode",13,0); |
robinmc | 0:28392431dbad | 985 | lcd.printString("Minigame",18,1); |
robinmc | 0:28392431dbad | 986 | lcd.printString("Settings",18,2); |
robinmc | 0:28392431dbad | 987 | lcd.printString("Leaderboard",9,3); |
robinmc | 0:28392431dbad | 988 | lcd.printString("Credits",21,4); |
robinmc | 3:4b254b4bd6d4 | 989 | //inverts the pixels to highlight the option that would be selected if the buttion A is pressed |
robinmc | 0:28392431dbad | 990 | for (int i=0; i<85; i++) { //go through every pixel on the x axis |
robinmc | 0:28392431dbad | 991 | for (int j=menu_select; j<(menu_select+8); j++) { // go through relevant pixels on the y axis |
robinmc | 0:28392431dbad | 992 | if (lcd.getPixel(i,j)== 0) { //if the pixel is on trun it off |
robinmc | 0:28392431dbad | 993 | lcd.setPixel(i,j); |
robinmc | 0:28392431dbad | 994 | } else { |
robinmc | 0:28392431dbad | 995 | lcd.clearPixel(i,j); //if the pixel is off turn it on |
robinmc | 0:28392431dbad | 996 | } |
robinmc | 0:28392431dbad | 997 | } |
robinmc | 0:28392431dbad | 998 | } |
robinmc | 0:28392431dbad | 999 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 1000 | //if the butto A is pressed with and the output of the menu fsm is 0, 8, 16, 24, 32 |
robinmc | 0:28392431dbad | 1001 | if (b_A & menu_select==0) { |
robinmc | 3:4b254b4bd6d4 | 1002 | //calls story mode function |
robinmc | 2:158d57cdbf1e | 1003 | Story_Mode(); |
robinmc | 0:28392431dbad | 1004 | } else if (b_A & menu_select==8) { |
robinmc | 3:4b254b4bd6d4 | 1005 | //calls game function |
robinmc | 2:158d57cdbf1e | 1006 | Game(); |
robinmc | 0:28392431dbad | 1007 | } else if (b_A & menu_select==16) { |
robinmc | 3:4b254b4bd6d4 | 1008 | //calls settings function |
robinmc | 2:158d57cdbf1e | 1009 | Settings(); |
robinmc | 0:28392431dbad | 1010 | } else if (b_A & menu_select==24) { |
robinmc | 3:4b254b4bd6d4 | 1011 | //calls leaderboard function and after it turns the mbes leds off |
robinmc | 2:158d57cdbf1e | 1012 | Leaderboard(); |
robinmc | 2:158d57cdbf1e | 1013 | red_led=1; |
robinmc | 2:158d57cdbf1e | 1014 | green_led=1; |
robinmc | 0:28392431dbad | 1015 | } else if (b_A & menu_select==32) { |
robinmc | 3:4b254b4bd6d4 | 1016 | //calls the credits funtion |
robinmc | 2:158d57cdbf1e | 1017 | Credits(); |
robinmc | 2:158d57cdbf1e | 1018 | } |
robinmc | 3:4b254b4bd6d4 | 1019 | //CHEAT CODE that unlocks all the story mode chapters |
robinmc | 3:4b254b4bd6d4 | 1020 | //CODE: joystick LEFT, button swJoy and button b_B at the same time |
robinmc | 2:158d57cdbf1e | 1021 | if (joystick.direction==LEFT&swJoy==1&b_B==1) { |
robinmc | 2:158d57cdbf1e | 1022 | story_progress=5; |
robinmc | 2:158d57cdbf1e | 1023 | writeSD_progress(); |
robinmc | 3:4b254b4bd6d4 | 1024 | //Led turns on and off to show that the code was sucessfull |
robinmc | 2:158d57cdbf1e | 1025 | green_led=0; |
robinmc | 2:158d57cdbf1e | 1026 | ticker_wait(5); |
robinmc | 2:158d57cdbf1e | 1027 | green_led=1; |
robinmc | 0:28392431dbad | 1028 | } |
robinmc | 0:28392431dbad | 1029 | } |
robinmc | 3:4b254b4bd6d4 | 1030 | sleep(); //puts mbed to sleep |
robinmc | 0:28392431dbad | 1031 | } |
robinmc | 2:158d57cdbf1e | 1032 | } |
robinmc | 0:28392431dbad | 1033 | |
robinmc | 3:4b254b4bd6d4 | 1034 | //Function that runs the game, when this funtion runs the game has no end |
robinmc | 2:158d57cdbf1e | 1035 | void Minigame() |
robinmc | 2:158d57cdbf1e | 1036 | { |
robinmc | 3:4b254b4bd6d4 | 1037 | ticker_wait(5); //wait 0.5s |
robinmc | 2:158d57cdbf1e | 1038 | while (1) { |
robinmc | 2:158d57cdbf1e | 1039 | if (g_Ticker_Game_flag) { |
robinmc | 2:158d57cdbf1e | 1040 | g_Ticker_Game_flag=0; |
robinmc | 3:4b254b4bd6d4 | 1041 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1042 | updateJoystick(); |
robinmc | 3:4b254b4bd6d4 | 1043 | Game(); //run the came |
robinmc | 2:158d57cdbf1e | 1044 | |
robinmc | 2:158d57cdbf1e | 1045 | } |
robinmc | 2:158d57cdbf1e | 1046 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 1047 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1048 | } |
robinmc | 2:158d57cdbf1e | 1049 | } |
robinmc | 2:158d57cdbf1e | 1050 | |
robinmc | 3:4b254b4bd6d4 | 1051 | //Function that runs story mode menu |
robinmc | 2:158d57cdbf1e | 1052 | void Story_Mode() |
robinmc | 2:158d57cdbf1e | 1053 | { |
robinmc | 1:046e66f1ca76 | 1054 | menuState=0; |
robinmc | 3:4b254b4bd6d4 | 1055 | story_mode_flag=1; //if this =1 the game funtion will end at different score levels depending on chapter |
robinmc | 2:158d57cdbf1e | 1056 | led=0; |
robinmc | 2:158d57cdbf1e | 1057 | readSD_progress(); |
robinmc | 1:046e66f1ca76 | 1058 | while(1) { |
robinmc | 1:046e66f1ca76 | 1059 | if (g_Ticker_Menu_flag) { |
robinmc | 1:046e66f1ca76 | 1060 | g_Ticker_Menu_flag=0; |
robinmc | 1:046e66f1ca76 | 1061 | updateJoystick(); |
robinmc | 1:046e66f1ca76 | 1062 | lcd.setBrightness(brightness); |
robinmc | 1:046e66f1ca76 | 1063 | menu_select = fsm_main_menu[menuState].menu_select; // set ouput depending on current state |
robinmc | 1:046e66f1ca76 | 1064 | menuState = fsm_main_menu[menuState].nextState[joystick.direction]; // when joystick.direction has a vaule of CENTRE/RIGHT/LEFT the state machine input is 0 when it has a value of DOWN it is 0b01 when it has a value of UP is is 0b10 |
robinmc | 3:4b254b4bd6d4 | 1065 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 3:4b254b4bd6d4 | 1066 | //prints the locks displaying what chapters are unlocked |
robinmc | 1:046e66f1ca76 | 1067 | print_locks(); |
robinmc | 3:4b254b4bd6d4 | 1068 | //prints the chapters |
robinmc | 2:158d57cdbf1e | 1069 | lcd.printString("Tutorial",20,0); |
robinmc | 2:158d57cdbf1e | 1070 | lcd.printString("Chapter 1",20,1); |
robinmc | 2:158d57cdbf1e | 1071 | lcd.printString("Chapter 2",20,2); |
robinmc | 2:158d57cdbf1e | 1072 | lcd.printString("Chapter 3",20,3); |
robinmc | 2:158d57cdbf1e | 1073 | lcd.printString("Chapter 4",20,4); |
robinmc | 1:046e66f1ca76 | 1074 | for (int i=0; i<85; i++) { //go through every pixel on the x axis |
robinmc | 1:046e66f1ca76 | 1075 | for (int j=menu_select; j<(menu_select+8); j++) { // go through relevant pixels on the y axis |
robinmc | 1:046e66f1ca76 | 1076 | if (lcd.getPixel(i,j)== 0) { //if the pixel is on trun it off |
robinmc | 1:046e66f1ca76 | 1077 | lcd.setPixel(i,j); |
robinmc | 1:046e66f1ca76 | 1078 | } else { |
robinmc | 1:046e66f1ca76 | 1079 | lcd.clearPixel(i,j); //if the pixel is off turn it on |
robinmc | 1:046e66f1ca76 | 1080 | } |
robinmc | 1:046e66f1ca76 | 1081 | } |
robinmc | 1:046e66f1ca76 | 1082 | } |
robinmc | 1:046e66f1ca76 | 1083 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 1084 | //selects chapter depending on the button A, the output of the menu fst and whether it is unlocked |
robinmc | 2:158d57cdbf1e | 1085 | if (b_A & menu_select==0&story_progress>=1) { |
robinmc | 2:158d57cdbf1e | 1086 | Tutorial(); |
robinmc | 2:158d57cdbf1e | 1087 | } else if (b_A & menu_select==8&story_progress>=2) { |
robinmc | 2:158d57cdbf1e | 1088 | Chapter1(); |
robinmc | 2:158d57cdbf1e | 1089 | } else if (b_A & menu_select==16&story_progress>=3) { |
robinmc | 2:158d57cdbf1e | 1090 | Chapter2(); |
robinmc | 2:158d57cdbf1e | 1091 | } else if (b_A & menu_select==24&story_progress>=4) { |
robinmc | 2:158d57cdbf1e | 1092 | Chapter3(); |
robinmc | 2:158d57cdbf1e | 1093 | } else if (b_A & menu_select==32&story_progress>=5) { |
robinmc | 2:158d57cdbf1e | 1094 | Chapter4(); |
robinmc | 1:046e66f1ca76 | 1095 | } |
robinmc | 3:4b254b4bd6d4 | 1096 | //if button b_B is presses it returns to the main menu clearing the story mode flag |
robinmc | 1:046e66f1ca76 | 1097 | if (b_B) { |
robinmc | 2:158d57cdbf1e | 1098 | menuState=0; |
robinmc | 2:158d57cdbf1e | 1099 | story_mode_flag=0; |
robinmc | 2:158d57cdbf1e | 1100 | return; |
robinmc | 1:046e66f1ca76 | 1101 | } |
robinmc | 1:046e66f1ca76 | 1102 | } |
robinmc | 3:4b254b4bd6d4 | 1103 | sleep(); //puts mbed to sleep |
robinmc | 1:046e66f1ca76 | 1104 | } |
robinmc | 2:158d57cdbf1e | 1105 | } |
robinmc | 2:158d57cdbf1e | 1106 | |
robinmc | 3:4b254b4bd6d4 | 1107 | |
robinmc | 3:4b254b4bd6d4 | 1108 | //Funtion that introduces the game and the controls to the user |
robinmc | 2:158d57cdbf1e | 1109 | void Tutorial() |
robinmc | 2:158d57cdbf1e | 1110 | { |
robinmc | 3:4b254b4bd6d4 | 1111 | //prints message |
robinmc | 3:4b254b4bd6d4 | 1112 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1113 | lcd.printString("Welcome to",0,0); |
robinmc | 2:158d57cdbf1e | 1114 | lcd.printString("boot camp",0,1); |
robinmc | 2:158d57cdbf1e | 1115 | lcd.printString("soldier",0,2); |
robinmc | 2:158d57cdbf1e | 1116 | lcd.printString("Press A >>",24,5); |
robinmc | 2:158d57cdbf1e | 1117 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1118 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1119 | g_press_b_A_flag=0; |
robinmc | 3:4b254b4bd6d4 | 1120 | //when b_A is pressed it exits the while loop continueing to the next printed message |
robinmc | 2:158d57cdbf1e | 1121 | while (1) { |
robinmc | 2:158d57cdbf1e | 1122 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1123 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1124 | break; |
robinmc | 2:158d57cdbf1e | 1125 | } |
robinmc | 3:4b254b4bd6d4 | 1126 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1127 | } |
robinmc | 3:4b254b4bd6d4 | 1128 | //print message |
robinmc | 3:4b254b4bd6d4 | 1129 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1130 | lcd.printString("Are you ready",0,0); |
robinmc | 2:158d57cdbf1e | 1131 | lcd.printString("to begin your",0,1); |
robinmc | 2:158d57cdbf1e | 1132 | lcd.printString("training?",0,2); |
robinmc | 2:158d57cdbf1e | 1133 | lcd.printString("Press A >>",24,5); |
robinmc | 2:158d57cdbf1e | 1134 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1135 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1136 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1137 | while (1) { |
robinmc | 2:158d57cdbf1e | 1138 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1139 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1140 | break; |
robinmc | 2:158d57cdbf1e | 1141 | } |
robinmc | 3:4b254b4bd6d4 | 1142 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1143 | } |
robinmc | 3:4b254b4bd6d4 | 1144 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1145 | lcd.printString("Okay use",0,0); |
robinmc | 2:158d57cdbf1e | 1146 | lcd.printString("joysick to",0,1); |
robinmc | 2:158d57cdbf1e | 1147 | lcd.printString("move right and",0,2); |
robinmc | 2:158d57cdbf1e | 1148 | lcd.printString("left to...",0,3); |
robinmc | 2:158d57cdbf1e | 1149 | lcd.printString("Press A >>",24,5); |
robinmc | 2:158d57cdbf1e | 1150 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1151 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1152 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1153 | while (1) { |
robinmc | 2:158d57cdbf1e | 1154 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1155 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1156 | break; |
robinmc | 2:158d57cdbf1e | 1157 | } |
robinmc | 3:4b254b4bd6d4 | 1158 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1159 | } |
robinmc | 3:4b254b4bd6d4 | 1160 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1161 | lcd.printString("... move",0,0); |
robinmc | 2:158d57cdbf1e | 1162 | lcd.printString("forwards and",0,1); |
robinmc | 2:158d57cdbf1e | 1163 | lcd.printString("backwards.",0,2); |
robinmc | 2:158d57cdbf1e | 1164 | lcd.printString("Understand?",0,3); |
robinmc | 2:158d57cdbf1e | 1165 | lcd.printString("Yes Sir!>>",22,5); |
robinmc | 2:158d57cdbf1e | 1166 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1167 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1168 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1169 | while (1) { |
robinmc | 2:158d57cdbf1e | 1170 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1171 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1172 | break; |
robinmc | 2:158d57cdbf1e | 1173 | } |
robinmc | 3:4b254b4bd6d4 | 1174 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1175 | } |
robinmc | 3:4b254b4bd6d4 | 1176 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1177 | lcd.printString("Now you try...",0,0); |
robinmc | 2:158d57cdbf1e | 1178 | lcd.printString("Okay!>>",30,5); |
robinmc | 2:158d57cdbf1e | 1179 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1180 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1181 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1182 | while (1) { |
robinmc | 2:158d57cdbf1e | 1183 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1184 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1185 | break; |
robinmc | 2:158d57cdbf1e | 1186 | } |
robinmc | 3:4b254b4bd6d4 | 1187 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1188 | } |
robinmc | 3:4b254b4bd6d4 | 1189 | //sets the difficulty to -1, no interactive elements in the game |
robinmc | 3:4b254b4bd6d4 | 1190 | //this allows the player to try the game contolls |
robinmc | 2:158d57cdbf1e | 1191 | difficulty =-1; |
robinmc | 2:158d57cdbf1e | 1192 | Game(); |
robinmc | 3:4b254b4bd6d4 | 1193 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1194 | lcd.printString("Good!!!",0,0); |
robinmc | 2:158d57cdbf1e | 1195 | lcd.printString("Now lets try",0,1); |
robinmc | 2:158d57cdbf1e | 1196 | lcd.printString("jumping. To",0,2); |
robinmc | 2:158d57cdbf1e | 1197 | lcd.printString("jump press B",0,3); |
robinmc | 2:158d57cdbf1e | 1198 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1199 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1200 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1201 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1202 | while (1) { |
robinmc | 2:158d57cdbf1e | 1203 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1204 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1205 | break; |
robinmc | 2:158d57cdbf1e | 1206 | } |
robinmc | 3:4b254b4bd6d4 | 1207 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1208 | } |
robinmc | 3:4b254b4bd6d4 | 1209 | //sets the difficulty to -1, no interactive elements in the game |
robinmc | 3:4b254b4bd6d4 | 1210 | //this allows the player to try the game contolls |
robinmc | 2:158d57cdbf1e | 1211 | difficulty =-1; |
robinmc | 2:158d57cdbf1e | 1212 | Game(); |
robinmc | 3:4b254b4bd6d4 | 1213 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1214 | lcd.printString("You can also",0,0); |
robinmc | 2:158d57cdbf1e | 1215 | lcd.printString("crouch if you",0,1); |
robinmc | 2:158d57cdbf1e | 1216 | lcd.printString("move your",0,2); |
robinmc | 2:158d57cdbf1e | 1217 | lcd.printString("joystick down",0,3); |
robinmc | 2:158d57cdbf1e | 1218 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1219 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1220 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1221 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1222 | while (1) { |
robinmc | 2:158d57cdbf1e | 1223 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1224 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1225 | break; |
robinmc | 2:158d57cdbf1e | 1226 | } |
robinmc | 3:4b254b4bd6d4 | 1227 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1228 | } |
robinmc | 3:4b254b4bd6d4 | 1229 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1230 | lcd.printString("And if you",0,0); |
robinmc | 2:158d57cdbf1e | 1231 | lcd.printString("move the joy-",0,1); |
robinmc | 2:158d57cdbf1e | 1232 | lcd.printString("stick up you",0,2); |
robinmc | 2:158d57cdbf1e | 1233 | lcd.printString("will activate",0,3); |
robinmc | 2:158d57cdbf1e | 1234 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1235 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1236 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1237 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1238 | while (1) { |
robinmc | 2:158d57cdbf1e | 1239 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1240 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1241 | break; |
robinmc | 2:158d57cdbf1e | 1242 | } |
robinmc | 3:4b254b4bd6d4 | 1243 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1244 | } |
robinmc | 3:4b254b4bd6d4 | 1245 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1246 | lcd.printString("your shield,",0,0); |
robinmc | 2:158d57cdbf1e | 1247 | lcd.printString("this will",0,1); |
robinmc | 2:158d57cdbf1e | 1248 | lcd.printString("protect you",0,2); |
robinmc | 2:158d57cdbf1e | 1249 | lcd.printString("for 1 sec but",0,3); |
robinmc | 2:158d57cdbf1e | 1250 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1251 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1252 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1253 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1254 | while (1) { |
robinmc | 2:158d57cdbf1e | 1255 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1256 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1257 | break; |
robinmc | 2:158d57cdbf1e | 1258 | } |
robinmc | 3:4b254b4bd6d4 | 1259 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1260 | } |
robinmc | 3:4b254b4bd6d4 | 1261 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1262 | lcd.printString("it'll cost",0,0); |
robinmc | 2:158d57cdbf1e | 1263 | lcd.printString("you 10 score",0,1); |
robinmc | 2:158d57cdbf1e | 1264 | lcd.printString("points.",0,2); |
robinmc | 2:158d57cdbf1e | 1265 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1266 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1267 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1268 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1269 | while (1) { |
robinmc | 2:158d57cdbf1e | 1270 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1271 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1272 | break; |
robinmc | 2:158d57cdbf1e | 1273 | } |
robinmc | 3:4b254b4bd6d4 | 1274 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1275 | } |
robinmc | 3:4b254b4bd6d4 | 1276 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1277 | lcd.printString("Try it...",0,0); |
robinmc | 2:158d57cdbf1e | 1278 | lcd.printString("Okay>>",30,5); |
robinmc | 2:158d57cdbf1e | 1279 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1280 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1281 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1282 | while (1) { |
robinmc | 2:158d57cdbf1e | 1283 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1284 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1285 | break; |
robinmc | 2:158d57cdbf1e | 1286 | } |
robinmc | 3:4b254b4bd6d4 | 1287 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1288 | } |
robinmc | 3:4b254b4bd6d4 | 1289 | //sets the difficulty to -1, no interactive elements in the game |
robinmc | 3:4b254b4bd6d4 | 1290 | //this allows the player to try the game contolls |
robinmc | 3:4b254b4bd6d4 | 1291 | //Also increases the score to 30 so player can test using the shield |
robinmc | 2:158d57cdbf1e | 1292 | difficulty =-1; |
robinmc | 3:4b254b4bd6d4 | 1293 | score=30; |
robinmc | 2:158d57cdbf1e | 1294 | Game(); |
robinmc | 3:4b254b4bd6d4 | 1295 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1296 | lcd.printString("Great!!!",0,0); |
robinmc | 2:158d57cdbf1e | 1297 | lcd.printString("To shoot press",0,1); |
robinmc | 2:158d57cdbf1e | 1298 | lcd.printString("A, but watch",0,2); |
robinmc | 2:158d57cdbf1e | 1299 | lcd.printString("out you...",0,3); |
robinmc | 2:158d57cdbf1e | 1300 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1301 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1302 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1303 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1304 | while (1) { |
robinmc | 2:158d57cdbf1e | 1305 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1306 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1307 | break; |
robinmc | 2:158d57cdbf1e | 1308 | } |
robinmc | 3:4b254b4bd6d4 | 1309 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1310 | } |
robinmc | 3:4b254b4bd6d4 | 1311 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1312 | lcd.printString("... might use",0,0); |
robinmc | 2:158d57cdbf1e | 1313 | lcd.printString("all your ammo",0,1); |
robinmc | 2:158d57cdbf1e | 1314 | lcd.printString("Give it a go!",0,3); |
robinmc | 2:158d57cdbf1e | 1315 | lcd.printString("Okay>>",30,5); |
robinmc | 2:158d57cdbf1e | 1316 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1317 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1318 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1319 | while (1) { |
robinmc | 2:158d57cdbf1e | 1320 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1321 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1322 | break; |
robinmc | 2:158d57cdbf1e | 1323 | } |
robinmc | 3:4b254b4bd6d4 | 1324 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1325 | } |
robinmc | 3:4b254b4bd6d4 | 1326 | //sets the difficulty to -1, no interactive elements in the game |
robinmc | 3:4b254b4bd6d4 | 1327 | //this allows the player to try the game contolls |
robinmc | 2:158d57cdbf1e | 1328 | difficulty =-1; |
robinmc | 2:158d57cdbf1e | 1329 | Game(); |
robinmc | 3:4b254b4bd6d4 | 1330 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1331 | lcd.printString("Remember you",0,0); |
robinmc | 2:158d57cdbf1e | 1332 | lcd.printString("can also shoot",0,1); |
robinmc | 2:158d57cdbf1e | 1333 | lcd.printString("while jumping",0,2); |
robinmc | 2:158d57cdbf1e | 1334 | lcd.printString("and crouching",0,3); |
robinmc | 2:158d57cdbf1e | 1335 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1336 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1337 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1338 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1339 | while (1) { |
robinmc | 2:158d57cdbf1e | 1340 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1341 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1342 | break; |
robinmc | 2:158d57cdbf1e | 1343 | } |
robinmc | 3:4b254b4bd6d4 | 1344 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1345 | } |
robinmc | 3:4b254b4bd6d4 | 1346 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1347 | lcd.printString("Information",0,0); |
robinmc | 2:158d57cdbf1e | 1348 | lcd.printString("about your",0,1); |
robinmc | 2:158d57cdbf1e | 1349 | lcd.printString("status (ammo",0,2); |
robinmc | 2:158d57cdbf1e | 1350 | lcd.printString("and score) ...",0,3); |
robinmc | 2:158d57cdbf1e | 1351 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1352 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1353 | ticker_wait(10);; |
robinmc | 2:158d57cdbf1e | 1354 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1355 | while (1) { |
robinmc | 2:158d57cdbf1e | 1356 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1357 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1358 | break; |
robinmc | 2:158d57cdbf1e | 1359 | } |
robinmc | 3:4b254b4bd6d4 | 1360 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1361 | } |
robinmc | 3:4b254b4bd6d4 | 1362 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1363 | lcd.printString("... is shown",0,0); |
robinmc | 2:158d57cdbf1e | 1364 | lcd.printString("above, and the",0,1); |
robinmc | 2:158d57cdbf1e | 1365 | lcd.printString("number",0,2); |
robinmc | 2:158d57cdbf1e | 1366 | lcd.printString("lives you ...",0,3); |
robinmc | 2:158d57cdbf1e | 1367 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1368 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1369 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1370 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1371 | while (1) { |
robinmc | 2:158d57cdbf1e | 1372 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1373 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1374 | break; |
robinmc | 2:158d57cdbf1e | 1375 | } |
robinmc | 3:4b254b4bd6d4 | 1376 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1377 | } |
robinmc | 3:4b254b4bd6d4 | 1378 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1379 | lcd.printString("... have is",0,0); |
robinmc | 2:158d57cdbf1e | 1380 | lcd.printString("displayed on",0,1); |
robinmc | 2:158d57cdbf1e | 1381 | lcd.printString("the LED bar,",0,2); |
robinmc | 2:158d57cdbf1e | 1382 | lcd.printString("when they...",0,3); |
robinmc | 2:158d57cdbf1e | 1383 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1384 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1385 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1386 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1387 | while (1) { |
robinmc | 2:158d57cdbf1e | 1388 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1389 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1390 | break; |
robinmc | 2:158d57cdbf1e | 1391 | } |
robinmc | 3:4b254b4bd6d4 | 1392 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1393 | } |
robinmc | 3:4b254b4bd6d4 | 1394 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1395 | lcd.printString("... all turn",0,0); |
robinmc | 2:158d57cdbf1e | 1396 | lcd.printString("off you will",0,1); |
robinmc | 2:158d57cdbf1e | 1397 | lcd.printString("die, so make",0,2); |
robinmc | 2:158d57cdbf1e | 1398 | lcd.printString("sure that...",0,3); |
robinmc | 2:158d57cdbf1e | 1399 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1400 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1401 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1402 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1403 | while (1) { |
robinmc | 2:158d57cdbf1e | 1404 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1405 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1406 | break; |
robinmc | 2:158d57cdbf1e | 1407 | } |
robinmc | 3:4b254b4bd6d4 | 1408 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1409 | } |
robinmc | 3:4b254b4bd6d4 | 1410 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1411 | lcd.printString("... it doesn't",0,0); |
robinmc | 2:158d57cdbf1e | 1412 | lcd.printString("happen!!!",0,1); |
robinmc | 2:158d57cdbf1e | 1413 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1414 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1415 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1416 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1417 | while (1) { |
robinmc | 2:158d57cdbf1e | 1418 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1419 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1420 | break; |
robinmc | 2:158d57cdbf1e | 1421 | } |
robinmc | 3:4b254b4bd6d4 | 1422 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1423 | } |
robinmc | 3:4b254b4bd6d4 | 1424 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1425 | lcd.printString("Excellent!!!",0,0); |
robinmc | 2:158d57cdbf1e | 1426 | lcd.printString("Your training",0,1); |
robinmc | 2:158d57cdbf1e | 1427 | lcd.printString("is over",0,2); |
robinmc | 2:158d57cdbf1e | 1428 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1429 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1430 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1431 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1432 | while (1) { |
robinmc | 2:158d57cdbf1e | 1433 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1434 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1435 | break; |
robinmc | 2:158d57cdbf1e | 1436 | } |
robinmc | 3:4b254b4bd6d4 | 1437 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1438 | } |
robinmc | 3:4b254b4bd6d4 | 1439 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1440 | lcd.printString("Are you ready",0,0); |
robinmc | 2:158d57cdbf1e | 1441 | lcd.printString("for your first",0,1); |
robinmc | 2:158d57cdbf1e | 1442 | lcd.printString("mission?",0,2); |
robinmc | 2:158d57cdbf1e | 1443 | lcd.printString("Yes!!!>>",24,5); |
robinmc | 2:158d57cdbf1e | 1444 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1445 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1446 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1447 | while (1) { |
robinmc | 2:158d57cdbf1e | 1448 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1449 | g_press_b_A_flag=0; |
robinmc | 3:4b254b4bd6d4 | 1450 | //Increses story_pregress |
robinmc | 2:158d57cdbf1e | 1451 | story_progress=2; |
robinmc | 3:4b254b4bd6d4 | 1452 | //autosaves progress |
robinmc | 2:158d57cdbf1e | 1453 | writeSD_progress(); |
robinmc | 2:158d57cdbf1e | 1454 | break; |
robinmc | 2:158d57cdbf1e | 1455 | } |
robinmc | 3:4b254b4bd6d4 | 1456 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1457 | } |
robinmc | 2:158d57cdbf1e | 1458 | } |
robinmc | 2:158d57cdbf1e | 1459 | |
robinmc | 2:158d57cdbf1e | 1460 | void Chapter1() |
robinmc | 2:158d57cdbf1e | 1461 | { |
robinmc | 3:4b254b4bd6d4 | 1462 | //Introduce story |
robinmc | 3:4b254b4bd6d4 | 1463 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1464 | lcd.printString("150+ MISSIONS",0,1); |
robinmc | 2:158d57cdbf1e | 1465 | lcd.printString("LATER",18,2); |
robinmc | 2:158d57cdbf1e | 1466 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1467 | ticker_wait(20); |
robinmc | 3:4b254b4bd6d4 | 1468 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1469 | lcd.printString("MISSION #158:",0,0); |
robinmc | 2:158d57cdbf1e | 1470 | lcd.printString("We have intel",0,1); |
robinmc | 2:158d57cdbf1e | 1471 | lcd.printString("of a new range",0,2); |
robinmc | 2:158d57cdbf1e | 1472 | lcd.printString("of high tech",0,3); |
robinmc | 2:158d57cdbf1e | 1473 | lcd.printString("military grade",0,4); |
robinmc | 2:158d57cdbf1e | 1474 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1475 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1476 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1477 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1478 | while (1) { |
robinmc | 2:158d57cdbf1e | 1479 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1480 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1481 | break; |
robinmc | 2:158d57cdbf1e | 1482 | } |
robinmc | 3:4b254b4bd6d4 | 1483 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1484 | } |
robinmc | 3:4b254b4bd6d4 | 1485 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1486 | lcd.printString("weapons being",0,0); |
robinmc | 2:158d57cdbf1e | 1487 | lcd.printString("developed in",0,1); |
robinmc | 2:158d57cdbf1e | 1488 | lcd.printString("a remote",0,2); |
robinmc | 2:158d57cdbf1e | 1489 | lcd.printString("island in the",0,3); |
robinmc | 2:158d57cdbf1e | 1490 | lcd.printString("South...",0,4); |
robinmc | 2:158d57cdbf1e | 1491 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1492 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1493 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1494 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1495 | while (1) { |
robinmc | 2:158d57cdbf1e | 1496 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1497 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1498 | break; |
robinmc | 2:158d57cdbf1e | 1499 | } |
robinmc | 3:4b254b4bd6d4 | 1500 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1501 | } |
robinmc | 2:158d57cdbf1e | 1502 | ticker_wait(10); |
robinmc | 3:4b254b4bd6d4 | 1503 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1504 | lcd.printString("... Pacific.",0,0); |
robinmc | 2:158d57cdbf1e | 1505 | lcd.printString("Your mission",0,1); |
robinmc | 2:158d57cdbf1e | 1506 | lcd.printString("is to",0,2); |
robinmc | 2:158d57cdbf1e | 1507 | lcd.printString("infiltrate the",0,3); |
robinmc | 2:158d57cdbf1e | 1508 | lcd.printString("island and...",0,4); |
robinmc | 2:158d57cdbf1e | 1509 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1510 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1511 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1512 | while (1) { |
robinmc | 2:158d57cdbf1e | 1513 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1514 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1515 | break; |
robinmc | 2:158d57cdbf1e | 1516 | } |
robinmc | 3:4b254b4bd6d4 | 1517 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1518 | } |
robinmc | 2:158d57cdbf1e | 1519 | ticker_wait(10); |
robinmc | 3:4b254b4bd6d4 | 1520 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1521 | lcd.printString("... destroy",0,0); |
robinmc | 2:158d57cdbf1e | 1522 | lcd.printString("as many of",0,1); |
robinmc | 2:158d57cdbf1e | 1523 | lcd.printString("the weapons as",0,2); |
robinmc | 2:158d57cdbf1e | 1524 | lcd.printString("you can. Are",0,3); |
robinmc | 2:158d57cdbf1e | 1525 | lcd.printString("you ready?",0,4); |
robinmc | 2:158d57cdbf1e | 1526 | lcd.printString("Yes!!>>",24,5); |
robinmc | 2:158d57cdbf1e | 1527 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1528 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1529 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1530 | while (1) { |
robinmc | 2:158d57cdbf1e | 1531 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1532 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1533 | break; |
robinmc | 2:158d57cdbf1e | 1534 | } |
robinmc | 3:4b254b4bd6d4 | 1535 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1536 | } |
robinmc | 2:158d57cdbf1e | 1537 | ticker_wait(10); |
robinmc | 3:4b254b4bd6d4 | 1538 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1539 | lcd.printString("Excellent, you",0,0); |
robinmc | 2:158d57cdbf1e | 1540 | lcd.printString("will land on",0,1); |
robinmc | 2:158d57cdbf1e | 1541 | lcd.printString("the farside of",0,2); |
robinmc | 2:158d57cdbf1e | 1542 | lcd.printString("the island and",0,3); |
robinmc | 2:158d57cdbf1e | 1543 | lcd.printString("work your...",0,4); |
robinmc | 2:158d57cdbf1e | 1544 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1545 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1546 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1547 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1548 | while (1) { |
robinmc | 2:158d57cdbf1e | 1549 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1550 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1551 | break; |
robinmc | 2:158d57cdbf1e | 1552 | } |
robinmc | 3:4b254b4bd6d4 | 1553 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1554 | } |
robinmc | 2:158d57cdbf1e | 1555 | ticker_wait(10); |
robinmc | 3:4b254b4bd6d4 | 1556 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1557 | lcd.printString("...way towards",0,0); |
robinmc | 2:158d57cdbf1e | 1558 | lcd.printString("the centre the",0,1); |
robinmc | 2:158d57cdbf1e | 1559 | lcd.printString("closer you get",0,2); |
robinmc | 2:158d57cdbf1e | 1560 | lcd.printString("the more",0,3); |
robinmc | 2:158d57cdbf1e | 1561 | lcd.printString("defences...",0,4); |
robinmc | 2:158d57cdbf1e | 1562 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1563 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1564 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1565 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1566 | while (1) { |
robinmc | 2:158d57cdbf1e | 1567 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1568 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1569 | break; |
robinmc | 2:158d57cdbf1e | 1570 | } |
robinmc | 3:4b254b4bd6d4 | 1571 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1572 | } |
robinmc | 2:158d57cdbf1e | 1573 | ticker_wait(20); |
robinmc | 3:4b254b4bd6d4 | 1574 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1575 | lcd.printString("they'll have.",0,0); |
robinmc | 2:158d57cdbf1e | 1576 | lcd.printString("For now you",0,1); |
robinmc | 2:158d57cdbf1e | 1577 | lcd.printString("need to look",0,2); |
robinmc | 2:158d57cdbf1e | 1578 | lcd.printString("out for the",0,3); |
robinmc | 2:158d57cdbf1e | 1579 | lcd.printString("cacti they...",0,4); |
robinmc | 2:158d57cdbf1e | 1580 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1581 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1582 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1583 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1584 | while (1) { |
robinmc | 2:158d57cdbf1e | 1585 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1586 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1587 | break; |
robinmc | 2:158d57cdbf1e | 1588 | } |
robinmc | 3:4b254b4bd6d4 | 1589 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1590 | } |
robinmc | 2:158d57cdbf1e | 1591 | |
robinmc | 2:158d57cdbf1e | 1592 | ticker_wait(20); |
robinmc | 3:4b254b4bd6d4 | 1593 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1594 | lcd.printString("if you touch",0,0); |
robinmc | 2:158d57cdbf1e | 1595 | lcd.printString("one you'll",0,1); |
robinmc | 2:158d57cdbf1e | 1596 | lcd.printString("lose a life so",0,2); |
robinmc | 2:158d57cdbf1e | 1597 | lcd.printString("jump over...",0,3); |
robinmc | 2:158d57cdbf1e | 1598 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1599 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1600 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1601 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1602 | while (1) { |
robinmc | 2:158d57cdbf1e | 1603 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1604 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1605 | break; |
robinmc | 2:158d57cdbf1e | 1606 | } |
robinmc | 3:4b254b4bd6d4 | 1607 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1608 | } |
robinmc | 2:158d57cdbf1e | 1609 | ticker_wait(20); |
robinmc | 3:4b254b4bd6d4 | 1610 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1611 | lcd.printString("...them, also,",0,0); |
robinmc | 2:158d57cdbf1e | 1612 | lcd.printString("watch out for",0,1); |
robinmc | 2:158d57cdbf1e | 1613 | lcd.printString("low tech cyber",0,2); |
robinmc | 2:158d57cdbf1e | 1614 | lcd.printString("rats running",0,3); |
robinmc | 2:158d57cdbf1e | 1615 | lcd.printString("around, you'll...",0,4); |
robinmc | 2:158d57cdbf1e | 1616 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1617 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1618 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1619 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1620 | while (1) { |
robinmc | 2:158d57cdbf1e | 1621 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1622 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1623 | break; |
robinmc | 2:158d57cdbf1e | 1624 | } |
robinmc | 3:4b254b4bd6d4 | 1625 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1626 | } |
robinmc | 2:158d57cdbf1e | 1627 | ticker_wait(20); |
robinmc | 3:4b254b4bd6d4 | 1628 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1629 | lcd.printString("have to jump",0,0); |
robinmc | 2:158d57cdbf1e | 1630 | lcd.printString("them aswell",0,1); |
robinmc | 2:158d57cdbf1e | 1631 | lcd.printString("as you cannot",0,2); |
robinmc | 2:158d57cdbf1e | 1632 | lcd.printString("destroy them.",0,3); |
robinmc | 2:158d57cdbf1e | 1633 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1634 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1635 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1636 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1637 | while (1) { |
robinmc | 2:158d57cdbf1e | 1638 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1639 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1640 | break; |
robinmc | 2:158d57cdbf1e | 1641 | } |
robinmc | 3:4b254b4bd6d4 | 1642 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1643 | } |
robinmc | 2:158d57cdbf1e | 1644 | ticker_wait(20); |
robinmc | 3:4b254b4bd6d4 | 1645 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1646 | lcd.printString("That's all you",0,0); |
robinmc | 2:158d57cdbf1e | 1647 | lcd.printString("need to know ",0,1); |
robinmc | 2:158d57cdbf1e | 1648 | lcd.printString("for now. Get",0,2); |
robinmc | 2:158d57cdbf1e | 1649 | lcd.printString("to work and",0,3); |
robinmc | 2:158d57cdbf1e | 1650 | lcd.printString("Good Luck!!!",0,4); |
robinmc | 2:158d57cdbf1e | 1651 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1652 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1653 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1654 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1655 | while (1) { |
robinmc | 2:158d57cdbf1e | 1656 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1657 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1658 | break; |
robinmc | 2:158d57cdbf1e | 1659 | } |
robinmc | 3:4b254b4bd6d4 | 1660 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1661 | } |
robinmc | 3:4b254b4bd6d4 | 1662 | //sets the difficulty to 0, only cactus and rats |
robinmc | 3:4b254b4bd6d4 | 1663 | //this allows the player to try the game contolls |
robinmc | 2:158d57cdbf1e | 1664 | difficulty=0; |
robinmc | 2:158d57cdbf1e | 1665 | Game(); |
robinmc | 3:4b254b4bd6d4 | 1666 | //innreases the story progress to 3 |
robinmc | 2:158d57cdbf1e | 1667 | story_progress=3; |
robinmc | 3:4b254b4bd6d4 | 1668 | //autosaves progress |
robinmc | 2:158d57cdbf1e | 1669 | writeSD_progress(); |
robinmc | 3:4b254b4bd6d4 | 1670 | //prints post game message |
robinmc | 3:4b254b4bd6d4 | 1671 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1672 | lcd.printString("Well done!!!",0,0); |
robinmc | 2:158d57cdbf1e | 1673 | lcd.printString("Oh no...",0,1); |
robinmc | 2:158d57cdbf1e | 1674 | lcd.printString("It looks like",0,2); |
robinmc | 2:158d57cdbf1e | 1675 | lcd.printString("things are",0,3); |
robinmc | 2:158d57cdbf1e | 1676 | lcd.printString("steping up",0,4); |
robinmc | 2:158d57cdbf1e | 1677 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1678 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1679 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1680 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1681 | while (1) { |
robinmc | 2:158d57cdbf1e | 1682 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1683 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1684 | break; |
robinmc | 2:158d57cdbf1e | 1685 | } |
robinmc | 3:4b254b4bd6d4 | 1686 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1687 | } |
robinmc | 2:158d57cdbf1e | 1688 | } |
robinmc | 2:158d57cdbf1e | 1689 | |
robinmc | 2:158d57cdbf1e | 1690 | void Chapter2() |
robinmc | 2:158d57cdbf1e | 1691 | { |
robinmc | 3:4b254b4bd6d4 | 1692 | //Continuing the story, indroducing more mobs |
robinmc | 3:4b254b4bd6d4 | 1693 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1694 | lcd.printString("Now you'll",0,0); |
robinmc | 2:158d57cdbf1e | 1695 | lcd.printString("encounter",0,1); |
robinmc | 2:158d57cdbf1e | 1696 | lcd.printString("robotic birds",0,2); |
robinmc | 2:158d57cdbf1e | 1697 | lcd.printString("and robotic",0,3); |
robinmc | 2:158d57cdbf1e | 1698 | lcd.printString("hounds aswell.",0,4); |
robinmc | 2:158d57cdbf1e | 1699 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1700 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1701 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1702 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1703 | while (1) { |
robinmc | 2:158d57cdbf1e | 1704 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1705 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1706 | break; |
robinmc | 2:158d57cdbf1e | 1707 | } |
robinmc | 3:4b254b4bd6d4 | 1708 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1709 | } |
robinmc | 3:4b254b4bd6d4 | 1710 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1711 | lcd.printString("Watch out for",0,0); |
robinmc | 2:158d57cdbf1e | 1712 | lcd.printString("the birds as",0,1); |
robinmc | 2:158d57cdbf1e | 1713 | lcd.printString("they may swoop",0,2); |
robinmc | 2:158d57cdbf1e | 1714 | lcd.printString("and the hounds",0,3); |
robinmc | 2:158d57cdbf1e | 1715 | lcd.printString("will pounce",0,4); |
robinmc | 2:158d57cdbf1e | 1716 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1717 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1718 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1719 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1720 | while (1) { |
robinmc | 2:158d57cdbf1e | 1721 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1722 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1723 | break; |
robinmc | 2:158d57cdbf1e | 1724 | } |
robinmc | 3:4b254b4bd6d4 | 1725 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1726 | } |
robinmc | 3:4b254b4bd6d4 | 1727 | //Set difficulty to 1. Hounds and birds also appear |
robinmc | 2:158d57cdbf1e | 1728 | difficulty=1; |
robinmc | 2:158d57cdbf1e | 1729 | Game(); |
robinmc | 3:4b254b4bd6d4 | 1730 | //When compleated it increases story_progress to 4 |
robinmc | 2:158d57cdbf1e | 1731 | story_progress=4; |
robinmc | 3:4b254b4bd6d4 | 1732 | //autosaves progress |
robinmc | 2:158d57cdbf1e | 1733 | writeSD_progress(); |
robinmc | 3:4b254b4bd6d4 | 1734 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1735 | lcd.printString("Oh dear...",0,0); |
robinmc | 2:158d57cdbf1e | 1736 | lcd.printString("There is more",0,1); |
robinmc | 2:158d57cdbf1e | 1737 | lcd.printString("trouble ahead",0,2); |
robinmc | 2:158d57cdbf1e | 1738 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1739 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1740 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1741 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1742 | while (1) { |
robinmc | 2:158d57cdbf1e | 1743 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1744 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1745 | break; |
robinmc | 2:158d57cdbf1e | 1746 | } |
robinmc | 3:4b254b4bd6d4 | 1747 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1748 | } |
robinmc | 2:158d57cdbf1e | 1749 | } |
robinmc | 2:158d57cdbf1e | 1750 | |
robinmc | 2:158d57cdbf1e | 1751 | void Chapter3() |
robinmc | 2:158d57cdbf1e | 1752 | { |
robinmc | 3:4b254b4bd6d4 | 1753 | //Continuing the story, indroducing more mobs |
robinmc | 3:4b254b4bd6d4 | 1754 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1755 | lcd.printString("It looks like",0,0); |
robinmc | 2:158d57cdbf1e | 1756 | lcd.printString("there is some",0,1); |
robinmc | 2:158d57cdbf1e | 1757 | lcd.printString("sort of",0,2); |
robinmc | 2:158d57cdbf1e | 1758 | lcd.printString("bionic bear!!",0,3); |
robinmc | 2:158d57cdbf1e | 1759 | lcd.printString("You better...",0,4); |
robinmc | 2:158d57cdbf1e | 1760 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1761 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1762 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1763 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1764 | while (1) { |
robinmc | 2:158d57cdbf1e | 1765 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1766 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1767 | break; |
robinmc | 2:158d57cdbf1e | 1768 | } |
robinmc | 3:4b254b4bd6d4 | 1769 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1770 | } |
robinmc | 3:4b254b4bd6d4 | 1771 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1772 | lcd.printString("... watch out",0,0); |
robinmc | 2:158d57cdbf1e | 1773 | lcd.printString("it looks like",0,1); |
robinmc | 2:158d57cdbf1e | 1774 | lcd.printString("it will be",0,2); |
robinmc | 2:158d57cdbf1e | 1775 | lcd.printString("able to",0,3); |
robinmc | 2:158d57cdbf1e | 1776 | lcd.printString("withstand...",0,4); |
robinmc | 2:158d57cdbf1e | 1777 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1778 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1779 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1780 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1781 | while (1) { |
robinmc | 2:158d57cdbf1e | 1782 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1783 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1784 | break; |
robinmc | 2:158d57cdbf1e | 1785 | } |
robinmc | 3:4b254b4bd6d4 | 1786 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1787 | } |
robinmc | 3:4b254b4bd6d4 | 1788 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1789 | lcd.printString("a few shots",0,0); |
robinmc | 2:158d57cdbf1e | 1790 | lcd.printString("before",0,1); |
robinmc | 2:158d57cdbf1e | 1791 | lcd.printString("destroying it",0,2); |
robinmc | 2:158d57cdbf1e | 1792 | lcd.printString("4 hits should",0,3); |
robinmc | 2:158d57cdbf1e | 1793 | lcd.printString("do it. GO!",0,4); |
robinmc | 2:158d57cdbf1e | 1794 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1795 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1796 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1797 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1798 | while (1) { |
robinmc | 2:158d57cdbf1e | 1799 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1800 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1801 | break; |
robinmc | 2:158d57cdbf1e | 1802 | } |
robinmc | 3:4b254b4bd6d4 | 1803 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1804 | } |
robinmc | 3:4b254b4bd6d4 | 1805 | //Set difficulty to 2. Bears will appear |
robinmc | 2:158d57cdbf1e | 1806 | difficulty=2; |
robinmc | 2:158d57cdbf1e | 1807 | Game(); |
robinmc | 3:4b254b4bd6d4 | 1808 | //Increases story progress |
robinmc | 2:158d57cdbf1e | 1809 | story_progress=5; |
robinmc | 3:4b254b4bd6d4 | 1810 | //Autosaves game |
robinmc | 2:158d57cdbf1e | 1811 | writeSD_progress(); |
robinmc | 3:4b254b4bd6d4 | 1812 | //Post game message |
robinmc | 3:4b254b4bd6d4 | 1813 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1814 | lcd.printString("OH DEAR",0,0); |
robinmc | 2:158d57cdbf1e | 1815 | lcd.printString("LORD...",0,1); |
robinmc | 2:158d57cdbf1e | 1816 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1817 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1818 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1819 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1820 | while (1) { |
robinmc | 2:158d57cdbf1e | 1821 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1822 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1823 | break; |
robinmc | 2:158d57cdbf1e | 1824 | } |
robinmc | 3:4b254b4bd6d4 | 1825 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1826 | } |
robinmc | 2:158d57cdbf1e | 1827 | } |
robinmc | 2:158d57cdbf1e | 1828 | |
robinmc | 2:158d57cdbf1e | 1829 | void Chapter4() |
robinmc | 2:158d57cdbf1e | 1830 | { |
robinmc | 3:4b254b4bd6d4 | 1831 | ////Continuing the story, indroducing final boss |
robinmc | 2:158d57cdbf1e | 1832 | g_press_b_A_flag=0; |
robinmc | 3:4b254b4bd6d4 | 1833 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1834 | lcd.printString("You won't",0,0); |
robinmc | 2:158d57cdbf1e | 1835 | lcd.printString("beleve this",0,1); |
robinmc | 2:158d57cdbf1e | 1836 | lcd.printString("it's it's...",0,2); |
robinmc | 2:158d57cdbf1e | 1837 | lcd.printString("it can't be",0,3); |
robinmc | 2:158d57cdbf1e | 1838 | lcd.printString("it's not...",0,4); |
robinmc | 2:158d57cdbf1e | 1839 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1840 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1841 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1842 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1843 | while (1) { |
robinmc | 2:158d57cdbf1e | 1844 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1845 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1846 | break; |
robinmc | 2:158d57cdbf1e | 1847 | } |
robinmc | 3:4b254b4bd6d4 | 1848 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1849 | } |
robinmc | 3:4b254b4bd6d4 | 1850 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1851 | lcd.printString("it's not",0,0); |
robinmc | 2:158d57cdbf1e | 1852 | lcd.printString("possible...",0,1); |
robinmc | 2:158d57cdbf1e | 1853 | lcd.printString("It's a T Rex,",0,2); |
robinmc | 2:158d57cdbf1e | 1854 | lcd.printString("a robotic",0,3); |
robinmc | 2:158d57cdbf1e | 1855 | lcd.printString("T Rex!!!!",0,4); |
robinmc | 2:158d57cdbf1e | 1856 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1857 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1858 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1859 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1860 | while (1) { |
robinmc | 2:158d57cdbf1e | 1861 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1862 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1863 | break; |
robinmc | 2:158d57cdbf1e | 1864 | } |
robinmc | 3:4b254b4bd6d4 | 1865 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1866 | } |
robinmc | 3:4b254b4bd6d4 | 1867 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1868 | lcd.printString("It's it's...",0,0); |
robinmc | 2:158d57cdbf1e | 1869 | lcd.printString("it's",0,1); |
robinmc | 2:158d57cdbf1e | 1870 | lcd.printString("breathing",0,2); |
robinmc | 2:158d57cdbf1e | 1871 | lcd.printString("fire!!!",0,3); |
robinmc | 2:158d57cdbf1e | 1872 | lcd.printString("It looks...",0,4); |
robinmc | 2:158d57cdbf1e | 1873 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1874 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1875 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1876 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1877 | while (1) { |
robinmc | 2:158d57cdbf1e | 1878 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1879 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1880 | break; |
robinmc | 2:158d57cdbf1e | 1881 | } |
robinmc | 3:4b254b4bd6d4 | 1882 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1883 | } |
robinmc | 3:4b254b4bd6d4 | 1884 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1885 | lcd.printString("... like it",0,0); |
robinmc | 2:158d57cdbf1e | 1886 | lcd.printString("will only",0,1); |
robinmc | 2:158d57cdbf1e | 1887 | lcd.printString("take damage",0,2); |
robinmc | 2:158d57cdbf1e | 1888 | lcd.printString("when it's",0,3); |
robinmc | 2:158d57cdbf1e | 1889 | lcd.printString("attacking...",0,4); |
robinmc | 2:158d57cdbf1e | 1890 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1891 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1892 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1893 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1894 | while (1) { |
robinmc | 2:158d57cdbf1e | 1895 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1896 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1897 | break; |
robinmc | 2:158d57cdbf1e | 1898 | } |
robinmc | 3:4b254b4bd6d4 | 1899 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1900 | } |
robinmc | 3:4b254b4bd6d4 | 1901 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1902 | lcd.printString("and I think",0,0); |
robinmc | 2:158d57cdbf1e | 1903 | lcd.printString("you'll have",0,1); |
robinmc | 2:158d57cdbf1e | 1904 | lcd.printString("to shoot it",0,2); |
robinmc | 2:158d57cdbf1e | 1905 | lcd.printString("at least 8",0,3); |
robinmc | 2:158d57cdbf1e | 1906 | lcd.printString("times to...",0,4); |
robinmc | 2:158d57cdbf1e | 1907 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1908 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1909 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1910 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1911 | while (1) { |
robinmc | 2:158d57cdbf1e | 1912 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1913 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1914 | break; |
robinmc | 2:158d57cdbf1e | 1915 | } |
robinmc | 3:4b254b4bd6d4 | 1916 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1917 | } |
robinmc | 3:4b254b4bd6d4 | 1918 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1919 | lcd.printString("...destroy it",0,0); |
robinmc | 2:158d57cdbf1e | 1920 | lcd.printString("I'll drop",0,1); |
robinmc | 2:158d57cdbf1e | 1921 | lcd.printString("some ammo",0,2); |
robinmc | 2:158d57cdbf1e | 1922 | lcd.printString("for you.",0,3); |
robinmc | 2:158d57cdbf1e | 1923 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1924 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1925 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1926 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1927 | while (1) { |
robinmc | 2:158d57cdbf1e | 1928 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1929 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1930 | break; |
robinmc | 2:158d57cdbf1e | 1931 | } |
robinmc | 3:4b254b4bd6d4 | 1932 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1933 | } |
robinmc | 3:4b254b4bd6d4 | 1934 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1935 | lcd.printString("Good Luck",0,0); |
robinmc | 2:158d57cdbf1e | 1936 | lcd.printString("You'll need",0,1); |
robinmc | 2:158d57cdbf1e | 1937 | lcd.printString("it",0,2); |
robinmc | 2:158d57cdbf1e | 1938 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1939 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1940 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 1941 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1942 | while (1) { |
robinmc | 2:158d57cdbf1e | 1943 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1944 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1945 | break; |
robinmc | 2:158d57cdbf1e | 1946 | } |
robinmc | 3:4b254b4bd6d4 | 1947 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1948 | } |
robinmc | 2:158d57cdbf1e | 1949 | difficulty=3; |
robinmc | 2:158d57cdbf1e | 1950 | Game(); |
robinmc | 2:158d57cdbf1e | 1951 | initialize_values(); |
robinmc | 2:158d57cdbf1e | 1952 | if (g_story_mode_win) { |
robinmc | 3:4b254b4bd6d4 | 1953 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 1954 | lcd.printString("Well done",0,0); |
robinmc | 2:158d57cdbf1e | 1955 | lcd.printString("Recks",0,1); |
robinmc | 2:158d57cdbf1e | 1956 | lcd.printString("Lets clear",0,2); |
robinmc | 2:158d57cdbf1e | 1957 | lcd.printString("get you home",0,3); |
robinmc | 2:158d57cdbf1e | 1958 | lcd.printString("Press A>>",24,5); |
robinmc | 2:158d57cdbf1e | 1959 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1960 | ticker_wait(30); |
robinmc | 2:158d57cdbf1e | 1961 | } |
robinmc | 2:158d57cdbf1e | 1962 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1963 | while (1) { |
robinmc | 2:158d57cdbf1e | 1964 | if (g_press_b_A_flag) { |
robinmc | 2:158d57cdbf1e | 1965 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 1966 | break; |
robinmc | 2:158d57cdbf1e | 1967 | } |
robinmc | 3:4b254b4bd6d4 | 1968 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 1969 | } |
robinmc | 2:158d57cdbf1e | 1970 | } |
robinmc | 2:158d57cdbf1e | 1971 | |
robinmc | 3:4b254b4bd6d4 | 1972 | //Funtion that inverst the pixels and stops the game for 0.5s when a life is lost |
robinmc | 2:158d57cdbf1e | 1973 | void freeze() |
robinmc | 2:158d57cdbf1e | 1974 | { |
robinmc | 3:4b254b4bd6d4 | 1975 | lcd.inverseMode(); //invert pixels |
robinmc | 2:158d57cdbf1e | 1976 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 1977 | ticker_wait(5); |
robinmc | 2:158d57cdbf1e | 1978 | lcd.normalMode(); |
robinmc | 2:158d57cdbf1e | 1979 | } |
robinmc | 2:158d57cdbf1e | 1980 | |
robinmc | 3:4b254b4bd6d4 | 1981 | //Print the settings menu |
robinmc | 2:158d57cdbf1e | 1982 | void Settings() |
robinmc | 2:158d57cdbf1e | 1983 | { |
robinmc | 0:28392431dbad | 1984 | menuState=0; |
robinmc | 0:28392431dbad | 1985 | while (1) { |
robinmc | 0:28392431dbad | 1986 | if (g_Ticker_Menu_flag) { |
robinmc | 0:28392431dbad | 1987 | g_Ticker_Menu_flag=0; |
robinmc | 0:28392431dbad | 1988 | updateJoystick(); |
robinmc | 0:28392431dbad | 1989 | menu_select = fsm_settings_menu[menuState].menu_select; // set ouput depending on current state |
robinmc | 0:28392431dbad | 1990 | menuState = fsm_settings_menu[menuState].nextState[joystick.direction]; // when joystick.direction has a vaule of CENTRE/RIGHT/LEFT the state machine input is 0 when it has a value of DOWN it is 0b01 when it has a value of UP is is 0b10 |
robinmc | 3:4b254b4bd6d4 | 1991 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 3:4b254b4bd6d4 | 1992 | //print the options |
robinmc | 0:28392431dbad | 1993 | lcd.printString("Brightness",13,0); |
robinmc | 1:046e66f1ca76 | 1994 | lcd.printString("Difficulty",13,1); |
robinmc | 2:158d57cdbf1e | 1995 | lcd.printString("SD card",13,2); |
robinmc | 2:158d57cdbf1e | 1996 | lcd.printString("Guns",13,3); |
robinmc | 0:28392431dbad | 1997 | for (int i=0; i<85; i++) { //go through every pixel on the x axis |
robinmc | 0:28392431dbad | 1998 | for (int j=menu_select; j<(menu_select+8); j++) { // go through relevant pixels on the y axis |
robinmc | 0:28392431dbad | 1999 | if (lcd.getPixel(i,j)== 0) { //if the pixel is on trun it off |
robinmc | 0:28392431dbad | 2000 | lcd.setPixel(i,j); |
robinmc | 0:28392431dbad | 2001 | } else { |
robinmc | 0:28392431dbad | 2002 | lcd.clearPixel(i,j); //if the pixel is off turn it on |
robinmc | 0:28392431dbad | 2003 | } |
robinmc | 0:28392431dbad | 2004 | } |
robinmc | 0:28392431dbad | 2005 | } |
robinmc | 3:4b254b4bd6d4 | 2006 | //Depending of the selected option, call the respective funtion |
robinmc | 0:28392431dbad | 2007 | lcd.refresh(); |
robinmc | 0:28392431dbad | 2008 | if (b_A & menu_select==0) { |
robinmc | 2:158d57cdbf1e | 2009 | Brightness(); |
robinmc | 2:158d57cdbf1e | 2010 | return; |
robinmc | 0:28392431dbad | 2011 | } else if (b_A & menu_select==8) { |
robinmc | 2:158d57cdbf1e | 2012 | Difficulty(); |
robinmc | 2:158d57cdbf1e | 2013 | return; |
robinmc | 2:158d57cdbf1e | 2014 | } else if (b_A & menu_select==16) { |
robinmc | 2:158d57cdbf1e | 2015 | Delete_Highscores(); |
robinmc | 2:158d57cdbf1e | 2016 | return; |
robinmc | 2:158d57cdbf1e | 2017 | } else if (b_A & menu_select==24) { |
robinmc | 2:158d57cdbf1e | 2018 | guns(); |
robinmc | 2:158d57cdbf1e | 2019 | return; |
robinmc | 1:046e66f1ca76 | 2020 | } |
robinmc | 1:046e66f1ca76 | 2021 | if (b_B) { |
robinmc | 2:158d57cdbf1e | 2022 | menuState=0; |
robinmc | 2:158d57cdbf1e | 2023 | return; |
robinmc | 0:28392431dbad | 2024 | } |
robinmc | 0:28392431dbad | 2025 | } |
robinmc | 0:28392431dbad | 2026 | } |
robinmc | 2:158d57cdbf1e | 2027 | } |
robinmc | 2:158d57cdbf1e | 2028 | |
robinmc | 3:4b254b4bd6d4 | 2029 | //Funtion to choose the difficulty of the game |
robinmc | 2:158d57cdbf1e | 2030 | void Difficulty() |
robinmc | 2:158d57cdbf1e | 2031 | { |
robinmc | 1:046e66f1ca76 | 2032 | menuState=0; |
robinmc | 1:046e66f1ca76 | 2033 | while(1) { |
robinmc | 1:046e66f1ca76 | 2034 | if (g_Ticker_Menu_flag) { |
robinmc | 1:046e66f1ca76 | 2035 | g_Ticker_Menu_flag=0; |
robinmc | 1:046e66f1ca76 | 2036 | updateJoystick(); |
robinmc | 1:046e66f1ca76 | 2037 | menu_select = fsm_main_menu[menuState].menu_select; // set ouput depending on current state |
robinmc | 1:046e66f1ca76 | 2038 | menuState = fsm_main_menu[menuState].nextState[joystick.direction]; // when joystick.direction has a vaule of CENTRE/RIGHT/LEFT the state machine input is 0 when it has a value of DOWN it is 0b01 when it has a value of UP is is 0b10 |
robinmc | 3:4b254b4bd6d4 | 2039 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 3:4b254b4bd6d4 | 2040 | //print all dificulty options |
robinmc | 1:046e66f1ca76 | 2041 | lcd.printString("Piece of Cake",3,0); |
robinmc | 1:046e66f1ca76 | 2042 | lcd.printString("Easy",30,1); |
robinmc | 1:046e66f1ca76 | 2043 | lcd.printString("Regular",23,2); |
robinmc | 1:046e66f1ca76 | 2044 | lcd.printString("Hard",30,3); |
robinmc | 1:046e66f1ca76 | 2045 | lcd.printString("Legendary",15,4); |
robinmc | 1:046e66f1ca76 | 2046 | for (int i=0; i<85; i++) { //go through every pixel on the x axis |
robinmc | 1:046e66f1ca76 | 2047 | for (int j=menu_select; j<(menu_select+8); j++) { // go through relevant pixels on the y axis |
robinmc | 1:046e66f1ca76 | 2048 | if (lcd.getPixel(i,j)== 0) { //if the pixel is on trun it off |
robinmc | 1:046e66f1ca76 | 2049 | lcd.setPixel(i,j); |
robinmc | 1:046e66f1ca76 | 2050 | } else { |
robinmc | 1:046e66f1ca76 | 2051 | lcd.clearPixel(i,j); //if the pixel is off turn it on |
robinmc | 1:046e66f1ca76 | 2052 | } |
robinmc | 1:046e66f1ca76 | 2053 | } |
robinmc | 1:046e66f1ca76 | 2054 | } |
robinmc | 3:4b254b4bd6d4 | 2055 | //Depending on the option chosen set the difficulty to a certain value, the higher the value the higher the dificulty and return to main menu |
robinmc | 1:046e66f1ca76 | 2056 | lcd.refresh(); |
robinmc | 1:046e66f1ca76 | 2057 | if (b_A & menu_select==0) { |
robinmc | 1:046e66f1ca76 | 2058 | difficulty=0; |
robinmc | 2:158d57cdbf1e | 2059 | return; |
robinmc | 1:046e66f1ca76 | 2060 | } else if (b_A & menu_select==8) { |
robinmc | 1:046e66f1ca76 | 2061 | difficulty=1; |
robinmc | 2:158d57cdbf1e | 2062 | return; |
robinmc | 1:046e66f1ca76 | 2063 | } else if (b_A & menu_select==16) { |
robinmc | 1:046e66f1ca76 | 2064 | difficulty=2; |
robinmc | 2:158d57cdbf1e | 2065 | return; |
robinmc | 1:046e66f1ca76 | 2066 | } else if (b_A & menu_select==24) { |
robinmc | 1:046e66f1ca76 | 2067 | difficulty=3; |
robinmc | 2:158d57cdbf1e | 2068 | return; |
robinmc | 1:046e66f1ca76 | 2069 | } else if (b_A & menu_select==32) { |
robinmc | 1:046e66f1ca76 | 2070 | difficulty=4; |
robinmc | 2:158d57cdbf1e | 2071 | return; |
robinmc | 2:158d57cdbf1e | 2072 | } |
robinmc | 2:158d57cdbf1e | 2073 | if (b_B) { |
robinmc | 2:158d57cdbf1e | 2074 | menuState=0; |
robinmc | 2:158d57cdbf1e | 2075 | return; |
robinmc | 2:158d57cdbf1e | 2076 | } |
robinmc | 2:158d57cdbf1e | 2077 | } |
robinmc | 3:4b254b4bd6d4 | 2078 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 2079 | } |
robinmc | 2:158d57cdbf1e | 2080 | } |
robinmc | 2:158d57cdbf1e | 2081 | |
robinmc | 3:4b254b4bd6d4 | 2082 | //Menu to chose brightness |
robinmc | 2:158d57cdbf1e | 2083 | void Brightness() |
robinmc | 2:158d57cdbf1e | 2084 | { |
robinmc | 2:158d57cdbf1e | 2085 | menuState=0; |
robinmc | 2:158d57cdbf1e | 2086 | while(1) { |
robinmc | 2:158d57cdbf1e | 2087 | if (g_Ticker_Menu_flag) { |
robinmc | 2:158d57cdbf1e | 2088 | g_Ticker_Menu_flag=0; |
robinmc | 2:158d57cdbf1e | 2089 | updateJoystick(); |
robinmc | 2:158d57cdbf1e | 2090 | menu_select = fsm_main_menu[menuState].menu_select; // set ouput depending on current state |
robinmc | 2:158d57cdbf1e | 2091 | menuState = fsm_main_menu[menuState].nextState[joystick.direction]; // when joystick.direction has a vaule of CENTRE/RIGHT/LEFT the state machine input is 0 when it has a value of DOWN it is 0b01 when it has a value of UP is is 0b10 |
robinmc | 3:4b254b4bd6d4 | 2092 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 3:4b254b4bd6d4 | 2093 | //Print brightness options |
robinmc | 2:158d57cdbf1e | 2094 | lcd.printString("Dark",30,0); |
robinmc | 2:158d57cdbf1e | 2095 | lcd.printString("Eco",33,1); |
robinmc | 2:158d57cdbf1e | 2096 | lcd.printString("Regular",23,2); |
robinmc | 2:158d57cdbf1e | 2097 | lcd.printString("Bright",26,3); |
robinmc | 2:158d57cdbf1e | 2098 | lcd.printString("Blinding",20,4); |
robinmc | 2:158d57cdbf1e | 2099 | for (int i=0; i<85; i++) { //go through every pixel on the x axis |
robinmc | 2:158d57cdbf1e | 2100 | for (int j=menu_select; j<(menu_select+8); j++) { // go through relevant pixels on the y axis |
robinmc | 2:158d57cdbf1e | 2101 | if (lcd.getPixel(i,j)== 0) { //if the pixel is on trun it off |
robinmc | 2:158d57cdbf1e | 2102 | lcd.setPixel(i,j); |
robinmc | 2:158d57cdbf1e | 2103 | } else { |
robinmc | 2:158d57cdbf1e | 2104 | lcd.clearPixel(i,j); //if the pixel is off turn it on |
robinmc | 2:158d57cdbf1e | 2105 | } |
robinmc | 2:158d57cdbf1e | 2106 | } |
robinmc | 2:158d57cdbf1e | 2107 | } |
robinmc | 3:4b254b4bd6d4 | 2108 | //Depending on chosen option, set the brightness between 0 anf 1 and return to main menu |
robinmc | 2:158d57cdbf1e | 2109 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 2110 | if (b_A & menu_select==0) { |
robinmc | 2:158d57cdbf1e | 2111 | brightness=0; |
robinmc | 2:158d57cdbf1e | 2112 | return; |
robinmc | 2:158d57cdbf1e | 2113 | } else if (b_A & menu_select==8) { |
robinmc | 2:158d57cdbf1e | 2114 | brightness=0.3; |
robinmc | 2:158d57cdbf1e | 2115 | return; |
robinmc | 2:158d57cdbf1e | 2116 | } else if (b_A & menu_select==16) { |
robinmc | 2:158d57cdbf1e | 2117 | brightness=0.5; |
robinmc | 2:158d57cdbf1e | 2118 | return; |
robinmc | 2:158d57cdbf1e | 2119 | } else if (b_A & menu_select==24) { |
robinmc | 2:158d57cdbf1e | 2120 | brightness=0.7; |
robinmc | 2:158d57cdbf1e | 2121 | return; |
robinmc | 2:158d57cdbf1e | 2122 | } else if (b_A & menu_select==32) { |
robinmc | 2:158d57cdbf1e | 2123 | brightness=1; |
robinmc | 2:158d57cdbf1e | 2124 | return; |
robinmc | 1:046e66f1ca76 | 2125 | } |
robinmc | 1:046e66f1ca76 | 2126 | if (b_B) { |
robinmc | 2:158d57cdbf1e | 2127 | menuState=0; |
robinmc | 2:158d57cdbf1e | 2128 | return; |
robinmc | 2:158d57cdbf1e | 2129 | } |
robinmc | 2:158d57cdbf1e | 2130 | } |
robinmc | 3:4b254b4bd6d4 | 2131 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 2132 | } |
robinmc | 2:158d57cdbf1e | 2133 | } |
robinmc | 2:158d57cdbf1e | 2134 | |
robinmc | 3:4b254b4bd6d4 | 2135 | //Prints the leaderboard |
robinmc | 2:158d57cdbf1e | 2136 | void Leaderboard() |
robinmc | 2:158d57cdbf1e | 2137 | { |
robinmc | 3:4b254b4bd6d4 | 2138 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 3:4b254b4bd6d4 | 2139 | //reads and prints the leaderboard |
robinmc | 2:158d57cdbf1e | 2140 | readSD_and_print_top_score(); |
robinmc | 2:158d57cdbf1e | 2141 | g_press_b_B_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2142 | //if the b_B button is presses return to menu |
robinmc | 2:158d57cdbf1e | 2143 | while(1) { |
robinmc | 2:158d57cdbf1e | 2144 | if (g_press_b_B_flag) { |
robinmc | 2:158d57cdbf1e | 2145 | g_press_b_B_flag=0; |
robinmc | 2:158d57cdbf1e | 2146 | return; |
robinmc | 2:158d57cdbf1e | 2147 | } |
robinmc | 2:158d57cdbf1e | 2148 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 2149 | sleep(); //puts mbed to sleep |
robinmc | 2:158d57cdbf1e | 2150 | } |
robinmc | 2:158d57cdbf1e | 2151 | } |
robinmc | 2:158d57cdbf1e | 2152 | |
robinmc | 3:4b254b4bd6d4 | 2153 | //Print the guns options |
robinmc | 2:158d57cdbf1e | 2154 | void guns() |
robinmc | 2:158d57cdbf1e | 2155 | { |
robinmc | 2:158d57cdbf1e | 2156 | menuState=0; |
robinmc | 2:158d57cdbf1e | 2157 | while(1) { |
robinmc | 2:158d57cdbf1e | 2158 | if (g_Ticker_Menu_flag) { |
robinmc | 2:158d57cdbf1e | 2159 | g_Ticker_Menu_flag=0; |
robinmc | 2:158d57cdbf1e | 2160 | updateJoystick(); |
robinmc | 2:158d57cdbf1e | 2161 | menu_select = fsm_settings_menu[menuState].menu_select; // set ouput depending on current state |
robinmc | 2:158d57cdbf1e | 2162 | menuState = fsm_settings_menu[menuState].nextState[joystick.direction]; // when joystick.direction has a vaule of CENTRE/RIGHT/LEFT the state machine input is 0 when it has a value of DOWN it is 0b01 when it has a value of UP is is 0b10 |
robinmc | 3:4b254b4bd6d4 | 2163 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 3:4b254b4bd6d4 | 2164 | //Print the guns options |
robinmc | 2:158d57cdbf1e | 2165 | lcd.printString("Pistol",10,0); |
robinmc | 2:158d57cdbf1e | 2166 | lcd.printString("Revolver",10,1); |
robinmc | 2:158d57cdbf1e | 2167 | lcd.printString("Rifle",10,2); |
robinmc | 2:158d57cdbf1e | 2168 | lcd.printString("Random",10,3); |
robinmc | 2:158d57cdbf1e | 2169 | for (int i=0; i<85; i++) { //go through every pixel on the x axis |
robinmc | 2:158d57cdbf1e | 2170 | for (int j=menu_select; j<(menu_select+8); j++) { // go through relevant pixels on the y axis |
robinmc | 2:158d57cdbf1e | 2171 | if (lcd.getPixel(i,j)== 0) { //if the pixel is on trun it off |
robinmc | 2:158d57cdbf1e | 2172 | lcd.setPixel(i,j); |
robinmc | 2:158d57cdbf1e | 2173 | } else { |
robinmc | 2:158d57cdbf1e | 2174 | lcd.clearPixel(i,j); //if the pixel is off turn it on |
robinmc | 2:158d57cdbf1e | 2175 | } |
robinmc | 2:158d57cdbf1e | 2176 | } |
robinmc | 2:158d57cdbf1e | 2177 | } |
robinmc | 2:158d57cdbf1e | 2178 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 2179 | //Depending on the options selected g_g1, g_g2 set to one |
robinmc | 3:4b254b4bd6d4 | 2180 | //if g_g1=1 and g_g2=1 it increases the dmage taken by certain mobs |
robinmc | 2:158d57cdbf1e | 2181 | if (b_A & menu_select==0) { |
robinmc | 2:158d57cdbf1e | 2182 | g_g1=0; |
robinmc | 2:158d57cdbf1e | 2183 | g_g2=0; |
robinmc | 2:158d57cdbf1e | 2184 | return; |
robinmc | 2:158d57cdbf1e | 2185 | } else if (b_A & menu_select==8) { |
robinmc | 2:158d57cdbf1e | 2186 | g_g1=1; |
robinmc | 2:158d57cdbf1e | 2187 | g_g2=0; |
robinmc | 2:158d57cdbf1e | 2188 | return; |
robinmc | 2:158d57cdbf1e | 2189 | } else if (b_A & menu_select==16) { |
robinmc | 2:158d57cdbf1e | 2190 | g_g1=1; |
robinmc | 2:158d57cdbf1e | 2191 | g_g2=1; |
robinmc | 2:158d57cdbf1e | 2192 | return; |
robinmc | 2:158d57cdbf1e | 2193 | } else if (b_A & menu_select==24) { |
robinmc | 2:158d57cdbf1e | 2194 | if (rand()%3==0) { |
robinmc | 2:158d57cdbf1e | 2195 | g_g1=0; |
robinmc | 2:158d57cdbf1e | 2196 | g_g2=0; |
robinmc | 2:158d57cdbf1e | 2197 | } else if (rand()%3==1) { |
robinmc | 2:158d57cdbf1e | 2198 | g_g1=1; |
robinmc | 2:158d57cdbf1e | 2199 | g_g2=0; |
robinmc | 2:158d57cdbf1e | 2200 | } else if (rand()%3==2) { |
robinmc | 2:158d57cdbf1e | 2201 | g_g1=1; |
robinmc | 2:158d57cdbf1e | 2202 | g_g2=1; |
robinmc | 2:158d57cdbf1e | 2203 | } |
robinmc | 2:158d57cdbf1e | 2204 | return; |
robinmc | 2:158d57cdbf1e | 2205 | } |
robinmc | 2:158d57cdbf1e | 2206 | if (b_B) { |
robinmc | 2:158d57cdbf1e | 2207 | menuState=0; |
robinmc | 2:158d57cdbf1e | 2208 | return; |
robinmc | 1:046e66f1ca76 | 2209 | } |
robinmc | 1:046e66f1ca76 | 2210 | } |
robinmc | 3:4b254b4bd6d4 | 2211 | sleep(); //puts mbed to sleep |
robinmc | 3:4b254b4bd6d4 | 2212 | } |
robinmc | 3:4b254b4bd6d4 | 2213 | } |
robinmc | 3:4b254b4bd6d4 | 2214 | |
robinmc | 3:4b254b4bd6d4 | 2215 | //prints the credits |
robinmc | 3:4b254b4bd6d4 | 2216 | void Credits() |
robinmc | 3:4b254b4bd6d4 | 2217 | { |
robinmc | 3:4b254b4bd6d4 | 2218 | lcd.clear(); |
robinmc | 3:4b254b4bd6d4 | 2219 | lcd.printString("Game made by",6,2); |
robinmc | 3:4b254b4bd6d4 | 2220 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 2221 | ticker_wait(30); |
robinmc | 3:4b254b4bd6d4 | 2222 | lcd.clear(); |
robinmc | 3:4b254b4bd6d4 | 2223 | lcd.printString("ROBIN",6,1); |
robinmc | 3:4b254b4bd6d4 | 2224 | lcd.printString("MILWARD",6,2); |
robinmc | 3:4b254b4bd6d4 | 2225 | lcd.printString("COONEY",6,3); |
robinmc | 3:4b254b4bd6d4 | 2226 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 2227 | ticker_wait(30); |
robinmc | 3:4b254b4bd6d4 | 2228 | lcd.clear(); |
robinmc | 3:4b254b4bd6d4 | 2229 | lcd.printString("Game made for",0,2); |
robinmc | 3:4b254b4bd6d4 | 2230 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 2231 | ticker_wait(30); |
robinmc | 3:4b254b4bd6d4 | 2232 | lcd.clear(); |
robinmc | 3:4b254b4bd6d4 | 2233 | lcd.printString("ELEC2645",6,2); |
robinmc | 3:4b254b4bd6d4 | 2234 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 2235 | ticker_wait(30); |
robinmc | 3:4b254b4bd6d4 | 2236 | } |
robinmc | 3:4b254b4bd6d4 | 2237 | |
robinmc | 3:4b254b4bd6d4 | 2238 | |
robinmc | 3:4b254b4bd6d4 | 2239 | //Physics related to Recks |
robinmc | 3:4b254b4bd6d4 | 2240 | void Recks() |
robinmc | 3:4b254b4bd6d4 | 2241 | { |
robinmc | 3:4b254b4bd6d4 | 2242 | //if the joystick is centred recks is still |
robinmc | 3:4b254b4bd6d4 | 2243 | if (joystick.direction==CENTRE&jump_flag!=1&shield_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2244 | lcd.setPixel(bullet,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2245 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2246 | print_recks_still_gun(); |
robinmc | 3:4b254b4bd6d4 | 2247 | if (shoot_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2248 | bullet+=20; |
robinmc | 3:4b254b4bd6d4 | 2249 | if (bullet>=84) { |
robinmc | 3:4b254b4bd6d4 | 2250 | shoot_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2251 | g_shoot_loop=0; |
robinmc | 3:4b254b4bd6d4 | 2252 | } |
robinmc | 3:4b254b4bd6d4 | 2253 | } |
robinmc | 3:4b254b4bd6d4 | 2254 | //if the joystick is left then everything except recks moves to the left |
robinmc | 3:4b254b4bd6d4 | 2255 | } else if (joystick.direction==LEFT&jump_flag!=1&shield_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2256 | if ( i%4>=2) { |
robinmc | 3:4b254b4bd6d4 | 2257 | print_recks_still_gun(); |
robinmc | 3:4b254b4bd6d4 | 2258 | } else if ( i%4<2) { |
robinmc | 3:4b254b4bd6d4 | 2259 | print_recks_moving_gun(); |
robinmc | 3:4b254b4bd6d4 | 2260 | } |
robinmc | 3:4b254b4bd6d4 | 2261 | lcd.setPixel(bullet,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2262 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2263 | if (shoot_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2264 | bullet+=21; |
robinmc | 3:4b254b4bd6d4 | 2265 | if (bullet>=84) { |
robinmc | 3:4b254b4bd6d4 | 2266 | shoot_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2267 | g_shoot_loop=0; |
robinmc | 3:4b254b4bd6d4 | 2268 | } |
robinmc | 3:4b254b4bd6d4 | 2269 | } |
robinmc | 3:4b254b4bd6d4 | 2270 | h_movement--; |
robinmc | 3:4b254b4bd6d4 | 2271 | //if the joystick is right then everything except recks moves to the right |
robinmc | 3:4b254b4bd6d4 | 2272 | } else if (joystick.direction==RIGHT&jump_flag!=1&shield_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2273 | if ( i%4>=2) { |
robinmc | 3:4b254b4bd6d4 | 2274 | print_recks_still_gun(); |
robinmc | 3:4b254b4bd6d4 | 2275 | } else if ( i%4<2) { |
robinmc | 3:4b254b4bd6d4 | 2276 | print_recks_moving_gun(); |
robinmc | 3:4b254b4bd6d4 | 2277 | } |
robinmc | 3:4b254b4bd6d4 | 2278 | lcd.setPixel(bullet,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2279 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2280 | if (shoot_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2281 | bullet+=19; |
robinmc | 3:4b254b4bd6d4 | 2282 | if (bullet>=84) { |
robinmc | 3:4b254b4bd6d4 | 2283 | shoot_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2284 | g_shoot_loop=0; |
robinmc | 3:4b254b4bd6d4 | 2285 | } |
robinmc | 3:4b254b4bd6d4 | 2286 | } |
robinmc | 3:4b254b4bd6d4 | 2287 | h_movement++; |
robinmc | 3:4b254b4bd6d4 | 2288 | //If joystick is down recks crouches |
robinmc | 3:4b254b4bd6d4 | 2289 | } else if (joystick.direction==DOWN&jump_flag!=1&shield_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2290 | lcd.setPixel(bullet,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2291 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2292 | print_recks_crouch_gun(); |
robinmc | 3:4b254b4bd6d4 | 2293 | bullet_height=42; |
robinmc | 3:4b254b4bd6d4 | 2294 | if (shoot_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2295 | bullet+=20; |
robinmc | 3:4b254b4bd6d4 | 2296 | if (bullet>=84) { |
robinmc | 3:4b254b4bd6d4 | 2297 | shoot_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2298 | g_shoot_loop=0; |
robinmc | 3:4b254b4bd6d4 | 2299 | } |
robinmc | 3:4b254b4bd6d4 | 2300 | } |
robinmc | 3:4b254b4bd6d4 | 2301 | //If the jump_flag is 1 (then teh jump button has been pressed) Recks jumps |
robinmc | 3:4b254b4bd6d4 | 2302 | //If the joystick moves while the jump_flag is 1 then Recks moves left or right |
robinmc | 3:4b254b4bd6d4 | 2303 | } else if (jump_flag==1&shield_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2304 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2305 | if (shoot_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2306 | bullet+=21; |
robinmc | 3:4b254b4bd6d4 | 2307 | if (bullet>=84) { |
robinmc | 3:4b254b4bd6d4 | 2308 | shoot_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2309 | g_shoot_loop=0; |
robinmc | 3:4b254b4bd6d4 | 2310 | } |
robinmc | 3:4b254b4bd6d4 | 2311 | } |
robinmc | 3:4b254b4bd6d4 | 2312 | h_movement--; |
robinmc | 3:4b254b4bd6d4 | 2313 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2314 | if (shoot_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2315 | bullet+=19; |
robinmc | 3:4b254b4bd6d4 | 2316 | if (bullet>=84) { |
robinmc | 3:4b254b4bd6d4 | 2317 | shoot_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2318 | g_shoot_loop=0; |
robinmc | 3:4b254b4bd6d4 | 2319 | } |
robinmc | 3:4b254b4bd6d4 | 2320 | } |
robinmc | 3:4b254b4bd6d4 | 2321 | h_movement++; |
robinmc | 3:4b254b4bd6d4 | 2322 | } else if (joystick.direction==CENTRE) { |
robinmc | 3:4b254b4bd6d4 | 2323 | if (shoot_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2324 | bullet+=20; |
robinmc | 3:4b254b4bd6d4 | 2325 | if (bullet>=84) { |
robinmc | 3:4b254b4bd6d4 | 2326 | shoot_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2327 | g_shoot_loop=0; |
robinmc | 3:4b254b4bd6d4 | 2328 | } |
robinmc | 3:4b254b4bd6d4 | 2329 | } |
robinmc | 3:4b254b4bd6d4 | 2330 | } |
robinmc | 3:4b254b4bd6d4 | 2331 | if (g_jump<=36&jumpUp==0&g_jump!=15) { |
robinmc | 3:4b254b4bd6d4 | 2332 | lcd.setPixel(bullet,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2333 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2334 | if (bullet>=84) { |
robinmc | 3:4b254b4bd6d4 | 2335 | shoot_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2336 | g_shoot_loop=0; |
robinmc | 3:4b254b4bd6d4 | 2337 | } |
robinmc | 3:4b254b4bd6d4 | 2338 | print_recks_jump_gun(); |
robinmc | 3:4b254b4bd6d4 | 2339 | g_jump-=6-accel; |
robinmc | 3:4b254b4bd6d4 | 2340 | accel++; |
robinmc | 3:4b254b4bd6d4 | 2341 | } else if (g_jump>=15&g_jump!=36) { |
robinmc | 3:4b254b4bd6d4 | 2342 | lcd.setPixel(bullet,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2343 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2344 | if (bullet>=84) { |
robinmc | 3:4b254b4bd6d4 | 2345 | shoot_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2346 | g_shoot_loop=0; |
robinmc | 3:4b254b4bd6d4 | 2347 | } |
robinmc | 3:4b254b4bd6d4 | 2348 | print_recks_jump_gun(); |
robinmc | 3:4b254b4bd6d4 | 2349 | g_jump+=6-accel; |
robinmc | 3:4b254b4bd6d4 | 2350 | accel--; |
robinmc | 3:4b254b4bd6d4 | 2351 | jumpUp=1; |
robinmc | 3:4b254b4bd6d4 | 2352 | } else if (g_jump==36&jumpUp==1) { |
robinmc | 3:4b254b4bd6d4 | 2353 | lcd.setPixel(bullet,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2354 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 3:4b254b4bd6d4 | 2355 | if (bullet>=84) { |
robinmc | 3:4b254b4bd6d4 | 2356 | shoot_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2357 | g_shoot_loop=0; |
robinmc | 3:4b254b4bd6d4 | 2358 | } |
robinmc | 3:4b254b4bd6d4 | 2359 | print_recks_still_gun(); |
robinmc | 3:4b254b4bd6d4 | 2360 | jump_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2361 | jumpUp=0; |
robinmc | 3:4b254b4bd6d4 | 2362 | g_jump=36; |
robinmc | 3:4b254b4bd6d4 | 2363 | accel=0; |
robinmc | 3:4b254b4bd6d4 | 2364 | } |
robinmc | 3:4b254b4bd6d4 | 2365 | } |
robinmc | 3:4b254b4bd6d4 | 2366 | } |
robinmc | 3:4b254b4bd6d4 | 2367 | |
robinmc | 3:4b254b4bd6d4 | 2368 | //Physics for rat |
robinmc | 3:4b254b4bd6d4 | 2369 | void rat() |
robinmc | 3:4b254b4bd6d4 | 2370 | { |
robinmc | 3:4b254b4bd6d4 | 2371 | //rat array p1 or p2 changes every 2 itterations |
robinmc | 3:4b254b4bd6d4 | 2372 | if (i%4>=2) { |
robinmc | 3:4b254b4bd6d4 | 2373 | print_mob_rat_p1(); |
robinmc | 3:4b254b4bd6d4 | 2374 | } else if (i%4<2) { |
robinmc | 3:4b254b4bd6d4 | 2375 | print_mob_rat_p2(); |
robinmc | 3:4b254b4bd6d4 | 2376 | } |
robinmc | 3:4b254b4bd6d4 | 2377 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2378 | rat_movement+=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2379 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2380 | rat_movement-=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2381 | } |
robinmc | 3:4b254b4bd6d4 | 2382 | //rat velocity is 3 pixels per itteration |
robinmc | 3:4b254b4bd6d4 | 2383 | rat_movement-=3; |
robinmc | 3:4b254b4bd6d4 | 2384 | if (rat_movement<=-15) { |
robinmc | 3:4b254b4bd6d4 | 2385 | rat_movement=100; |
robinmc | 3:4b254b4bd6d4 | 2386 | print_rat_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2387 | } |
robinmc | 3:4b254b4bd6d4 | 2388 | //when rat is in same vertical and horizontal position as Recks, Recks loses a life and the freeze duntion runs |
robinmc | 3:4b254b4bd6d4 | 2389 | if (rat_movement<=5&rat_movement>=-3&g_jump>32&lose_lives_delay_flag==0&shield_flag!=1) { //a life is lost if recks has an vertical and horizontal position equal to one of the pixels corresponding to the bears position |
robinmc | 3:4b254b4bd6d4 | 2390 | lives--; |
robinmc | 3:4b254b4bd6d4 | 2391 | freeze(); |
robinmc | 3:4b254b4bd6d4 | 2392 | lose_lives_delay_flag=1; |
robinmc | 3:4b254b4bd6d4 | 2393 | } |
robinmc | 3:4b254b4bd6d4 | 2394 | |
robinmc | 3:4b254b4bd6d4 | 2395 | } |
robinmc | 3:4b254b4bd6d4 | 2396 | |
robinmc | 3:4b254b4bd6d4 | 2397 | void hound() |
robinmc | 3:4b254b4bd6d4 | 2398 | { |
robinmc | 3:4b254b4bd6d4 | 2399 | //hound array p1 or p2 changes every 2 itterations |
robinmc | 3:4b254b4bd6d4 | 2400 | if (i%4>=2&hound_jump_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2401 | print_mob_hound_p1(); |
robinmc | 3:4b254b4bd6d4 | 2402 | } else if (i%4<2&hound_jump_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2403 | print_mob_hound_p2(); |
robinmc | 3:4b254b4bd6d4 | 2404 | } |
robinmc | 3:4b254b4bd6d4 | 2405 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2406 | hound_hMovement+=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2407 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2408 | hound_hMovement-=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2409 | } |
robinmc | 3:4b254b4bd6d4 | 2410 | //hound velocity is 2 pixels per itteration |
robinmc | 3:4b254b4bd6d4 | 2411 | hound_hMovement-=2; |
robinmc | 3:4b254b4bd6d4 | 2412 | if (hound_hMovement<=-15) { |
robinmc | 3:4b254b4bd6d4 | 2413 | hound_hMovement=100; |
robinmc | 3:4b254b4bd6d4 | 2414 | print_hound_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2415 | } |
robinmc | 3:4b254b4bd6d4 | 2416 | if (random_num%10==0) { |
robinmc | 3:4b254b4bd6d4 | 2417 | hound_jump_flag=1; |
robinmc | 3:4b254b4bd6d4 | 2418 | } |
robinmc | 3:4b254b4bd6d4 | 2419 | //if the hound_jump_flag is one the houd jumps and increases it's horizontal velocity to 3 pixels per itteration |
robinmc | 3:4b254b4bd6d4 | 2420 | if (hound_jump_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2421 | hound_jump++; |
robinmc | 3:4b254b4bd6d4 | 2422 | hound_hMovement--; |
robinmc | 3:4b254b4bd6d4 | 2423 | if (hound_jump==1) { |
robinmc | 3:4b254b4bd6d4 | 2424 | hound_vMovement-=3; |
robinmc | 3:4b254b4bd6d4 | 2425 | } else if (hound_jump==2) { |
robinmc | 3:4b254b4bd6d4 | 2426 | hound_vMovement-=2; |
robinmc | 3:4b254b4bd6d4 | 2427 | } else if (hound_jump==3) { |
robinmc | 3:4b254b4bd6d4 | 2428 | hound_vMovement-=1; |
robinmc | 3:4b254b4bd6d4 | 2429 | } else if (hound_jump==4) { |
robinmc | 3:4b254b4bd6d4 | 2430 | hound_vMovement+=1; |
robinmc | 3:4b254b4bd6d4 | 2431 | } else if (hound_jump==5) { |
robinmc | 3:4b254b4bd6d4 | 2432 | hound_vMovement+=2; |
robinmc | 3:4b254b4bd6d4 | 2433 | } else if (hound_jump==6) { |
robinmc | 3:4b254b4bd6d4 | 2434 | hound_vMovement+=3; |
robinmc | 3:4b254b4bd6d4 | 2435 | } else if (hound_jump==7) { |
robinmc | 3:4b254b4bd6d4 | 2436 | hound_jump_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2437 | hound_jump=0; |
robinmc | 3:4b254b4bd6d4 | 2438 | } |
robinmc | 3:4b254b4bd6d4 | 2439 | print_mob_hound_p2(); |
robinmc | 3:4b254b4bd6d4 | 2440 | |
robinmc | 3:4b254b4bd6d4 | 2441 | } |
robinmc | 3:4b254b4bd6d4 | 2442 | //if hound possiton = recks possition, lives decrease by one |
robinmc | 3:4b254b4bd6d4 | 2443 | if ((hound_hMovement<=8&hound_hMovement>=-5&g_jump>30&lose_lives_delay_flag==0&hound_jump_flag!=1&shield_flag!=1)|(hound_hMovement<=8&hound_hMovement>=-5&g_jump>26&lose_lives_delay_flag==0&hound_jump_flag==1&shield_flag!=1)) { //a life is lost if recks has an vertical and horizontal position equal to one of the pixels corresponding to the hounds position |
robinmc | 3:4b254b4bd6d4 | 2444 | lives--; |
robinmc | 3:4b254b4bd6d4 | 2445 | freeze(); |
robinmc | 3:4b254b4bd6d4 | 2446 | lose_lives_delay_flag=1; |
robinmc | 3:4b254b4bd6d4 | 2447 | } |
robinmc | 3:4b254b4bd6d4 | 2448 | //if bullet is the same hight as hound then hound dies |
robinmc | 3:4b254b4bd6d4 | 2449 | if (shoot_flag==1&bullet_height>hound_vMovement&bullet_height<hound_vMovement+8) { |
robinmc | 3:4b254b4bd6d4 | 2450 | print_mob_hound_dead(); |
robinmc | 3:4b254b4bd6d4 | 2451 | print_hound_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2452 | hound_hMovement=90; |
robinmc | 3:4b254b4bd6d4 | 2453 | kill_score+=5; |
robinmc | 1:046e66f1ca76 | 2454 | } |
robinmc | 2:158d57cdbf1e | 2455 | } |
robinmc | 2:158d57cdbf1e | 2456 | |
robinmc | 3:4b254b4bd6d4 | 2457 | //Prints bear physics |
robinmc | 3:4b254b4bd6d4 | 2458 | void bear() |
robinmc | 3:4b254b4bd6d4 | 2459 | { |
robinmc | 3:4b254b4bd6d4 | 2460 | if (i%4>=2) { |
robinmc | 3:4b254b4bd6d4 | 2461 | print_mob_bear_p1(); |
robinmc | 3:4b254b4bd6d4 | 2462 | } else if (i%4<2) { |
robinmc | 3:4b254b4bd6d4 | 2463 | print_mob_bear_p2(); |
robinmc | 3:4b254b4bd6d4 | 2464 | } |
robinmc | 3:4b254b4bd6d4 | 2465 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2466 | bear_movement+=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2467 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2468 | bear_movement-=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2469 | } |
robinmc | 3:4b254b4bd6d4 | 2470 | bear_movement-=2; |
robinmc | 3:4b254b4bd6d4 | 2471 | if (bear_movement<=-15) { |
robinmc | 3:4b254b4bd6d4 | 2472 | bear_movement=100; |
robinmc | 3:4b254b4bd6d4 | 2473 | print_bear_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2474 | } |
robinmc | 3:4b254b4bd6d4 | 2475 | if (bear_movement<=8&bear_movement>=-5&g_jump>26&lose_lives_delay_flag==0&shield_flag!=1) { //a life is lost if recks has an vertical and horizontal position equal to one of the pixels corresponding to the bears position |
robinmc | 3:4b254b4bd6d4 | 2476 | lives--; |
robinmc | 3:4b254b4bd6d4 | 2477 | freeze(); |
robinmc | 3:4b254b4bd6d4 | 2478 | lose_lives_delay_flag=1; |
robinmc | 3:4b254b4bd6d4 | 2479 | } |
robinmc | 3:4b254b4bd6d4 | 2480 | if (shoot_flag==1&bullet_height>38) { |
robinmc | 3:4b254b4bd6d4 | 2481 | bear_lives++; |
robinmc | 3:4b254b4bd6d4 | 2482 | //if bullet hits bear 4 (or 3 or 2 depending on g_g1 and g_g2) bear dies |
robinmc | 3:4b254b4bd6d4 | 2483 | if (bear_lives==12-3*g_g1-3*g_g2) { |
robinmc | 3:4b254b4bd6d4 | 2484 | print_mob_bear_dead(); |
robinmc | 3:4b254b4bd6d4 | 2485 | print_bear_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2486 | bear_movement=100; |
robinmc | 3:4b254b4bd6d4 | 2487 | kill_score+=7; |
robinmc | 3:4b254b4bd6d4 | 2488 | bear_lives=0; |
robinmc | 3:4b254b4bd6d4 | 2489 | } |
robinmc | 3:4b254b4bd6d4 | 2490 | } |
robinmc | 3:4b254b4bd6d4 | 2491 | } |
robinmc | 3:4b254b4bd6d4 | 2492 | |
robinmc | 3:4b254b4bd6d4 | 2493 | //Bird physins, has a constant horizontal velocity and the vertical one changes randomly |
robinmc | 3:4b254b4bd6d4 | 2494 | void bird() |
robinmc | 2:158d57cdbf1e | 2495 | { |
robinmc | 3:4b254b4bd6d4 | 2496 | if (i%8>=4) { |
robinmc | 3:4b254b4bd6d4 | 2497 | print_mob_bird_p1(); |
robinmc | 3:4b254b4bd6d4 | 2498 | } else if (i%8<4) { |
robinmc | 3:4b254b4bd6d4 | 2499 | print_mob_bird_p2(); |
robinmc | 3:4b254b4bd6d4 | 2500 | } |
robinmc | 3:4b254b4bd6d4 | 2501 | bird_hMovement-=2; |
robinmc | 3:4b254b4bd6d4 | 2502 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2503 | bird_hMovement+=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2504 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2505 | bird_hMovement-=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2506 | } |
robinmc | 3:4b254b4bd6d4 | 2507 | if (random_num%6==0) { |
robinmc | 3:4b254b4bd6d4 | 2508 | bird_vMovement--; |
robinmc | 3:4b254b4bd6d4 | 2509 | } else if (random_num%6>=4) { |
robinmc | 3:4b254b4bd6d4 | 2510 | bird_vMovement++; |
robinmc | 3:4b254b4bd6d4 | 2511 | } |
robinmc | 3:4b254b4bd6d4 | 2512 | if (bird_vMovement>=37) { |
robinmc | 3:4b254b4bd6d4 | 2513 | bird_vMovement=37; |
robinmc | 3:4b254b4bd6d4 | 2514 | } else if (bird_vMovement<=10) { |
robinmc | 3:4b254b4bd6d4 | 2515 | bird_vMovement=10; |
robinmc | 3:4b254b4bd6d4 | 2516 | } |
robinmc | 3:4b254b4bd6d4 | 2517 | if (bird_hMovement<=-10) { |
robinmc | 3:4b254b4bd6d4 | 2518 | print_bird_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2519 | bird_hMovement=100; |
robinmc | 3:4b254b4bd6d4 | 2520 | bird_vMovement=20; |
robinmc | 3:4b254b4bd6d4 | 2521 | bear_lives=0; |
robinmc | 3:4b254b4bd6d4 | 2522 | } |
robinmc | 3:4b254b4bd6d4 | 2523 | if ((bird_hMovement>=0&bird_hMovement<=10)&(bird_vMovement+5>=g_jump&bird_vMovement+5<=g_jump+10&lose_lives_delay_flag==0)&shield_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2524 | lives--; |
robinmc | 3:4b254b4bd6d4 | 2525 | freeze(); |
robinmc | 3:4b254b4bd6d4 | 2526 | lose_lives_delay_flag=1; |
robinmc | 3:4b254b4bd6d4 | 2527 | } |
robinmc | 3:4b254b4bd6d4 | 2528 | if (shoot_flag==1&(bullet_height==bird_vMovement+5|bullet_height==bird_vMovement+4)) { |
robinmc | 3:4b254b4bd6d4 | 2529 | print_mob_bird_dead(); |
robinmc | 3:4b254b4bd6d4 | 2530 | print_bird_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2531 | bird_hMovement=100; |
robinmc | 3:4b254b4bd6d4 | 2532 | bird_vMovement=20; |
robinmc | 3:4b254b4bd6d4 | 2533 | kill_score+=5; |
robinmc | 3:4b254b4bd6d4 | 2534 | } |
robinmc | 3:4b254b4bd6d4 | 2535 | } |
robinmc | 2:158d57cdbf1e | 2536 | |
robinmc | 3:4b254b4bd6d4 | 2537 | //Cactus physics |
robinmc | 3:4b254b4bd6d4 | 2538 | void cactus() |
robinmc | 3:4b254b4bd6d4 | 2539 | { |
robinmc | 3:4b254b4bd6d4 | 2540 | print_cactus(); |
robinmc | 3:4b254b4bd6d4 | 2541 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2542 | cactus_movement+=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2543 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2544 | cactus_movement-=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2545 | } |
robinmc | 3:4b254b4bd6d4 | 2546 | if (cactus_movement<=-10) { |
robinmc | 3:4b254b4bd6d4 | 2547 | cactus_movement=110; |
robinmc | 3:4b254b4bd6d4 | 2548 | print_cactus_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2549 | } |
robinmc | 3:4b254b4bd6d4 | 2550 | if (cactus_movement<=10&cactus_movement>=2&g_jump>32&lose_lives_delay_flag==0&shield_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2551 | lives--; |
robinmc | 3:4b254b4bd6d4 | 2552 | freeze(); |
robinmc | 3:4b254b4bd6d4 | 2553 | lose_lives_delay_flag=1; |
robinmc | 3:4b254b4bd6d4 | 2554 | } |
robinmc | 3:4b254b4bd6d4 | 2555 | } |
robinmc | 3:4b254b4bd6d4 | 2556 | |
robinmc | 3:4b254b4bd6d4 | 2557 | //T Rex physics |
robinmc | 3:4b254b4bd6d4 | 2558 | void t_rex() |
robinmc | 3:4b254b4bd6d4 | 2559 | { |
robinmc | 3:4b254b4bd6d4 | 2560 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2561 | t_rex_movement+=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2562 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2563 | t_rex_movement-=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2564 | } |
robinmc | 3:4b254b4bd6d4 | 2565 | if (random_num%4==0&print_fire_ball_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2566 | t_rex_movement+=3; |
robinmc | 3:4b254b4bd6d4 | 2567 | print_t_rex_moving(); |
robinmc | 3:4b254b4bd6d4 | 2568 | } else if (random_num%4==1&print_fire_ball_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2569 | t_rex_movement-=3; |
robinmc | 3:4b254b4bd6d4 | 2570 | print_t_rex_moving(); |
robinmc | 3:4b254b4bd6d4 | 2571 | } else if (random_num%4>1&print_fire_ball_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2572 | print_t_rex(); |
robinmc | 3:4b254b4bd6d4 | 2573 | } |
robinmc | 3:4b254b4bd6d4 | 2574 | if (t_rex_movement<=-100) { |
robinmc | 3:4b254b4bd6d4 | 2575 | t_rex_movement=120; |
robinmc | 3:4b254b4bd6d4 | 2576 | print_t_rex_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2577 | } |
robinmc | 3:4b254b4bd6d4 | 2578 | if (t_rex_movement<=6&t_rex_movement>=2&lose_lives_delay_flag==0&shield_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2579 | lives--; |
robinmc | 3:4b254b4bd6d4 | 2580 | freeze(); |
robinmc | 3:4b254b4bd6d4 | 2581 | lose_lives_delay_flag=1; |
robinmc | 3:4b254b4bd6d4 | 2582 | } |
robinmc | 3:4b254b4bd6d4 | 2583 | if (print_t_rex_flag==1&random_num%10==0&fire_on_screen==0) { |
robinmc | 3:4b254b4bd6d4 | 2584 | fire_on_screen=1; |
robinmc | 3:4b254b4bd6d4 | 2585 | print_fire_ball_flag=1; |
robinmc | 3:4b254b4bd6d4 | 2586 | fire_ball_hMovement=t_rex_movement-6; |
robinmc | 3:4b254b4bd6d4 | 2587 | fire_ball_vMovement=25; |
robinmc | 3:4b254b4bd6d4 | 2588 | } |
robinmc | 2:158d57cdbf1e | 2589 | } |
robinmc | 2:158d57cdbf1e | 2590 | |
robinmc | 3:4b254b4bd6d4 | 2591 | //Fire ball physics, T Rex only loses lives when fire ball flag is on |
robinmc | 3:4b254b4bd6d4 | 2592 | void fire_ball() |
robinmc | 3:4b254b4bd6d4 | 2593 | { |
robinmc | 3:4b254b4bd6d4 | 2594 | print_t_rex_attack(); |
robinmc | 3:4b254b4bd6d4 | 2595 | fire_ball_hMovement-=4; |
robinmc | 3:4b254b4bd6d4 | 2596 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2597 | fire_ball_hMovement+=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2598 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2599 | fire_ball_hMovement-=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2600 | } |
robinmc | 3:4b254b4bd6d4 | 2601 | if (i%4>=2) { |
robinmc | 3:4b254b4bd6d4 | 2602 | print_fire_ball_p1(); |
robinmc | 3:4b254b4bd6d4 | 2603 | } else { |
robinmc | 3:4b254b4bd6d4 | 2604 | print_fire_ball_p2(); |
robinmc | 3:4b254b4bd6d4 | 2605 | } |
robinmc | 3:4b254b4bd6d4 | 2606 | if (fire_ball_vMovement>=37) { |
robinmc | 3:4b254b4bd6d4 | 2607 | fire_ball_vMovement=37; |
robinmc | 3:4b254b4bd6d4 | 2608 | } |
robinmc | 3:4b254b4bd6d4 | 2609 | if (random_num%3==0) { |
robinmc | 3:4b254b4bd6d4 | 2610 | fire_ball_vMovement++; |
robinmc | 3:4b254b4bd6d4 | 2611 | } else if (random_num%3==1) { |
robinmc | 3:4b254b4bd6d4 | 2612 | fire_ball_vMovement+=2; |
robinmc | 3:4b254b4bd6d4 | 2613 | } |
robinmc | 3:4b254b4bd6d4 | 2614 | if (fire_ball_hMovement<=-10) { |
robinmc | 3:4b254b4bd6d4 | 2615 | fire_ball_vMovement=27; |
robinmc | 3:4b254b4bd6d4 | 2616 | fire_ball_hMovement=t_rex_movement-6; |
robinmc | 3:4b254b4bd6d4 | 2617 | print_fire_ball_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2618 | fire_on_screen=0; |
robinmc | 3:4b254b4bd6d4 | 2619 | } |
robinmc | 3:4b254b4bd6d4 | 2620 | if (fire_ball_hMovement>=3&fire_ball_hMovement<=8&fire_ball_vMovement>g_jump-5&fire_ball_vMovement<g_jump+10&lose_lives_delay_flag==0&shield_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2621 | lives--; |
robinmc | 3:4b254b4bd6d4 | 2622 | freeze(); |
robinmc | 3:4b254b4bd6d4 | 2623 | lose_lives_delay_flag=1; |
robinmc | 3:4b254b4bd6d4 | 2624 | } |
robinmc | 3:4b254b4bd6d4 | 2625 | if (shoot_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2626 | t_rex_lives++; |
robinmc | 3:4b254b4bd6d4 | 2627 | if (t_rex_lives>=27-3*g_g1-3*g_g2) { |
robinmc | 3:4b254b4bd6d4 | 2628 | print_t_rex_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2629 | t_rex_movement=120; |
robinmc | 3:4b254b4bd6d4 | 2630 | kill_score+=20; |
robinmc | 3:4b254b4bd6d4 | 2631 | t_rex_lives=0; |
robinmc | 3:4b254b4bd6d4 | 2632 | } |
robinmc | 3:4b254b4bd6d4 | 2633 | } |
robinmc | 3:4b254b4bd6d4 | 2634 | } |
robinmc | 3:4b254b4bd6d4 | 2635 | |
robinmc | 3:4b254b4bd6d4 | 2636 | //Physics for quicksand |
robinmc | 3:4b254b4bd6d4 | 2637 | void quick_sand() |
robinmc | 3:4b254b4bd6d4 | 2638 | { |
robinmc | 3:4b254b4bd6d4 | 2639 | print_quick_sand(); |
robinmc | 3:4b254b4bd6d4 | 2640 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2641 | quick_sand_movement+=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2642 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2643 | quick_sand_movement-=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2644 | } |
robinmc | 3:4b254b4bd6d4 | 2645 | if (quick_sand_movement<7&quick_sand_movement>-5&jump_flag!=1) { |
robinmc | 3:4b254b4bd6d4 | 2646 | lives-=5; |
robinmc | 3:4b254b4bd6d4 | 2647 | falling_animation(); |
robinmc | 3:4b254b4bd6d4 | 2648 | quick_sand_movement=85; |
robinmc | 3:4b254b4bd6d4 | 2649 | if (quick_sand_movement<-8) { |
robinmc | 3:4b254b4bd6d4 | 2650 | print_quick_sand_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2651 | } |
robinmc | 3:4b254b4bd6d4 | 2652 | } |
robinmc | 3:4b254b4bd6d4 | 2653 | } |
robinmc | 3:4b254b4bd6d4 | 2654 | |
robinmc | 3:4b254b4bd6d4 | 2655 | //Heart physics |
robinmc | 3:4b254b4bd6d4 | 2656 | void heart() |
robinmc | 3:4b254b4bd6d4 | 2657 | { |
robinmc | 3:4b254b4bd6d4 | 2658 | print_heart(); |
robinmc | 3:4b254b4bd6d4 | 2659 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2660 | heart_movement+=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2661 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2662 | heart_movement-=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2663 | } |
robinmc | 3:4b254b4bd6d4 | 2664 | if (heart_movement<=7&g_jump>26) { |
robinmc | 3:4b254b4bd6d4 | 2665 | heart_movement=90; |
robinmc | 3:4b254b4bd6d4 | 2666 | print_heart_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2667 | lives++; |
robinmc | 3:4b254b4bd6d4 | 2668 | } |
robinmc | 3:4b254b4bd6d4 | 2669 | } |
robinmc | 3:4b254b4bd6d4 | 2670 | |
robinmc | 3:4b254b4bd6d4 | 2671 | //Ammo pickup physics |
robinmc | 3:4b254b4bd6d4 | 2672 | void pickUp_ammo() |
robinmc | 3:4b254b4bd6d4 | 2673 | { |
robinmc | 3:4b254b4bd6d4 | 2674 | print_ammo_pickUp(); |
robinmc | 3:4b254b4bd6d4 | 2675 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2676 | ammo_movement+=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2677 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2678 | ammo_movement-=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2679 | } |
robinmc | 3:4b254b4bd6d4 | 2680 | if (ammo_movement<=7&g_jump>26) { |
robinmc | 3:4b254b4bd6d4 | 2681 | ammo_movement=90; |
robinmc | 3:4b254b4bd6d4 | 2682 | print_ammo_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2683 | ammo+=5; |
robinmc | 3:4b254b4bd6d4 | 2684 | ammo+=rand()%7; |
robinmc | 3:4b254b4bd6d4 | 2685 | } |
robinmc | 3:4b254b4bd6d4 | 2686 | } |
robinmc | 3:4b254b4bd6d4 | 2687 | |
robinmc | 3:4b254b4bd6d4 | 2688 | //Speedboost physcis. Recks speed increases by one when pucked up |
robinmc | 3:4b254b4bd6d4 | 2689 | void speed_boost() |
robinmc | 3:4b254b4bd6d4 | 2690 | { |
robinmc | 3:4b254b4bd6d4 | 2691 | print_speed_boost(); |
robinmc | 3:4b254b4bd6d4 | 2692 | if (joystick.direction==LEFT) { |
robinmc | 3:4b254b4bd6d4 | 2693 | speed_boost_movement+=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2694 | } else if (joystick.direction==RIGHT) { |
robinmc | 3:4b254b4bd6d4 | 2695 | speed_boost_movement-=recks_movement; |
robinmc | 3:4b254b4bd6d4 | 2696 | } |
robinmc | 3:4b254b4bd6d4 | 2697 | if (speed_boost_movement<=5&g_jump>26) { |
robinmc | 3:4b254b4bd6d4 | 2698 | speed_boost_movement=120; |
robinmc | 3:4b254b4bd6d4 | 2699 | print_speed_boost_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2700 | recks_movement++; |
robinmc | 3:4b254b4bd6d4 | 2701 | } |
robinmc | 3:4b254b4bd6d4 | 2702 | } |
robinmc | 3:4b254b4bd6d4 | 2703 | |
robinmc | 3:4b254b4bd6d4 | 2704 | //Shield physics |
robinmc | 3:4b254b4bd6d4 | 2705 | void shield() |
robinmc | 3:4b254b4bd6d4 | 2706 | { |
robinmc | 3:4b254b4bd6d4 | 2707 | print_recks_shield(); |
robinmc | 3:4b254b4bd6d4 | 2708 | recks_movement=0; |
robinmc | 3:4b254b4bd6d4 | 2709 | jump_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2710 | shoot_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2711 | shield_counter++; |
robinmc | 3:4b254b4bd6d4 | 2712 | if (shield_counter>=10) { |
robinmc | 3:4b254b4bd6d4 | 2713 | shield_counter=0; |
robinmc | 3:4b254b4bd6d4 | 2714 | recks_movement=2; |
robinmc | 3:4b254b4bd6d4 | 2715 | shield_score+=10; |
robinmc | 3:4b254b4bd6d4 | 2716 | shield_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2717 | } |
robinmc | 3:4b254b4bd6d4 | 2718 | } |
robinmc | 3:4b254b4bd6d4 | 2719 | |
robinmc | 3:4b254b4bd6d4 | 2720 | |
robinmc | 3:4b254b4bd6d4 | 2721 | //Game funtion |
robinmc | 3:4b254b4bd6d4 | 2722 | //Combines all the privious physics funtions |
robinmc | 3:4b254b4bd6d4 | 2723 | //if the story mode is on then it ends after certain tasks are complete |
robinmc | 2:158d57cdbf1e | 2724 | void Game() |
robinmc | 2:158d57cdbf1e | 2725 | { |
robinmc | 2:158d57cdbf1e | 2726 | int run_game=1; |
robinmc | 2:158d57cdbf1e | 2727 | g_music_count=1; |
robinmc | 2:158d57cdbf1e | 2728 | while (run_game==1) { |
robinmc | 2:158d57cdbf1e | 2729 | ground(); |
robinmc | 2:158d57cdbf1e | 2730 | set_difficulty(); |
robinmc | 2:158d57cdbf1e | 2731 | if (g_Ticker_Game_flag) { |
robinmc | 2:158d57cdbf1e | 2732 | play_music(); |
robinmc | 2:158d57cdbf1e | 2733 | g_Ticker_Game_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2734 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 2735 | updateJoystick(); |
robinmc | 2:158d57cdbf1e | 2736 | led_bar(); |
robinmc | 2:158d57cdbf1e | 2737 | print_score(); |
robinmc | 2:158d57cdbf1e | 2738 | generate_random_number(); |
robinmc | 2:158d57cdbf1e | 2739 | if (lose_lives_delay_flag==1) { |
robinmc | 2:158d57cdbf1e | 2740 | lives_delay_loop++; |
robinmc | 2:158d57cdbf1e | 2741 | if (lives_delay_loop>=10) { //means that the delay between one life beeing lost and another one beeing lost is at least 1s |
robinmc | 2:158d57cdbf1e | 2742 | lives_delay_loop=0; |
robinmc | 2:158d57cdbf1e | 2743 | lose_lives_delay_flag=0; |
robinmc | 2:158d57cdbf1e | 2744 | } |
robinmc | 2:158d57cdbf1e | 2745 | |
robinmc | 2:158d57cdbf1e | 2746 | } |
robinmc | 2:158d57cdbf1e | 2747 | if (ammo<=5) { |
robinmc | 2:158d57cdbf1e | 2748 | if (i%8>=4) { |
robinmc | 2:158d57cdbf1e | 2749 | print_ammo(); |
robinmc | 2:158d57cdbf1e | 2750 | } |
robinmc | 2:158d57cdbf1e | 2751 | } else { |
robinmc | 2:158d57cdbf1e | 2752 | print_ammo(); |
robinmc | 2:158d57cdbf1e | 2753 | } |
robinmc | 2:158d57cdbf1e | 2754 | if (b_B) { |
robinmc | 2:158d57cdbf1e | 2755 | jump_flag=1; |
robinmc | 2:158d57cdbf1e | 2756 | } |
robinmc | 2:158d57cdbf1e | 2757 | if (shoot_flag==0) { |
robinmc | 2:158d57cdbf1e | 2758 | bullet=9; |
robinmc | 2:158d57cdbf1e | 2759 | if (joystick.direction==DOWN&jump_flag!=1) { |
robinmc | 2:158d57cdbf1e | 2760 | bullet_height=42; |
robinmc | 2:158d57cdbf1e | 2761 | } else { |
robinmc | 2:158d57cdbf1e | 2762 | bullet_height=g_jump+4; |
robinmc | 2:158d57cdbf1e | 2763 | } |
robinmc | 3:4b254b4bd6d4 | 2764 | } else if (shoot_flag==1&g_shoot_loop==0) { |
robinmc | 3:4b254b4bd6d4 | 2765 | g_shoot_loop++; |
robinmc | 2:158d57cdbf1e | 2766 | ammo--; |
robinmc | 2:158d57cdbf1e | 2767 | if (joystick.direction==DOWN&jump_flag!=1) { |
robinmc | 2:158d57cdbf1e | 2768 | bullet_height=42; |
robinmc | 2:158d57cdbf1e | 2769 | } else { |
robinmc | 2:158d57cdbf1e | 2770 | bullet_height=g_jump+4; |
robinmc | 2:158d57cdbf1e | 2771 | } |
robinmc | 2:158d57cdbf1e | 2772 | } |
robinmc | 2:158d57cdbf1e | 2773 | if (b_A) { |
robinmc | 2:158d57cdbf1e | 2774 | if (ammo<=0) { |
robinmc | 2:158d57cdbf1e | 2775 | shoot_flag=0; |
robinmc | 2:158d57cdbf1e | 2776 | } else { |
robinmc | 2:158d57cdbf1e | 2777 | shoot_flag=1; |
robinmc | 2:158d57cdbf1e | 2778 | } |
robinmc | 2:158d57cdbf1e | 2779 | } |
robinmc | 2:158d57cdbf1e | 2780 | if (joystick.direction==UP&score>=10&jump_flag!=1) { |
robinmc | 2:158d57cdbf1e | 2781 | shield_flag=1; |
robinmc | 2:158d57cdbf1e | 2782 | } else if (joystick.direction==UP&score<10&jump_flag!=1) { |
robinmc | 2:158d57cdbf1e | 2783 | print_recks_still_gun(); |
robinmc | 2:158d57cdbf1e | 2784 | } |
robinmc | 3:4b254b4bd6d4 | 2785 | |
robinmc | 3:4b254b4bd6d4 | 2786 | Recks(); |
robinmc | 3:4b254b4bd6d4 | 2787 | if (shield_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2788 | shield(); |
robinmc | 2:158d57cdbf1e | 2789 | } |
robinmc | 2:158d57cdbf1e | 2790 | if (print_rat_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2791 | rat(); |
robinmc | 1:046e66f1ca76 | 2792 | } |
robinmc | 2:158d57cdbf1e | 2793 | if (print_hound_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2794 | hound(); |
robinmc | 2:158d57cdbf1e | 2795 | } |
robinmc | 2:158d57cdbf1e | 2796 | if (print_bear_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2797 | bear(); |
robinmc | 2:158d57cdbf1e | 2798 | } |
robinmc | 2:158d57cdbf1e | 2799 | if (print_bird_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2800 | bird(); |
robinmc | 2:158d57cdbf1e | 2801 | } |
robinmc | 2:158d57cdbf1e | 2802 | if (print_cactus_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2803 | cactus(); |
robinmc | 2:158d57cdbf1e | 2804 | } |
robinmc | 2:158d57cdbf1e | 2805 | if (print_t_rex_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2806 | t_rex(); |
robinmc | 2:158d57cdbf1e | 2807 | } |
robinmc | 2:158d57cdbf1e | 2808 | if (print_fire_ball_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2809 | fire_ball(); |
robinmc | 2:158d57cdbf1e | 2810 | } |
robinmc | 3:4b254b4bd6d4 | 2811 | if (print_quick_sand_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2812 | quick_sand(); |
robinmc | 2:158d57cdbf1e | 2813 | } |
robinmc | 2:158d57cdbf1e | 2814 | if (print_heart_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2815 | heart(); |
robinmc | 2:158d57cdbf1e | 2816 | } |
robinmc | 2:158d57cdbf1e | 2817 | if (print_ammo_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2818 | pickUp_ammo(); |
robinmc | 2:158d57cdbf1e | 2819 | } |
robinmc | 2:158d57cdbf1e | 2820 | if (print_speed_boost_flag==1) { |
robinmc | 3:4b254b4bd6d4 | 2821 | speed_boost(); |
robinmc | 2:158d57cdbf1e | 2822 | } |
robinmc | 2:158d57cdbf1e | 2823 | if (recks_movement>=3&i%150==0) { |
robinmc | 2:158d57cdbf1e | 2824 | recks_movement=2; |
robinmc | 2:158d57cdbf1e | 2825 | } |
robinmc | 2:158d57cdbf1e | 2826 | if (lives<=0) { |
robinmc | 2:158d57cdbf1e | 2827 | run_game=Game_over(); //calls game over returns 1 if continue was selected returns 0 if back to menu |
robinmc | 2:158d57cdbf1e | 2828 | } |
robinmc | 2:158d57cdbf1e | 2829 | if (swJoy==1) { |
robinmc | 2:158d57cdbf1e | 2830 | Pause(); |
robinmc | 2:158d57cdbf1e | 2831 | } |
robinmc | 3:4b254b4bd6d4 | 2832 | |
robinmc | 2:158d57cdbf1e | 2833 | |
robinmc | 2:158d57cdbf1e | 2834 | if (difficulty==-1&story_mode_flag==1) { |
robinmc | 2:158d57cdbf1e | 2835 | if (i>70) { |
robinmc | 2:158d57cdbf1e | 2836 | initialize_values(); |
robinmc | 2:158d57cdbf1e | 2837 | return; |
robinmc | 2:158d57cdbf1e | 2838 | } |
robinmc | 2:158d57cdbf1e | 2839 | } else if (difficulty==0&story_mode_flag==1) { |
robinmc | 2:158d57cdbf1e | 2840 | if (score>60) { |
robinmc | 2:158d57cdbf1e | 2841 | return; |
robinmc | 2:158d57cdbf1e | 2842 | } |
robinmc | 2:158d57cdbf1e | 2843 | } else if (difficulty==1&story_mode_flag==1) { |
robinmc | 2:158d57cdbf1e | 2844 | if (score>200) { |
robinmc | 2:158d57cdbf1e | 2845 | return; |
robinmc | 2:158d57cdbf1e | 2846 | } |
robinmc | 2:158d57cdbf1e | 2847 | } else if (difficulty==2&story_mode_flag==1) { |
robinmc | 2:158d57cdbf1e | 2848 | if (score>500) { |
robinmc | 2:158d57cdbf1e | 2849 | return; |
robinmc | 2:158d57cdbf1e | 2850 | } |
robinmc | 2:158d57cdbf1e | 2851 | } else if (difficulty==3&story_mode_flag==1) { |
robinmc | 2:158d57cdbf1e | 2852 | print_t_rex_flag=1; |
robinmc | 2:158d57cdbf1e | 2853 | g_story_mode_win=0; |
robinmc | 2:158d57cdbf1e | 2854 | if (t_rex_lives>=24) { |
robinmc | 2:158d57cdbf1e | 2855 | print_t_rex_flag=0; |
robinmc | 2:158d57cdbf1e | 2856 | g_story_mode_win=1; |
robinmc | 2:158d57cdbf1e | 2857 | return; |
robinmc | 2:158d57cdbf1e | 2858 | } |
robinmc | 2:158d57cdbf1e | 2859 | } |
robinmc | 2:158d57cdbf1e | 2860 | i++; |
robinmc | 2:158d57cdbf1e | 2861 | print_clouds(); |
robinmc | 1:046e66f1ca76 | 2862 | } |
robinmc | 1:046e66f1ca76 | 2863 | lcd.refresh(); |
robinmc | 3:4b254b4bd6d4 | 2864 | sleep(); //puts mbed to sleep |
robinmc | 1:046e66f1ca76 | 2865 | } |
robinmc | 2:158d57cdbf1e | 2866 | } |
robinmc | 1:046e66f1ca76 | 2867 | |
robinmc | 3:4b254b4bd6d4 | 2868 | //Funtion for pause |
robinmc | 2:158d57cdbf1e | 2869 | void Pause() |
robinmc | 2:158d57cdbf1e | 2870 | { |
robinmc | 1:046e66f1ca76 | 2871 | int q; |
robinmc | 2:158d57cdbf1e | 2872 | lcd.printString("PAUSED",25,3); |
robinmc | 2:158d57cdbf1e | 2873 | ticker_wait(10); |
robinmc | 2:158d57cdbf1e | 2874 | while (!swJoy) { |
robinmc | 3:4b254b4bd6d4 | 2875 | q++; |
robinmc | 1:046e66f1ca76 | 2876 | if (g_Ticker_Menu_flag) { |
robinmc | 1:046e66f1ca76 | 2877 | g_Ticker_Menu_flag=0; |
robinmc | 3:4b254b4bd6d4 | 2878 | if (q>=20) { |
robinmc | 1:046e66f1ca76 | 2879 | lcd.setBrightness(0); |
robinmc | 1:046e66f1ca76 | 2880 | led=0; |
robinmc | 1:046e66f1ca76 | 2881 | } |
robinmc | 0:28392431dbad | 2882 | } |
robinmc | 3:4b254b4bd6d4 | 2883 | sleep(); //puts mbed to sleep |
robinmc | 0:28392431dbad | 2884 | } |
robinmc | 3:4b254b4bd6d4 | 2885 | lcd.setBrightness(brightness); |
robinmc | 3:4b254b4bd6d4 | 2886 | led_bar(); |
robinmc | 2:158d57cdbf1e | 2887 | } |
robinmc | 2:158d57cdbf1e | 2888 | |
robinmc | 3:4b254b4bd6d4 | 2889 | |
robinmc | 3:4b254b4bd6d4 | 2890 | //Funtion that increases game difficuly as difficulty increases |
robinmc | 2:158d57cdbf1e | 2891 | void set_difficulty() |
robinmc | 2:158d57cdbf1e | 2892 | { |
robinmc | 2:158d57cdbf1e | 2893 | switch(difficulty) { |
robinmc | 2:158d57cdbf1e | 2894 | case -1: |
robinmc | 2:158d57cdbf1e | 2895 | break; |
robinmc | 2:158d57cdbf1e | 2896 | case 0: |
robinmc | 2:158d57cdbf1e | 2897 | if (random_num<3000) { |
robinmc | 2:158d57cdbf1e | 2898 | print_cactus_flag=1; |
robinmc | 2:158d57cdbf1e | 2899 | } else if (random_num>=3000&random_num<6000) { |
robinmc | 2:158d57cdbf1e | 2900 | print_rat_flag=1; |
robinmc | 2:158d57cdbf1e | 2901 | } else if (random_num>=6000&random_num<6100) { |
robinmc | 2:158d57cdbf1e | 2902 | print_heart_flag=1; |
robinmc | 2:158d57cdbf1e | 2903 | } |
robinmc | 2:158d57cdbf1e | 2904 | break; |
robinmc | 2:158d57cdbf1e | 2905 | case 1: |
robinmc | 2:158d57cdbf1e | 2906 | if (random_num<3000) { |
robinmc | 2:158d57cdbf1e | 2907 | print_cactus_flag=1; |
robinmc | 2:158d57cdbf1e | 2908 | } else if (random_num>=3000&random_num<5000) { |
robinmc | 2:158d57cdbf1e | 2909 | print_rat_flag=1; |
robinmc | 2:158d57cdbf1e | 2910 | } else if (random_num>=5000&random_num<6000) { |
robinmc | 2:158d57cdbf1e | 2911 | print_bird_flag=1; |
robinmc | 2:158d57cdbf1e | 2912 | } else if (random_num>=6000&random_num<6050) { |
robinmc | 2:158d57cdbf1e | 2913 | print_heart_flag=1; |
robinmc | 2:158d57cdbf1e | 2914 | } else if (random_num>=6050&random_num<7000) { |
robinmc | 2:158d57cdbf1e | 2915 | print_hound_flag=1; |
robinmc | 2:158d57cdbf1e | 2916 | } else if (random_num>=7000&random_num<7200) { |
robinmc | 2:158d57cdbf1e | 2917 | print_ammo_flag=1; |
robinmc | 2:158d57cdbf1e | 2918 | } |
robinmc | 2:158d57cdbf1e | 2919 | break; |
robinmc | 2:158d57cdbf1e | 2920 | case 2: |
robinmc | 2:158d57cdbf1e | 2921 | if (random_num<3000) { |
robinmc | 2:158d57cdbf1e | 2922 | print_cactus_flag=1; |
robinmc | 2:158d57cdbf1e | 2923 | } else if (random_num>=3000&random_num<5000) { |
robinmc | 2:158d57cdbf1e | 2924 | print_rat_flag=1; |
robinmc | 2:158d57cdbf1e | 2925 | } else if (random_num>=5000&random_num<6000) { |
robinmc | 2:158d57cdbf1e | 2926 | print_bird_flag=1; |
robinmc | 2:158d57cdbf1e | 2927 | } else if (random_num>=6000&random_num<6040) { |
robinmc | 2:158d57cdbf1e | 2928 | print_heart_flag=1; |
robinmc | 2:158d57cdbf1e | 2929 | } else if (random_num>=6040&random_num<7000) { |
robinmc | 2:158d57cdbf1e | 2930 | print_hound_flag=1; |
robinmc | 2:158d57cdbf1e | 2931 | } else if (random_num>=7000&random_num<7200) { |
robinmc | 2:158d57cdbf1e | 2932 | print_ammo_flag=1; |
robinmc | 2:158d57cdbf1e | 2933 | } else if (random_num>=7200&random_num<8000) { |
robinmc | 2:158d57cdbf1e | 2934 | print_bear_flag=1; |
robinmc | 2:158d57cdbf1e | 2935 | } else if (random_num>=8000&random_num<8200) { |
robinmc | 2:158d57cdbf1e | 2936 | print_speed_boost_flag=1; |
robinmc | 2:158d57cdbf1e | 2937 | } |
robinmc | 2:158d57cdbf1e | 2938 | break; |
robinmc | 2:158d57cdbf1e | 2939 | case 3: |
robinmc | 2:158d57cdbf1e | 2940 | if (random_num<1000) { |
robinmc | 2:158d57cdbf1e | 2941 | print_bear_flag=1; |
robinmc | 2:158d57cdbf1e | 2942 | } else if (random_num>=1000&random_num<3000) { |
robinmc | 2:158d57cdbf1e | 2943 | print_bird_flag=1; |
robinmc | 2:158d57cdbf1e | 2944 | } else if (random_num>=3000&random_num<3010) { |
robinmc | 2:158d57cdbf1e | 2945 | print_heart_flag=1; |
robinmc | 2:158d57cdbf1e | 2946 | } else if (random_num>=3010&random_num<3050) { |
robinmc | 2:158d57cdbf1e | 2947 | print_ammo_flag=1; |
robinmc | 2:158d57cdbf1e | 2948 | } else if (random_num>=3050&random_num<6000) { |
robinmc | 2:158d57cdbf1e | 2949 | print_cactus_flag=1; |
robinmc | 2:158d57cdbf1e | 2950 | } else if (random_num>=6000&random_num<6100) { |
robinmc | 2:158d57cdbf1e | 2951 | print_ammo_flag=1; |
robinmc | 2:158d57cdbf1e | 2952 | print_t_rex_flag=1; |
robinmc | 2:158d57cdbf1e | 2953 | } else if (random_num>=6100&random_num<7000) { |
robinmc | 2:158d57cdbf1e | 2954 | print_rat_flag=1; |
robinmc | 2:158d57cdbf1e | 2955 | } else if (random_num>=7000&random_num<8000) { |
robinmc | 2:158d57cdbf1e | 2956 | print_hound_flag=1; |
robinmc | 2:158d57cdbf1e | 2957 | } else if (random_num>=8000&random_num<8200) { |
robinmc | 2:158d57cdbf1e | 2958 | print_speed_boost_flag=1; |
robinmc | 2:158d57cdbf1e | 2959 | } |
robinmc | 2:158d57cdbf1e | 2960 | break; |
robinmc | 2:158d57cdbf1e | 2961 | case 4: |
robinmc | 2:158d57cdbf1e | 2962 | if (random_num<1000) { |
robinmc | 2:158d57cdbf1e | 2963 | print_bear_flag=1; |
robinmc | 2:158d57cdbf1e | 2964 | } else if (random_num>=1000&random_num<3000) { |
robinmc | 2:158d57cdbf1e | 2965 | print_bird_flag=1; |
robinmc | 2:158d57cdbf1e | 2966 | } else if (random_num>=3000&random_num<3010) { |
robinmc | 2:158d57cdbf1e | 2967 | print_heart_flag=1; |
robinmc | 2:158d57cdbf1e | 2968 | } else if (random_num>=3010&random_num<3050) { |
robinmc | 2:158d57cdbf1e | 2969 | print_ammo_flag=1; |
robinmc | 2:158d57cdbf1e | 2970 | } else if (random_num>=3050&random_num<6000) { |
robinmc | 2:158d57cdbf1e | 2971 | print_cactus_flag=1; |
robinmc | 2:158d57cdbf1e | 2972 | } else if (random_num>=6000&random_num<6300) { |
robinmc | 2:158d57cdbf1e | 2973 | print_ammo_flag=1; |
robinmc | 2:158d57cdbf1e | 2974 | print_t_rex_flag=1; |
robinmc | 2:158d57cdbf1e | 2975 | } else if (random_num>=6300&random_num<7000) { |
robinmc | 2:158d57cdbf1e | 2976 | print_rat_flag=1; |
robinmc | 2:158d57cdbf1e | 2977 | } else if (random_num>=7000&random_num<8000) { |
robinmc | 2:158d57cdbf1e | 2978 | print_hound_flag=1; |
robinmc | 2:158d57cdbf1e | 2979 | } else if (random_num>=8000&random_num<8200) { |
robinmc | 2:158d57cdbf1e | 2980 | print_speed_boost_flag=1; |
robinmc | 2:158d57cdbf1e | 2981 | } else if (random_num>=8200&random_num<9000) { |
robinmc | 3:4b254b4bd6d4 | 2982 | print_quick_sand_flag=1; |
robinmc | 2:158d57cdbf1e | 2983 | } |
robinmc | 2:158d57cdbf1e | 2984 | break; |
robinmc | 1:046e66f1ca76 | 2985 | } |
robinmc | 2:158d57cdbf1e | 2986 | } |
robinmc | 2:158d57cdbf1e | 2987 | |
robinmc | 3:4b254b4bd6d4 | 2988 | |
robinmc | 3:4b254b4bd6d4 | 2989 | //Game over funtion |
robinmc | 2:158d57cdbf1e | 2990 | int Game_over() |
robinmc | 2:158d57cdbf1e | 2991 | { |
robinmc | 1:046e66f1ca76 | 2992 | led_bar(); |
robinmc | 3:4b254b4bd6d4 | 2993 | lcd.clear(); //Clear all the pixels on the LCD screen |
robinmc | 2:158d57cdbf1e | 2994 | sort_top_scores(); |
robinmc | 2:158d57cdbf1e | 2995 | writeSD(); |
robinmc | 2:158d57cdbf1e | 2996 | lcd.printString("GAME",25,1); |
robinmc | 2:158d57cdbf1e | 2997 | lcd.printString("OVER",25,2); |
robinmc | 2:158d57cdbf1e | 2998 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 2999 | ticker_wait(10); |
robinmc | 0:28392431dbad | 3000 | lcd.printString("A Retry",40,4); |
robinmc | 0:28392431dbad | 3001 | lcd.printString("B Back to Menu",0,5); |
robinmc | 1:046e66f1ca76 | 3002 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 3003 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 3004 | g_press_b_B_flag=0; |
robinmc | 0:28392431dbad | 3005 | while (1) { |
robinmc | 2:158d57cdbf1e | 3006 | if (g_press_b_A_flag|g_press_b_B_flag) { |
robinmc | 2:158d57cdbf1e | 3007 | if (g_press_b_A_flag) { |
robinmc | 1:046e66f1ca76 | 3008 | initialize_values(); |
robinmc | 2:158d57cdbf1e | 3009 | g_press_b_A_flag=0; |
robinmc | 2:158d57cdbf1e | 3010 | return 1; |
robinmc | 2:158d57cdbf1e | 3011 | } else { |
robinmc | 1:046e66f1ca76 | 3012 | initialize_values(); |
robinmc | 2:158d57cdbf1e | 3013 | g_press_b_B_flag=0; |
robinmc | 2:158d57cdbf1e | 3014 | return 0; |
robinmc | 1:046e66f1ca76 | 3015 | } |
robinmc | 0:28392431dbad | 3016 | } |
robinmc | 3:4b254b4bd6d4 | 3017 | sleep(); //puts mbed to sleep |
robinmc | 0:28392431dbad | 3018 | } |
robinmc | 0:28392431dbad | 3019 | } |
robinmc | 0:28392431dbad | 3020 | |
robinmc | 3:4b254b4bd6d4 | 3021 | //Print ammo |
robinmc | 0:28392431dbad | 3022 | void print_ammo() |
robinmc | 0:28392431dbad | 3023 | { |
robinmc | 0:28392431dbad | 3024 | for(int c=0; c<=2; c++) { // 2 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 3025 | for(int r=0; r<=4; r++) { |
robinmc | 0:28392431dbad | 3026 | for (int n=70; n<=74; n+=4) { |
robinmc | 0:28392431dbad | 3027 | if (n==74&ammo%10==0) { |
robinmc | 0:28392431dbad | 3028 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 3029 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3030 | } else { |
robinmc | 0:28392431dbad | 3031 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3032 | } |
robinmc | 0:28392431dbad | 3033 | } else if (n==74&ammo%10==1) { |
robinmc | 0:28392431dbad | 3034 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 3035 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3036 | } else { |
robinmc | 0:28392431dbad | 3037 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3038 | } |
robinmc | 0:28392431dbad | 3039 | } else if (n==74&ammo%10==2) { |
robinmc | 0:28392431dbad | 3040 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 3041 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3042 | } else { |
robinmc | 0:28392431dbad | 3043 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3044 | } |
robinmc | 0:28392431dbad | 3045 | } else if (n==74&ammo%10==3) { |
robinmc | 0:28392431dbad | 3046 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 3047 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3048 | } else { |
robinmc | 0:28392431dbad | 3049 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3050 | } |
robinmc | 0:28392431dbad | 3051 | } else if (n==74&ammo%10==4) { |
robinmc | 0:28392431dbad | 3052 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 3053 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3054 | } else { |
robinmc | 0:28392431dbad | 3055 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3056 | } |
robinmc | 0:28392431dbad | 3057 | } else if (n==74&ammo%10==5) { |
robinmc | 0:28392431dbad | 3058 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 3059 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3060 | } else { |
robinmc | 0:28392431dbad | 3061 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3062 | } |
robinmc | 0:28392431dbad | 3063 | } else if (n==74&ammo%10==6) { |
robinmc | 0:28392431dbad | 3064 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 3065 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3066 | } else { |
robinmc | 0:28392431dbad | 3067 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3068 | } |
robinmc | 0:28392431dbad | 3069 | } else if (n==74&ammo%10==7) { |
robinmc | 0:28392431dbad | 3070 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 3071 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3072 | } else { |
robinmc | 0:28392431dbad | 3073 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3074 | } |
robinmc | 0:28392431dbad | 3075 | } else if (n==74&ammo%10==8) { |
robinmc | 0:28392431dbad | 3076 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 3077 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3078 | } else { |
robinmc | 0:28392431dbad | 3079 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3080 | } |
robinmc | 0:28392431dbad | 3081 | } else if (n==74&ammo%10==9) { |
robinmc | 0:28392431dbad | 3082 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 3083 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3084 | } else { |
robinmc | 0:28392431dbad | 3085 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3086 | } |
robinmc | 0:28392431dbad | 3087 | } |
robinmc | 0:28392431dbad | 3088 | |
robinmc | 0:28392431dbad | 3089 | if (n==70&(ammo%100>=0&ammo%100<10)) { |
robinmc | 0:28392431dbad | 3090 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 3091 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3092 | } else { |
robinmc | 0:28392431dbad | 3093 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3094 | } |
robinmc | 0:28392431dbad | 3095 | } else if (n==70&(ammo%100>=10&ammo%100<20)) { |
robinmc | 0:28392431dbad | 3096 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 3097 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3098 | } else { |
robinmc | 0:28392431dbad | 3099 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3100 | } |
robinmc | 0:28392431dbad | 3101 | } else if (n==70&(ammo%100>=20&ammo%100<30)) { |
robinmc | 0:28392431dbad | 3102 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 3103 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3104 | } else { |
robinmc | 0:28392431dbad | 3105 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3106 | } |
robinmc | 0:28392431dbad | 3107 | } else if (n==70&(ammo%100>=30&ammo%100<40)) { |
robinmc | 0:28392431dbad | 3108 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 3109 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3110 | } else { |
robinmc | 0:28392431dbad | 3111 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3112 | } |
robinmc | 0:28392431dbad | 3113 | } else if (n==70&(ammo%100>=40&ammo%100<50)) { |
robinmc | 0:28392431dbad | 3114 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 3115 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3116 | } else { |
robinmc | 0:28392431dbad | 3117 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3118 | } |
robinmc | 0:28392431dbad | 3119 | } else if (n==70&(ammo%100>=50&ammo%100<60)) { |
robinmc | 0:28392431dbad | 3120 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 3121 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3122 | } else { |
robinmc | 0:28392431dbad | 3123 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3124 | } |
robinmc | 0:28392431dbad | 3125 | } else if (n==70&(ammo%100>=60&ammo%100<70)) { |
robinmc | 0:28392431dbad | 3126 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 3127 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3128 | } else { |
robinmc | 0:28392431dbad | 3129 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3130 | } |
robinmc | 0:28392431dbad | 3131 | } else if (n==70&(ammo%100>=70&ammo%100<80)) { |
robinmc | 0:28392431dbad | 3132 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 3133 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3134 | } else { |
robinmc | 0:28392431dbad | 3135 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3136 | } |
robinmc | 0:28392431dbad | 3137 | } else if (n==70&(ammo%100>=80&ammo%100<90)) { |
robinmc | 0:28392431dbad | 3138 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 3139 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3140 | } else { |
robinmc | 0:28392431dbad | 3141 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3142 | } |
robinmc | 0:28392431dbad | 3143 | } else if (n==70&(ammo%100>=90&ammo%100<100)) { |
robinmc | 0:28392431dbad | 3144 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 3145 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3146 | } else { |
robinmc | 0:28392431dbad | 3147 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3148 | } |
robinmc | 0:28392431dbad | 3149 | } |
robinmc | 0:28392431dbad | 3150 | } |
robinmc | 0:28392431dbad | 3151 | } |
robinmc | 0:28392431dbad | 3152 | } |
robinmc | 0:28392431dbad | 3153 | for(int c=0; c<=14; c++) { //14 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 3154 | for(int r=0; r<=4; r++) { |
robinmc | 0:28392431dbad | 3155 | if (g_ammo[r][c]==0) { |
robinmc | 0:28392431dbad | 3156 | lcd.clearPixel(c+50,r); |
robinmc | 0:28392431dbad | 3157 | } else if (g_ammo[r][c]==1) { |
robinmc | 0:28392431dbad | 3158 | lcd.setPixel(c+50,r); |
robinmc | 0:28392431dbad | 3159 | } |
robinmc | 0:28392431dbad | 3160 | } |
robinmc | 0:28392431dbad | 3161 | } |
robinmc | 0:28392431dbad | 3162 | if (ammo>=99) { |
robinmc | 0:28392431dbad | 3163 | ammo=99; |
robinmc | 0:28392431dbad | 3164 | } |
robinmc | 0:28392431dbad | 3165 | lcd.refresh(); |
robinmc | 0:28392431dbad | 3166 | } |
robinmc | 0:28392431dbad | 3167 | |
robinmc | 3:4b254b4bd6d4 | 3168 | //Print score |
robinmc | 0:28392431dbad | 3169 | void print_score() |
robinmc | 0:28392431dbad | 3170 | { |
robinmc | 2:158d57cdbf1e | 3171 | score=h_movement/10+kill_score-shield_score; |
robinmc | 0:28392431dbad | 3172 | if (score<=0) { |
robinmc | 0:28392431dbad | 3173 | score=0; |
robinmc | 0:28392431dbad | 3174 | } |
robinmc | 0:28392431dbad | 3175 | for(int c=0; c<=2; c++) { //2 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 3176 | for(int r=0; r<=4; r++) { |
robinmc | 0:28392431dbad | 3177 | for (int n=24; n<=36; n+=4) { |
robinmc | 0:28392431dbad | 3178 | if (n==36&score%10==0) { |
robinmc | 0:28392431dbad | 3179 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 3180 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3181 | } else { |
robinmc | 0:28392431dbad | 3182 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3183 | } |
robinmc | 0:28392431dbad | 3184 | } else if (n==36&score%10==1) { |
robinmc | 0:28392431dbad | 3185 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 3186 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3187 | } else { |
robinmc | 0:28392431dbad | 3188 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3189 | } |
robinmc | 0:28392431dbad | 3190 | } else if (n==36&score%10==2) { |
robinmc | 0:28392431dbad | 3191 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 3192 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3193 | } else { |
robinmc | 0:28392431dbad | 3194 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3195 | } |
robinmc | 0:28392431dbad | 3196 | } else if (n==36&score%10==3) { |
robinmc | 0:28392431dbad | 3197 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 3198 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3199 | } else { |
robinmc | 0:28392431dbad | 3200 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3201 | } |
robinmc | 0:28392431dbad | 3202 | } else if (n==36&score%10==4) { |
robinmc | 0:28392431dbad | 3203 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 3204 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3205 | } else { |
robinmc | 0:28392431dbad | 3206 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3207 | } |
robinmc | 0:28392431dbad | 3208 | } else if (n==36&score%10==5) { |
robinmc | 0:28392431dbad | 3209 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 3210 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3211 | } else { |
robinmc | 0:28392431dbad | 3212 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3213 | } |
robinmc | 0:28392431dbad | 3214 | } else if (n==36&score%10==6) { |
robinmc | 0:28392431dbad | 3215 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 3216 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3217 | } else { |
robinmc | 0:28392431dbad | 3218 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3219 | } |
robinmc | 0:28392431dbad | 3220 | } else if (n==36&score%10==7) { |
robinmc | 0:28392431dbad | 3221 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 3222 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3223 | } else { |
robinmc | 0:28392431dbad | 3224 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3225 | } |
robinmc | 0:28392431dbad | 3226 | } else if (n==36&score%10==8) { |
robinmc | 0:28392431dbad | 3227 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 3228 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3229 | } else { |
robinmc | 0:28392431dbad | 3230 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3231 | } |
robinmc | 0:28392431dbad | 3232 | } else if (n==36&score%10==9) { |
robinmc | 0:28392431dbad | 3233 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 3234 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3235 | } else { |
robinmc | 0:28392431dbad | 3236 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3237 | } |
robinmc | 0:28392431dbad | 3238 | } |
robinmc | 0:28392431dbad | 3239 | |
robinmc | 0:28392431dbad | 3240 | if (n==32&(score%100>=0&score%100<10)) { |
robinmc | 0:28392431dbad | 3241 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 3242 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3243 | } else { |
robinmc | 0:28392431dbad | 3244 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3245 | } |
robinmc | 0:28392431dbad | 3246 | } else if (n==32&(score%100>=10&score%100<20)) { |
robinmc | 0:28392431dbad | 3247 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 3248 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3249 | } else { |
robinmc | 0:28392431dbad | 3250 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3251 | } |
robinmc | 0:28392431dbad | 3252 | } else if (n==32&(score%100>=20&score%100<30)) { |
robinmc | 0:28392431dbad | 3253 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 3254 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3255 | } else { |
robinmc | 0:28392431dbad | 3256 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3257 | } |
robinmc | 0:28392431dbad | 3258 | } else if (n==32&(score%100>=30&score%100<40)) { |
robinmc | 0:28392431dbad | 3259 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 3260 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3261 | } else { |
robinmc | 0:28392431dbad | 3262 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3263 | } |
robinmc | 0:28392431dbad | 3264 | } else if (n==32&(score%100>=40&score%100<50)) { |
robinmc | 0:28392431dbad | 3265 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 3266 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3267 | } else { |
robinmc | 0:28392431dbad | 3268 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3269 | } |
robinmc | 0:28392431dbad | 3270 | } else if (n==32&(score%100>=50&score%100<60)) { |
robinmc | 0:28392431dbad | 3271 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 3272 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3273 | } else { |
robinmc | 0:28392431dbad | 3274 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3275 | } |
robinmc | 0:28392431dbad | 3276 | } else if (n==32&(score%100>=60&score%100<70)) { |
robinmc | 0:28392431dbad | 3277 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 3278 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3279 | } else { |
robinmc | 0:28392431dbad | 3280 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3281 | } |
robinmc | 0:28392431dbad | 3282 | } else if (n==32&(score%100>=70&score%100<80)) { |
robinmc | 0:28392431dbad | 3283 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 3284 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3285 | } else { |
robinmc | 0:28392431dbad | 3286 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3287 | } |
robinmc | 0:28392431dbad | 3288 | } else if (n==32&(score%100>=80&score%100<90)) { |
robinmc | 0:28392431dbad | 3289 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 3290 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3291 | } else { |
robinmc | 0:28392431dbad | 3292 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3293 | } |
robinmc | 0:28392431dbad | 3294 | } else if (n==32&(score%100>=90&score%100<100)) { |
robinmc | 0:28392431dbad | 3295 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 3296 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3297 | } else { |
robinmc | 0:28392431dbad | 3298 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3299 | } |
robinmc | 0:28392431dbad | 3300 | } |
robinmc | 0:28392431dbad | 3301 | if (n==28&(score%1000>=0&score%1000<100)) { |
robinmc | 0:28392431dbad | 3302 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 3303 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3304 | } else { |
robinmc | 0:28392431dbad | 3305 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3306 | } |
robinmc | 0:28392431dbad | 3307 | } else if (n==28&(score%1000>=100&score%1000<200)) { |
robinmc | 0:28392431dbad | 3308 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 3309 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3310 | } else { |
robinmc | 0:28392431dbad | 3311 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3312 | } |
robinmc | 0:28392431dbad | 3313 | } else if (n==28&(score%1000>=200&score%1000<300)) { |
robinmc | 0:28392431dbad | 3314 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 3315 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3316 | } else { |
robinmc | 0:28392431dbad | 3317 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3318 | } |
robinmc | 0:28392431dbad | 3319 | } else if (n==28&(score%1000>=300&score%1000<400)) { |
robinmc | 0:28392431dbad | 3320 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 3321 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3322 | } else { |
robinmc | 0:28392431dbad | 3323 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3324 | } |
robinmc | 0:28392431dbad | 3325 | } else if (n==28&(score%1000>=400&score%1000<500)) { |
robinmc | 0:28392431dbad | 3326 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 3327 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3328 | } else { |
robinmc | 0:28392431dbad | 3329 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3330 | } |
robinmc | 0:28392431dbad | 3331 | } else if (n==28&(score%1000>=500&score%1000<600)) { |
robinmc | 0:28392431dbad | 3332 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 3333 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3334 | } else { |
robinmc | 0:28392431dbad | 3335 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3336 | } |
robinmc | 0:28392431dbad | 3337 | } else if (n==28&(score%1000>=600&score%1000<700)) { |
robinmc | 0:28392431dbad | 3338 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 3339 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3340 | } else { |
robinmc | 0:28392431dbad | 3341 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3342 | } |
robinmc | 0:28392431dbad | 3343 | } else if (n==28&(score%1000>=700&score%1000<800)) { |
robinmc | 0:28392431dbad | 3344 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 3345 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3346 | } else { |
robinmc | 0:28392431dbad | 3347 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3348 | } |
robinmc | 0:28392431dbad | 3349 | } else if (n==28&(score%1000>=800&score%1000<900)) { |
robinmc | 0:28392431dbad | 3350 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 3351 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3352 | } else { |
robinmc | 0:28392431dbad | 3353 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3354 | } |
robinmc | 0:28392431dbad | 3355 | } else if (n==28&(score%1000>=900&score%1000<1000)) { |
robinmc | 0:28392431dbad | 3356 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 3357 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3358 | } else { |
robinmc | 0:28392431dbad | 3359 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3360 | } |
robinmc | 0:28392431dbad | 3361 | } |
robinmc | 0:28392431dbad | 3362 | if (n==24&(score%10000>=0&score%10000<1000)) { |
robinmc | 0:28392431dbad | 3363 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 3364 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3365 | } else { |
robinmc | 0:28392431dbad | 3366 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3367 | } |
robinmc | 0:28392431dbad | 3368 | } else if (n==24&(score%10000>=1000&score%10000<2000)) { |
robinmc | 0:28392431dbad | 3369 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 3370 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3371 | } else { |
robinmc | 0:28392431dbad | 3372 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3373 | } |
robinmc | 0:28392431dbad | 3374 | } else if (n==24&(score%10000>=2000&score%10000<3000)) { |
robinmc | 0:28392431dbad | 3375 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 3376 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3377 | } else { |
robinmc | 0:28392431dbad | 3378 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3379 | } |
robinmc | 0:28392431dbad | 3380 | } else if (n==24&(score%10000>=3000&score%10000<4000)) { |
robinmc | 0:28392431dbad | 3381 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 3382 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3383 | } else { |
robinmc | 0:28392431dbad | 3384 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3385 | } |
robinmc | 0:28392431dbad | 3386 | } else if (n==24&(score%10000>=4000&score%10000<5000)) { |
robinmc | 0:28392431dbad | 3387 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 3388 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3389 | } else { |
robinmc | 0:28392431dbad | 3390 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3391 | } |
robinmc | 0:28392431dbad | 3392 | } else if (n==24&(score%10000>=5000&score%10000<6000)) { |
robinmc | 0:28392431dbad | 3393 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 3394 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3395 | } else { |
robinmc | 0:28392431dbad | 3396 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3397 | } |
robinmc | 0:28392431dbad | 3398 | } else if (n==24&(score%10000>=6000&score%10000<7000)) { |
robinmc | 0:28392431dbad | 3399 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 3400 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3401 | } else { |
robinmc | 0:28392431dbad | 3402 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3403 | } |
robinmc | 0:28392431dbad | 3404 | } else if (n==24&(score%10000>=7000&score%10000<8000)) { |
robinmc | 0:28392431dbad | 3405 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 3406 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3407 | } else { |
robinmc | 0:28392431dbad | 3408 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3409 | } |
robinmc | 0:28392431dbad | 3410 | } else if (n==24&(score%10000>=8000&score%10000<9000)) { |
robinmc | 0:28392431dbad | 3411 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 3412 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3413 | } else { |
robinmc | 0:28392431dbad | 3414 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3415 | } |
robinmc | 0:28392431dbad | 3416 | } else if (n==24&(score%10000>=9000&score%10000<10000)) { |
robinmc | 0:28392431dbad | 3417 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 3418 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 3419 | } else { |
robinmc | 0:28392431dbad | 3420 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 3421 | } |
robinmc | 0:28392431dbad | 3422 | } |
robinmc | 0:28392431dbad | 3423 | } |
robinmc | 0:28392431dbad | 3424 | } |
robinmc | 0:28392431dbad | 3425 | } |
robinmc | 0:28392431dbad | 3426 | for(int c=0; c<=18; c++) { //18 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 3427 | for(int r=0; r<=4; r++) { |
robinmc | 0:28392431dbad | 3428 | if (g_score[r][c]==0) { |
robinmc | 0:28392431dbad | 3429 | lcd.clearPixel(c,r); |
robinmc | 0:28392431dbad | 3430 | } else if (g_score[r][c]==1) { |
robinmc | 0:28392431dbad | 3431 | lcd.setPixel(c,r); |
robinmc | 0:28392431dbad | 3432 | } |
robinmc | 0:28392431dbad | 3433 | } |
robinmc | 0:28392431dbad | 3434 | } |
robinmc | 0:28392431dbad | 3435 | lcd.refresh(); |
robinmc | 2:158d57cdbf1e | 3436 | } |