Robin Milward Cooney 200849894

Dependencies:   N5110 SDFileSystem gameCharacters mbed

Committer:
robinmc
Date:
Wed May 04 10:12:58 2016 +0000
Revision:
2:158d57cdbf1e
Parent:
1:046e66f1ca76
Child:
3:4b254b4bd6d4
before deOx;

Who changed what in which revision?

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