Robin Milward Cooney 200849894
Dependencies: N5110 SDFileSystem gameCharacters mbed
main.cpp@1:046e66f1ca76, 2016-04-29 (annotated)
- Committer:
- robinmc
- Date:
- Fri Apr 29 10:45:15 2016 +0000
- Revision:
- 1:046e66f1ca76
- Parent:
- 0:28392431dbad
- Child:
- 2:158d57cdbf1e
getting rid of gotos
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:28392431dbad | 9 | #include "mbed.h" |
robinmc | 0:28392431dbad | 10 | #include "N5110.h" |
robinmc | 0:28392431dbad | 11 | #include "math.h" |
robinmc | 0:28392431dbad | 12 | #include "stdint.h" |
robinmc | 0:28392431dbad | 13 | #include "tone.h" |
robinmc | 1:046e66f1ca76 | 14 | #include "SDFileSystem.h" |
robinmc | 0:28392431dbad | 15 | #include "gameCharacters.h" |
robinmc | 0:28392431dbad | 16 | |
robinmc | 0:28392431dbad | 17 | #define joystickTolerance 0.05f |
robinmc | 0:28392431dbad | 18 | |
robinmc | 0:28392431dbad | 19 | N5110 lcd(PTE26,PTA0,PTC4,PTD0,PTD2,PTD1,PTC3); //declare LCD |
robinmc | 0:28392431dbad | 20 | BusOut led(PTC8,PTC9,PTC0,PTC7,PTC5); //declare Bus output for LED bar |
robinmc | 1:046e66f1ca76 | 21 | SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS |
robinmc | 1:046e66f1ca76 | 22 | DigitalOut red_led(LED_RED); |
robinmc | 1:046e66f1ca76 | 23 | DigitalOut green_led(LED_GREEN); |
robinmc | 0:28392431dbad | 24 | DigitalIn swJoy(PTB18); //define potentiomiter switch |
robinmc | 0:28392431dbad | 25 | AnalogIn xPot(PTB2); //define x axis analoge in (this is the pot that corresponds to horizontal movement of the joystick) |
robinmc | 0:28392431dbad | 26 | AnalogIn yPot(PTB3); //define y axis analoge in (this is the pot that corresponds to vertical movement of the joystick) |
robinmc | 0:28392431dbad | 27 | DigitalIn b_A(PTE24); //define additional first button |
robinmc | 0:28392431dbad | 28 | DigitalIn b_B(PTE25); //define additional second button |
robinmc | 0:28392431dbad | 29 | PwmOut PWM(PTC11); |
robinmc | 0:28392431dbad | 30 | InterruptIn press_b_A(PTE24); //declare the push button A as an interrupt |
robinmc | 0:28392431dbad | 31 | InterruptIn press_b_B(PTE25); //declare the push button B as an interrupt |
robinmc | 0:28392431dbad | 32 | Ticker Ticker_Menu; |
robinmc | 0:28392431dbad | 33 | Ticker Ticker_Game; |
robinmc | 0:28392431dbad | 34 | |
robinmc | 0:28392431dbad | 35 | int i; //loop counter |
robinmc | 1:046e66f1ca76 | 36 | int run=0; |
robinmc | 0:28392431dbad | 37 | int loop=0; |
robinmc | 1:046e66f1ca76 | 38 | int difficulty=2; |
robinmc | 0:28392431dbad | 39 | int g_jump=36; |
robinmc | 0:28392431dbad | 40 | int jumpUp; |
robinmc | 0:28392431dbad | 41 | int accel=0; |
robinmc | 0:28392431dbad | 42 | int bullet=9; |
robinmc | 0:28392431dbad | 43 | int bullet_height; |
robinmc | 0:28392431dbad | 44 | int menu_select; |
robinmc | 1:046e66f1ca76 | 45 | int score=0; |
robinmc | 1:046e66f1ca76 | 46 | int highscore; |
robinmc | 0:28392431dbad | 47 | int kill_score; |
robinmc | 0:28392431dbad | 48 | int h_movement=0; |
robinmc | 0:28392431dbad | 49 | int ammo=24; |
robinmc | 1:046e66f1ca76 | 50 | int rat_movement=85; |
robinmc | 1:046e66f1ca76 | 51 | int hound_hMovement=90; |
robinmc | 1:046e66f1ca76 | 52 | int hound_vMovement=40; |
robinmc | 1:046e66f1ca76 | 53 | int hound_jump=0; |
robinmc | 0:28392431dbad | 54 | int bear_movement=100; |
robinmc | 0:28392431dbad | 55 | int bird_hMovement=95; |
robinmc | 0:28392431dbad | 56 | int bird_vMovement=20; |
robinmc | 0:28392431dbad | 57 | int cactus_movement=110; |
robinmc | 0:28392431dbad | 58 | int t_rex_movement=120; |
robinmc | 0:28392431dbad | 59 | int fire_ball_hMovement=t_rex_movement-6; |
robinmc | 1:046e66f1ca76 | 60 | int fire_ball_vMovement=25; |
robinmc | 0:28392431dbad | 61 | int heart_movement=90; |
robinmc | 0:28392431dbad | 62 | int ammo_movement=100; |
robinmc | 0:28392431dbad | 63 | int menuState=0; //initial state for the menu fsm |
robinmc | 0:28392431dbad | 64 | int jump_flag=0; |
robinmc | 0:28392431dbad | 65 | int shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 66 | int print_rat_flag=0; |
robinmc | 1:046e66f1ca76 | 67 | int print_hound_flag=0; |
robinmc | 1:046e66f1ca76 | 68 | int hound_jump_flag=0; |
robinmc | 0:28392431dbad | 69 | int print_bear_flag=0; |
robinmc | 0:28392431dbad | 70 | int print_bird_flag=0; |
robinmc | 0:28392431dbad | 71 | int print_heart_flag=0; |
robinmc | 0:28392431dbad | 72 | int print_ammo_flag=0; |
robinmc | 0:28392431dbad | 73 | int print_cactus_flag=0; |
robinmc | 0:28392431dbad | 74 | int print_t_rex_flag=0; |
robinmc | 0:28392431dbad | 75 | int print_fire_ball_flag=0; |
robinmc | 0:28392431dbad | 76 | int lose_lives_delay_flag=0; |
robinmc | 0:28392431dbad | 77 | int lives_delay_loop=0; //number of times the lose_lives_delay_flag if statement has iterated |
robinmc | 0:28392431dbad | 78 | int fire_on_screen=0; |
robinmc | 1:046e66f1ca76 | 79 | int story_progress=1; |
robinmc | 0:28392431dbad | 80 | double lives=4; |
robinmc | 0:28392431dbad | 81 | int bear_lives=0; |
robinmc | 0:28392431dbad | 82 | int t_rex_lives=0; |
robinmc | 0:28392431dbad | 83 | int random_num; |
robinmc | 1:046e66f1ca76 | 84 | float brightness=0.5; |
robinmc | 0:28392431dbad | 85 | volatile int g_Ticker_Menu_flag=0; |
robinmc | 0:28392431dbad | 86 | volatile int g_Ticker_Game_flag=0; |
robinmc | 0:28392431dbad | 87 | volatile int g_press_b_A_flag=0; |
robinmc | 0:28392431dbad | 88 | volatile int g_press_b_B_flag=0; |
robinmc | 0:28392431dbad | 89 | |
robinmc | 0:28392431dbad | 90 | void initialize_values() |
robinmc | 0:28392431dbad | 91 | { |
robinmc | 1:046e66f1ca76 | 92 | red_led = 1; |
robinmc | 1:046e66f1ca76 | 93 | green_led=1; |
robinmc | 0:28392431dbad | 94 | i=0; //loop counter |
robinmc | 0:28392431dbad | 95 | loop=0; |
robinmc | 0:28392431dbad | 96 | g_jump=36; |
robinmc | 0:28392431dbad | 97 | accel=0; |
robinmc | 0:28392431dbad | 98 | bullet=9; |
robinmc | 0:28392431dbad | 99 | h_movement=0; |
robinmc | 0:28392431dbad | 100 | ammo=24; |
robinmc | 1:046e66f1ca76 | 101 | rat_movement=85; |
robinmc | 1:046e66f1ca76 | 102 | hound_hMovement=90; |
robinmc | 1:046e66f1ca76 | 103 | hound_vMovement=40; |
robinmc | 1:046e66f1ca76 | 104 | hound_jump=0; |
robinmc | 0:28392431dbad | 105 | bear_movement=100; |
robinmc | 0:28392431dbad | 106 | bird_hMovement=95; |
robinmc | 0:28392431dbad | 107 | bird_vMovement=20; |
robinmc | 0:28392431dbad | 108 | cactus_movement=110; |
robinmc | 0:28392431dbad | 109 | t_rex_movement=120; |
robinmc | 0:28392431dbad | 110 | fire_ball_hMovement=t_rex_movement-6; |
robinmc | 1:046e66f1ca76 | 111 | fire_ball_vMovement=25; |
robinmc | 0:28392431dbad | 112 | heart_movement=90; |
robinmc | 0:28392431dbad | 113 | ammo_movement=100; |
robinmc | 0:28392431dbad | 114 | menuState=0; //initial state for the menu fsm |
robinmc | 0:28392431dbad | 115 | jump_flag=0; |
robinmc | 0:28392431dbad | 116 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 117 | print_rat_flag=0; |
robinmc | 1:046e66f1ca76 | 118 | print_hound_flag=0; |
robinmc | 1:046e66f1ca76 | 119 | hound_jump_flag=0; |
robinmc | 0:28392431dbad | 120 | print_bear_flag=0; |
robinmc | 0:28392431dbad | 121 | print_bird_flag=0; |
robinmc | 0:28392431dbad | 122 | print_heart_flag=0; |
robinmc | 0:28392431dbad | 123 | print_ammo_flag=0; |
robinmc | 0:28392431dbad | 124 | print_cactus_flag=0; |
robinmc | 0:28392431dbad | 125 | print_t_rex_flag=0; |
robinmc | 0:28392431dbad | 126 | print_fire_ball_flag=0; |
robinmc | 0:28392431dbad | 127 | lose_lives_delay_flag=0; |
robinmc | 0:28392431dbad | 128 | lives_delay_loop=0; |
robinmc | 0:28392431dbad | 129 | lives=4; |
robinmc | 0:28392431dbad | 130 | bear_lives=0; |
robinmc | 0:28392431dbad | 131 | score=0; |
robinmc | 0:28392431dbad | 132 | kill_score=0; |
robinmc | 0:28392431dbad | 133 | fire_on_screen=0; |
robinmc | 0:28392431dbad | 134 | } |
robinmc | 0:28392431dbad | 135 | |
robinmc | 0:28392431dbad | 136 | void generate_random_number() |
robinmc | 0:28392431dbad | 137 | { |
robinmc | 0:28392431dbad | 138 | time_t seconds = time(NULL); |
robinmc | 0:28392431dbad | 139 | srand(seconds); |
robinmc | 0:28392431dbad | 140 | random_num=rand()%10000; |
robinmc | 0:28392431dbad | 141 | } |
robinmc | 0:28392431dbad | 142 | void led_bar() //code to test led bar |
robinmc | 0:28392431dbad | 143 | { |
robinmc | 0:28392431dbad | 144 | led=pow(2,lives)-1; |
robinmc | 0:28392431dbad | 145 | if (lives>5) { |
robinmc | 0:28392431dbad | 146 | lives=5; |
robinmc | 0:28392431dbad | 147 | } |
robinmc | 0:28392431dbad | 148 | } |
robinmc | 0:28392431dbad | 149 | |
robinmc | 0:28392431dbad | 150 | |
robinmc | 0:28392431dbad | 151 | void ground() //funtion to print the ground |
robinmc | 0:28392431dbad | 152 | { |
robinmc | 0:28392431dbad | 153 | for (int x = 0; x<=84 ; x++) { |
robinmc | 0:28392431dbad | 154 | lcd.setPixel(x,47); |
robinmc | 0:28392431dbad | 155 | } |
robinmc | 0:28392431dbad | 156 | } |
robinmc | 0:28392431dbad | 157 | |
robinmc | 0:28392431dbad | 158 | void print_heart() |
robinmc | 0:28392431dbad | 159 | { |
robinmc | 0:28392431dbad | 160 | for(int c=0; c<=4; c++) { //4 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 161 | for(int r=0; r<=4; r++) { |
robinmc | 0:28392431dbad | 162 | if (g_heart[r][c]==0) { |
robinmc | 0:28392431dbad | 163 | if (lcd.getPixel(c+heart_movement,r+35)!=0) { |
robinmc | 0:28392431dbad | 164 | lcd.setPixel(c+heart_movement,r+35); |
robinmc | 0:28392431dbad | 165 | } else { |
robinmc | 0:28392431dbad | 166 | lcd.clearPixel(c+heart_movement,r+35); |
robinmc | 0:28392431dbad | 167 | } |
robinmc | 0:28392431dbad | 168 | } else if (g_heart[r][c]==1) { |
robinmc | 0:28392431dbad | 169 | lcd.setPixel(c+heart_movement,r+35); |
robinmc | 0:28392431dbad | 170 | } |
robinmc | 0:28392431dbad | 171 | } |
robinmc | 0:28392431dbad | 172 | } |
robinmc | 0:28392431dbad | 173 | } |
robinmc | 0:28392431dbad | 174 | |
robinmc | 0:28392431dbad | 175 | void print_ammo_pickUp() |
robinmc | 0:28392431dbad | 176 | { |
robinmc | 0:28392431dbad | 177 | for(int c=0; c<=6; c++) { //6 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 178 | for(int r=0; r<=7; r++) { |
robinmc | 0:28392431dbad | 179 | if (g_ammo_pickUp[r][c]==0) { |
robinmc | 0:28392431dbad | 180 | if (lcd.getPixel(c+ammo_movement,r+35)!=0) { |
robinmc | 0:28392431dbad | 181 | lcd.setPixel(c+ammo_movement,r+35); |
robinmc | 0:28392431dbad | 182 | } else { |
robinmc | 0:28392431dbad | 183 | lcd.clearPixel(c+ammo_movement,r+35); |
robinmc | 0:28392431dbad | 184 | } |
robinmc | 0:28392431dbad | 185 | } else if (g_ammo_pickUp[r][c]==1) { |
robinmc | 0:28392431dbad | 186 | lcd.setPixel(c+ammo_movement,r+35); |
robinmc | 0:28392431dbad | 187 | } |
robinmc | 0:28392431dbad | 188 | } |
robinmc | 0:28392431dbad | 189 | } |
robinmc | 0:28392431dbad | 190 | } |
robinmc | 0:28392431dbad | 191 | |
robinmc | 0:28392431dbad | 192 | void print_recks_still_gun() |
robinmc | 0:28392431dbad | 193 | { |
robinmc | 0:28392431dbad | 194 | |
robinmc | 0:28392431dbad | 195 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 196 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 197 | if (g_recks_still_gun[r][c]==0) { |
robinmc | 0:28392431dbad | 198 | if (lcd.getPixel(c+3,r+37)!=0) { |
robinmc | 0:28392431dbad | 199 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 200 | } else { |
robinmc | 0:28392431dbad | 201 | lcd.clearPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 202 | } |
robinmc | 0:28392431dbad | 203 | } else if (g_recks_still_gun[r][c]==1) { |
robinmc | 0:28392431dbad | 204 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 205 | } |
robinmc | 0:28392431dbad | 206 | } |
robinmc | 0:28392431dbad | 207 | } |
robinmc | 0:28392431dbad | 208 | } |
robinmc | 0:28392431dbad | 209 | |
robinmc | 0:28392431dbad | 210 | void print_recks_moving_gun() |
robinmc | 0:28392431dbad | 211 | { |
robinmc | 0:28392431dbad | 212 | |
robinmc | 0:28392431dbad | 213 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 214 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 215 | if (g_recks_moving_gun[r][c]==0) { |
robinmc | 0:28392431dbad | 216 | if (lcd.getPixel(c+3,r+37)!=0) { |
robinmc | 0:28392431dbad | 217 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 218 | } else { |
robinmc | 0:28392431dbad | 219 | lcd.clearPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 220 | } |
robinmc | 0:28392431dbad | 221 | } else if (g_recks_moving_gun[r][c]==1) { |
robinmc | 0:28392431dbad | 222 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 223 | } |
robinmc | 0:28392431dbad | 224 | } |
robinmc | 0:28392431dbad | 225 | } |
robinmc | 0:28392431dbad | 226 | } |
robinmc | 0:28392431dbad | 227 | |
robinmc | 0:28392431dbad | 228 | void print_recks_crouch_gun() |
robinmc | 0:28392431dbad | 229 | { |
robinmc | 0:28392431dbad | 230 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 231 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 232 | if (g_recks_crouch_gun[r][c]==0) { |
robinmc | 0:28392431dbad | 233 | if (lcd.getPixel(c+3,r+37)!=0) { |
robinmc | 0:28392431dbad | 234 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 235 | } else { |
robinmc | 0:28392431dbad | 236 | lcd.clearPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 237 | } |
robinmc | 0:28392431dbad | 238 | } else if (g_recks_crouch_gun[r][c]==1) { |
robinmc | 0:28392431dbad | 239 | lcd.setPixel(c+3,r+37); |
robinmc | 0:28392431dbad | 240 | } |
robinmc | 0:28392431dbad | 241 | } |
robinmc | 0:28392431dbad | 242 | } |
robinmc | 0:28392431dbad | 243 | } |
robinmc | 0:28392431dbad | 244 | |
robinmc | 0:28392431dbad | 245 | |
robinmc | 0:28392431dbad | 246 | void print_recks_jump_gun() |
robinmc | 0:28392431dbad | 247 | { |
robinmc | 0:28392431dbad | 248 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 249 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 250 | if (g_recks_jump_gun[r][c]==0) { |
robinmc | 0:28392431dbad | 251 | if (lcd.getPixel(c+3,r+g_jump)!=0) { |
robinmc | 0:28392431dbad | 252 | lcd.setPixel(c+3,r+g_jump); |
robinmc | 0:28392431dbad | 253 | } else { |
robinmc | 0:28392431dbad | 254 | lcd.clearPixel(c+3,r+g_jump); |
robinmc | 0:28392431dbad | 255 | } |
robinmc | 0:28392431dbad | 256 | } else if (g_recks_jump_gun[r][c]==1) { |
robinmc | 0:28392431dbad | 257 | lcd.setPixel(c+3,r+g_jump); |
robinmc | 0:28392431dbad | 258 | } |
robinmc | 0:28392431dbad | 259 | } |
robinmc | 0:28392431dbad | 260 | } |
robinmc | 0:28392431dbad | 261 | } |
robinmc | 0:28392431dbad | 262 | |
robinmc | 1:046e66f1ca76 | 263 | void print_mob_rat_p1() //funtion to print the still bear on the LCD |
robinmc | 1:046e66f1ca76 | 264 | { |
robinmc | 1:046e66f1ca76 | 265 | for(int c=0; c<=7; c++) { // 7 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 266 | for(int r=0; r<=2; r++) { |
robinmc | 1:046e66f1ca76 | 267 | if (g_mob_rat_p1[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 268 | if (lcd.getPixel(c+rat_movement,r+44)!=0) { |
robinmc | 1:046e66f1ca76 | 269 | lcd.setPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 270 | } else { |
robinmc | 1:046e66f1ca76 | 271 | lcd.clearPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 272 | } |
robinmc | 1:046e66f1ca76 | 273 | } else if (g_mob_rat_p1[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 274 | lcd.setPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 275 | } |
robinmc | 1:046e66f1ca76 | 276 | } |
robinmc | 1:046e66f1ca76 | 277 | } |
robinmc | 1:046e66f1ca76 | 278 | } |
robinmc | 1:046e66f1ca76 | 279 | |
robinmc | 1:046e66f1ca76 | 280 | void print_mob_rat_p2() //funtion to print the still bear on the LCD |
robinmc | 1:046e66f1ca76 | 281 | { |
robinmc | 1:046e66f1ca76 | 282 | for(int c=0; c<=7; c++) { // 7 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 283 | for(int r=0; r<=2; r++) { |
robinmc | 1:046e66f1ca76 | 284 | if (g_mob_rat_p2[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 285 | if (lcd.getPixel(c+rat_movement,r+44)!=0) { |
robinmc | 1:046e66f1ca76 | 286 | lcd.setPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 287 | } else { |
robinmc | 1:046e66f1ca76 | 288 | lcd.clearPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 289 | } |
robinmc | 1:046e66f1ca76 | 290 | } else if (g_mob_rat_p2[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 291 | lcd.setPixel(c+rat_movement,r+44); |
robinmc | 1:046e66f1ca76 | 292 | } |
robinmc | 1:046e66f1ca76 | 293 | } |
robinmc | 1:046e66f1ca76 | 294 | } |
robinmc | 1:046e66f1ca76 | 295 | } |
robinmc | 1:046e66f1ca76 | 296 | |
robinmc | 1:046e66f1ca76 | 297 | void print_mob_hound_p1() //funtion to print the still hound on the LCD |
robinmc | 1:046e66f1ca76 | 298 | { |
robinmc | 1:046e66f1ca76 | 299 | for(int c=0; c<=12; c++) { // 12 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 300 | for(int r=0; r<=7; r++) { |
robinmc | 1:046e66f1ca76 | 301 | if (g_mob_hound_p1[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 302 | if (lcd.getPixel(c+hound_hMovement,r+hound_vMovement)!=0) { |
robinmc | 1:046e66f1ca76 | 303 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 304 | } else { |
robinmc | 1:046e66f1ca76 | 305 | lcd.clearPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 306 | } |
robinmc | 1:046e66f1ca76 | 307 | } else if (g_mob_hound_p1[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 308 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 309 | } |
robinmc | 1:046e66f1ca76 | 310 | } |
robinmc | 1:046e66f1ca76 | 311 | } |
robinmc | 1:046e66f1ca76 | 312 | } |
robinmc | 1:046e66f1ca76 | 313 | |
robinmc | 1:046e66f1ca76 | 314 | void print_mob_hound_p2() //funtion to print the moving hound on the LCD |
robinmc | 1:046e66f1ca76 | 315 | { |
robinmc | 1:046e66f1ca76 | 316 | for(int c=0; c<=12; c++) { // 12 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 317 | for(int r=0; r<=7; r++) { |
robinmc | 1:046e66f1ca76 | 318 | if (g_mob_hound_p2[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 319 | if (lcd.getPixel(c+hound_hMovement,r+hound_vMovement)!=0) { |
robinmc | 1:046e66f1ca76 | 320 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 321 | } else { |
robinmc | 1:046e66f1ca76 | 322 | lcd.clearPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 323 | } |
robinmc | 1:046e66f1ca76 | 324 | } else if (g_mob_hound_p2[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 325 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 326 | } |
robinmc | 1:046e66f1ca76 | 327 | } |
robinmc | 1:046e66f1ca76 | 328 | } |
robinmc | 1:046e66f1ca76 | 329 | } |
robinmc | 1:046e66f1ca76 | 330 | |
robinmc | 1:046e66f1ca76 | 331 | void print_mob_hound_dead() //funtion to print the moving hound on the LCD |
robinmc | 1:046e66f1ca76 | 332 | { |
robinmc | 1:046e66f1ca76 | 333 | for(int c=0; c<=12; c++) { // 12 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 334 | for(int r=0; r<=7; r++) { |
robinmc | 1:046e66f1ca76 | 335 | if (g_mob_hound_dead[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 336 | if (lcd.getPixel(c+hound_hMovement,r+hound_vMovement)!=0) { |
robinmc | 1:046e66f1ca76 | 337 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 338 | } else { |
robinmc | 1:046e66f1ca76 | 339 | lcd.clearPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 340 | } |
robinmc | 1:046e66f1ca76 | 341 | } else if (g_mob_hound_dead[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 342 | lcd.setPixel(c+hound_hMovement,r+hound_vMovement); |
robinmc | 1:046e66f1ca76 | 343 | } |
robinmc | 1:046e66f1ca76 | 344 | } |
robinmc | 1:046e66f1ca76 | 345 | } |
robinmc | 1:046e66f1ca76 | 346 | } |
robinmc | 1:046e66f1ca76 | 347 | |
robinmc | 0:28392431dbad | 348 | void print_mob_bear_p1() //funtion to print the still bear on the LCD |
robinmc | 0:28392431dbad | 349 | { |
robinmc | 0:28392431dbad | 350 | for(int c=0; c<=18; c++) { //18 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 351 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 352 | if (g_mob_bear_p1[r][c]==0) { |
robinmc | 0:28392431dbad | 353 | if (lcd.getPixel(c+bear_movement,r+37)!=0) { |
robinmc | 0:28392431dbad | 354 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 355 | } else { |
robinmc | 0:28392431dbad | 356 | lcd.clearPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 357 | } |
robinmc | 0:28392431dbad | 358 | } else if (g_mob_bear_p1[r][c]==1) { |
robinmc | 0:28392431dbad | 359 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 360 | } |
robinmc | 0:28392431dbad | 361 | } |
robinmc | 0:28392431dbad | 362 | } |
robinmc | 0:28392431dbad | 363 | } |
robinmc | 0:28392431dbad | 364 | |
robinmc | 0:28392431dbad | 365 | void print_mob_bear_p2() //funtion to print the moving bear on the LCD |
robinmc | 0:28392431dbad | 366 | { |
robinmc | 0:28392431dbad | 367 | for(int c=0; c<=18; c++) { //18 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 368 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 369 | if (g_mob_bear_p2[r][c]==0) { |
robinmc | 0:28392431dbad | 370 | if (lcd.getPixel(c+bear_movement,r+37)!=0) { |
robinmc | 0:28392431dbad | 371 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 372 | } else { |
robinmc | 0:28392431dbad | 373 | lcd.clearPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 374 | } |
robinmc | 0:28392431dbad | 375 | } else if (g_mob_bear_p2[r][c]==1) { |
robinmc | 0:28392431dbad | 376 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 377 | } |
robinmc | 0:28392431dbad | 378 | } |
robinmc | 0:28392431dbad | 379 | } |
robinmc | 0:28392431dbad | 380 | } |
robinmc | 0:28392431dbad | 381 | |
robinmc | 1:046e66f1ca76 | 382 | void print_mob_bear_dead() //funtion to print the bead bear on the LCD |
robinmc | 0:28392431dbad | 383 | { |
robinmc | 0:28392431dbad | 384 | for(int c=0; c<=18; c++) { //18 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 385 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 386 | if (g_mob_bear_dead[r][c]==0) { |
robinmc | 0:28392431dbad | 387 | if (lcd.getPixel(c+bear_movement,r+37)!=0) { |
robinmc | 0:28392431dbad | 388 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 389 | } else { |
robinmc | 0:28392431dbad | 390 | lcd.clearPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 391 | } |
robinmc | 0:28392431dbad | 392 | } else if (g_mob_bear_dead[r][c]==1) { |
robinmc | 0:28392431dbad | 393 | lcd.setPixel(c+bear_movement,r+37); |
robinmc | 0:28392431dbad | 394 | } |
robinmc | 0:28392431dbad | 395 | } |
robinmc | 0:28392431dbad | 396 | } |
robinmc | 0:28392431dbad | 397 | } |
robinmc | 0:28392431dbad | 398 | |
robinmc | 0:28392431dbad | 399 | void print_mob_bird_p1() //funtion to print the moving bird on the LCD |
robinmc | 0:28392431dbad | 400 | { |
robinmc | 0:28392431dbad | 401 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 402 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 403 | if (g_mob_bird_p1[r][c]==0) { |
robinmc | 0:28392431dbad | 404 | if (lcd.getPixel(c+bird_hMovement,r+bird_vMovement)!=0) { |
robinmc | 0:28392431dbad | 405 | lcd.setPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 406 | } else { |
robinmc | 0:28392431dbad | 407 | lcd.clearPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 408 | } |
robinmc | 0:28392431dbad | 409 | } else if (g_mob_bird_p1[r][c]==1) { |
robinmc | 0:28392431dbad | 410 | lcd.setPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 411 | } |
robinmc | 0:28392431dbad | 412 | } |
robinmc | 0:28392431dbad | 413 | } |
robinmc | 0:28392431dbad | 414 | } |
robinmc | 0:28392431dbad | 415 | |
robinmc | 0:28392431dbad | 416 | void print_mob_bird_p2() //funtion to print the moving bird on the LCD |
robinmc | 0:28392431dbad | 417 | { |
robinmc | 0:28392431dbad | 418 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 419 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 420 | if (g_mob_bird_p2[r][c]==0) { |
robinmc | 0:28392431dbad | 421 | if (lcd.getPixel(c+bird_hMovement,r+bird_vMovement)!=0) { |
robinmc | 0:28392431dbad | 422 | lcd.setPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 423 | } else { |
robinmc | 0:28392431dbad | 424 | lcd.clearPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 425 | } |
robinmc | 0:28392431dbad | 426 | } else if (g_mob_bird_p2[r][c]==1) { |
robinmc | 0:28392431dbad | 427 | lcd.setPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 428 | } |
robinmc | 0:28392431dbad | 429 | } |
robinmc | 0:28392431dbad | 430 | } |
robinmc | 0:28392431dbad | 431 | } |
robinmc | 0:28392431dbad | 432 | |
robinmc | 0:28392431dbad | 433 | void print_mob_bird_dead() //funtion to print the moving bird on the LCD |
robinmc | 0:28392431dbad | 434 | { |
robinmc | 0:28392431dbad | 435 | for(int c=0; c<=9; c++) { //9 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 436 | for(int r=0; r<=9; r++) { |
robinmc | 0:28392431dbad | 437 | if (g_mob_bird_dead[r][c]==0) { |
robinmc | 0:28392431dbad | 438 | lcd.clearPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 439 | } else if (g_mob_bird_dead[r][c]==1) { |
robinmc | 0:28392431dbad | 440 | lcd.setPixel(c+bird_hMovement,r+bird_vMovement); |
robinmc | 0:28392431dbad | 441 | } |
robinmc | 0:28392431dbad | 442 | } |
robinmc | 0:28392431dbad | 443 | } |
robinmc | 0:28392431dbad | 444 | } |
robinmc | 0:28392431dbad | 445 | |
robinmc | 0:28392431dbad | 446 | void print_cactus() //funtion to print the moving bird on the LCD |
robinmc | 0:28392431dbad | 447 | { |
robinmc | 0:28392431dbad | 448 | for(int c=0; c<=4; c++) { //4 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 449 | for(int r=0; r<=11; r++) { |
robinmc | 0:28392431dbad | 450 | if (cactus[r][c]==0) { |
robinmc | 0:28392431dbad | 451 | if (lcd.getPixel(c+cactus_movement,r+35)!=0) { |
robinmc | 0:28392431dbad | 452 | lcd.setPixel(c+cactus_movement,r+35); |
robinmc | 0:28392431dbad | 453 | } else { |
robinmc | 0:28392431dbad | 454 | lcd.clearPixel(c+cactus_movement,r+35); |
robinmc | 0:28392431dbad | 455 | } |
robinmc | 0:28392431dbad | 456 | } else if (cactus[r][c]==1) { |
robinmc | 0:28392431dbad | 457 | lcd.setPixel(c+cactus_movement,r+35); |
robinmc | 0:28392431dbad | 458 | } |
robinmc | 0:28392431dbad | 459 | } |
robinmc | 0:28392431dbad | 460 | } |
robinmc | 0:28392431dbad | 461 | } |
robinmc | 0:28392431dbad | 462 | |
robinmc | 0:28392431dbad | 463 | void print_t_rex() |
robinmc | 0:28392431dbad | 464 | { |
robinmc | 0:28392431dbad | 465 | for(int c=0; c<=24; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 466 | for(int r=0; r<=27; r++) { |
robinmc | 0:28392431dbad | 467 | if (g_t_rex[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 468 | if (lcd.getPixel(c+t_rex_movement,r+19)!=0) { |
robinmc | 1:046e66f1ca76 | 469 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 470 | } else { |
robinmc | 1:046e66f1ca76 | 471 | lcd.clearPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 472 | } |
robinmc | 0:28392431dbad | 473 | } else if (g_t_rex[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 474 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 475 | } |
robinmc | 0:28392431dbad | 476 | } |
robinmc | 0:28392431dbad | 477 | } |
robinmc | 0:28392431dbad | 478 | } |
robinmc | 0:28392431dbad | 479 | |
robinmc | 0:28392431dbad | 480 | void print_t_rex_moving() |
robinmc | 0:28392431dbad | 481 | { |
robinmc | 0:28392431dbad | 482 | for(int c=0; c<=24; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 483 | for(int r=0; r<=27; r++) { |
robinmc | 0:28392431dbad | 484 | if (g_t_rex_moving[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 485 | if (lcd.getPixel(c+t_rex_movement,r+19)!=0) { |
robinmc | 1:046e66f1ca76 | 486 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 487 | } else { |
robinmc | 1:046e66f1ca76 | 488 | lcd.clearPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 489 | } |
robinmc | 0:28392431dbad | 490 | } else if (g_t_rex_moving[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 491 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 492 | } |
robinmc | 0:28392431dbad | 493 | } |
robinmc | 0:28392431dbad | 494 | } |
robinmc | 0:28392431dbad | 495 | } |
robinmc | 0:28392431dbad | 496 | |
robinmc | 0:28392431dbad | 497 | void print_t_rex_attack() |
robinmc | 0:28392431dbad | 498 | { |
robinmc | 0:28392431dbad | 499 | for(int c=0; c<=24; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 500 | for(int r=0; r<=27; r++) { |
robinmc | 0:28392431dbad | 501 | if (g_t_rex_attack[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 502 | if (lcd.getPixel(c+t_rex_movement,r+19)!=0) { |
robinmc | 1:046e66f1ca76 | 503 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 504 | } else { |
robinmc | 1:046e66f1ca76 | 505 | lcd.clearPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 506 | } |
robinmc | 0:28392431dbad | 507 | } else if (g_t_rex_attack[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 508 | lcd.setPixel(c+t_rex_movement,r+19); |
robinmc | 0:28392431dbad | 509 | } |
robinmc | 0:28392431dbad | 510 | } |
robinmc | 0:28392431dbad | 511 | } |
robinmc | 0:28392431dbad | 512 | } |
robinmc | 0:28392431dbad | 513 | |
robinmc | 0:28392431dbad | 514 | void print_fire_ball_p1() |
robinmc | 0:28392431dbad | 515 | { |
robinmc | 0:28392431dbad | 516 | for(int c=0; c<=8; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 517 | for(int r=0; r<=8; r++) { |
robinmc | 0:28392431dbad | 518 | if (g_fire_ball_p1[r][c]==0) { |
robinmc | 0:28392431dbad | 519 | if (lcd.getPixel(c+fire_ball_hMovement,r+fire_ball_vMovement)!=0) { |
robinmc | 0:28392431dbad | 520 | lcd.setPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 521 | } else { |
robinmc | 0:28392431dbad | 522 | lcd.clearPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 523 | } |
robinmc | 0:28392431dbad | 524 | } else if (g_fire_ball_p1[r][c]==1) { |
robinmc | 0:28392431dbad | 525 | lcd.setPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 526 | } |
robinmc | 0:28392431dbad | 527 | } |
robinmc | 0:28392431dbad | 528 | } |
robinmc | 0:28392431dbad | 529 | } |
robinmc | 0:28392431dbad | 530 | |
robinmc | 0:28392431dbad | 531 | void print_fire_ball_p2() |
robinmc | 0:28392431dbad | 532 | { |
robinmc | 0:28392431dbad | 533 | for(int c=0; c<=8; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 534 | for(int r=0; r<=8; r++) { |
robinmc | 0:28392431dbad | 535 | if (g_fire_ball_p2[r][c]==0) { |
robinmc | 0:28392431dbad | 536 | if (lcd.getPixel(c+fire_ball_hMovement,r+fire_ball_vMovement)!=0) { |
robinmc | 0:28392431dbad | 537 | lcd.setPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 538 | } else { |
robinmc | 0:28392431dbad | 539 | lcd.clearPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 540 | } |
robinmc | 0:28392431dbad | 541 | } else if (g_fire_ball_p2[r][c]==1) { |
robinmc | 0:28392431dbad | 542 | lcd.setPixel(c+fire_ball_hMovement,r+fire_ball_vMovement); |
robinmc | 0:28392431dbad | 543 | } |
robinmc | 0:28392431dbad | 544 | } |
robinmc | 0:28392431dbad | 545 | } |
robinmc | 0:28392431dbad | 546 | } |
robinmc | 0:28392431dbad | 547 | |
robinmc | 0:28392431dbad | 548 | |
robinmc | 0:28392431dbad | 549 | void print_clouds() |
robinmc | 0:28392431dbad | 550 | { |
robinmc | 0:28392431dbad | 551 | uint8_t clouds_movement=h_movement; //8 bit unsigned interger |
robinmc | 0:28392431dbad | 552 | for(int c=clouds_movement; c<=clouds_movement+83; c++) { |
robinmc | 0:28392431dbad | 553 | for(int r=0; r<=2; r++) { |
robinmc | 0:28392431dbad | 554 | if (g_clouds[r][c]==0) { |
robinmc | 0:28392431dbad | 555 | lcd.clearPixel(c-clouds_movement,r+6); |
robinmc | 0:28392431dbad | 556 | } else if (g_clouds[r][c]==1) { |
robinmc | 0:28392431dbad | 557 | lcd.setPixel(c-clouds_movement,r+6); |
robinmc | 0:28392431dbad | 558 | } |
robinmc | 0:28392431dbad | 559 | } |
robinmc | 0:28392431dbad | 560 | } |
robinmc | 0:28392431dbad | 561 | } |
robinmc | 0:28392431dbad | 562 | |
robinmc | 1:046e66f1ca76 | 563 | void print_locks() |
robinmc | 0:28392431dbad | 564 | { |
robinmc | 1:046e66f1ca76 | 565 | int sp=8*story_progress; |
robinmc | 1:046e66f1ca76 | 566 | for(int c=0; c<=3; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 567 | for(int r=0; r<=5; r++) { |
robinmc | 1:046e66f1ca76 | 568 | for (int n=1; n<=33; n+=8) { |
robinmc | 1:046e66f1ca76 | 569 | if (g_padlock_p1[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 570 | lcd.clearPixel(c+8,r+n); |
robinmc | 1:046e66f1ca76 | 571 | } else if (g_padlock_p1[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 572 | lcd.setPixel(c+8,r+n); |
robinmc | 1:046e66f1ca76 | 573 | } |
robinmc | 1:046e66f1ca76 | 574 | } |
robinmc | 0:28392431dbad | 575 | } |
robinmc | 0:28392431dbad | 576 | } |
robinmc | 1:046e66f1ca76 | 577 | for(int c=0; c<=3; c++) { //24 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 1:046e66f1ca76 | 578 | for(int r=0; r<=5; r++) { |
robinmc | 1:046e66f1ca76 | 579 | for (int n=1; n<=sp; n+=8) { |
robinmc | 1:046e66f1ca76 | 580 | if (g_padlock_p2[r][c]==0) { |
robinmc | 1:046e66f1ca76 | 581 | lcd.clearPixel(c+8,r+n); |
robinmc | 1:046e66f1ca76 | 582 | } else if (g_padlock_p2[r][c]==1) { |
robinmc | 1:046e66f1ca76 | 583 | lcd.setPixel(c+8,r+n); |
robinmc | 1:046e66f1ca76 | 584 | } |
robinmc | 1:046e66f1ca76 | 585 | } |
robinmc | 1:046e66f1ca76 | 586 | } |
robinmc | 1:046e66f1ca76 | 587 | } |
robinmc | 0:28392431dbad | 588 | } |
robinmc | 0:28392431dbad | 589 | |
robinmc | 1:046e66f1ca76 | 590 | |
robinmc | 0:28392431dbad | 591 | void shoot() |
robinmc | 0:28392431dbad | 592 | { |
robinmc | 0:28392431dbad | 593 | lcd.setPixel(bullet,g_jump+4); |
robinmc | 0:28392431dbad | 594 | lcd.setPixel(bullet+1,g_jump+4); |
robinmc | 0:28392431dbad | 595 | } |
robinmc | 0:28392431dbad | 596 | |
robinmc | 0:28392431dbad | 597 | void print_score(); |
robinmc | 0:28392431dbad | 598 | void print_ammo(); |
robinmc | 0:28392431dbad | 599 | |
robinmc | 0:28392431dbad | 600 | void intro() |
robinmc | 0:28392431dbad | 601 | { |
robinmc | 0:28392431dbad | 602 | |
robinmc | 0:28392431dbad | 603 | } |
robinmc | 0:28392431dbad | 604 | |
robinmc | 0:28392431dbad | 605 | void Ticker_Menu_isr() |
robinmc | 0:28392431dbad | 606 | { |
robinmc | 0:28392431dbad | 607 | g_Ticker_Menu_flag=1; |
robinmc | 0:28392431dbad | 608 | } |
robinmc | 0:28392431dbad | 609 | |
robinmc | 0:28392431dbad | 610 | void Ticker_Game_isr() |
robinmc | 0:28392431dbad | 611 | { |
robinmc | 0:28392431dbad | 612 | g_Ticker_Game_flag=1; |
robinmc | 0:28392431dbad | 613 | } |
robinmc | 0:28392431dbad | 614 | |
robinmc | 0:28392431dbad | 615 | void press_b_A_isr() |
robinmc | 0:28392431dbad | 616 | { |
robinmc | 0:28392431dbad | 617 | g_press_b_A_flag=1; |
robinmc | 0:28392431dbad | 618 | } |
robinmc | 0:28392431dbad | 619 | |
robinmc | 0:28392431dbad | 620 | enum joystickDirection { //emunm type for every neccessary direction of the joystick |
robinmc | 0:28392431dbad | 621 | CENTRE, //when the joystick isn't moved |
robinmc | 0:28392431dbad | 622 | DOWN, |
robinmc | 0:28392431dbad | 623 | UP, |
robinmc | 0:28392431dbad | 624 | LEFT, |
robinmc | 0:28392431dbad | 625 | RIGHT, |
robinmc | 0:28392431dbad | 626 | }; |
robinmc | 0:28392431dbad | 627 | |
robinmc | 0:28392431dbad | 628 | typedef struct JoyStick Joystick; //struct for Joystick |
robinmc | 0:28392431dbad | 629 | struct JoyStick { |
robinmc | 0:28392431dbad | 630 | float x; // current x value |
robinmc | 0:28392431dbad | 631 | float x0; // 'centred' x value |
robinmc | 0:28392431dbad | 632 | float y; // current y value |
robinmc | 0:28392431dbad | 633 | float y0; // 'centred' y value |
robinmc | 0:28392431dbad | 634 | int swJoy; // button state (assume pull-down used, so 1 = pressed, 0 = unpressed) |
robinmc | 0:28392431dbad | 635 | joystickDirection direction; // current direction |
robinmc | 0:28392431dbad | 636 | }; |
robinmc | 0:28392431dbad | 637 | // create struct variable |
robinmc | 0:28392431dbad | 638 | Joystick joystick; |
robinmc | 0:28392431dbad | 639 | |
robinmc | 0:28392431dbad | 640 | // read default positions of the joystick to calibrate later readings |
robinmc | 0:28392431dbad | 641 | void calibrateJoystick() |
robinmc | 0:28392431dbad | 642 | { |
robinmc | 0:28392431dbad | 643 | swJoy.mode(PullDown); |
robinmc | 0:28392431dbad | 644 | // must not move during calibration |
robinmc | 0:28392431dbad | 645 | joystick.x0 = xPot; // initial positions in the range 0.0 to 1.0 (0.5 if centred exactly) |
robinmc | 0:28392431dbad | 646 | joystick.y0 = yPot; |
robinmc | 0:28392431dbad | 647 | } |
robinmc | 0:28392431dbad | 648 | void updateJoystick() |
robinmc | 0:28392431dbad | 649 | { |
robinmc | 0:28392431dbad | 650 | // read current joystick values relative to calibrated values (in range -0.5 to 0.5, 0.0 is centred) |
robinmc | 0:28392431dbad | 651 | joystick.x = xPot - joystick.x0; |
robinmc | 0:28392431dbad | 652 | joystick.y = yPot - joystick.y0; |
robinmc | 0:28392431dbad | 653 | // read button state |
robinmc | 0:28392431dbad | 654 | joystick.swJoy = swJoy; |
robinmc | 0:28392431dbad | 655 | |
robinmc | 0:28392431dbad | 656 | // calculate direction depending on x,y values |
robinmc | 0:28392431dbad | 657 | // tolerance allows a little lee-way in case joystick not exactly in the stated direction |
robinmc | 0:28392431dbad | 658 | if ( fabs(joystick.y) < joystickTolerance && fabs(joystick.x) < joystickTolerance) { |
robinmc | 0:28392431dbad | 659 | joystick.direction = CENTRE; |
robinmc | 0:28392431dbad | 660 | } else if ( joystick.y > joystickTolerance && fabs(joystick.x) < joystickTolerance) { |
robinmc | 0:28392431dbad | 661 | joystick.direction = UP; |
robinmc | 0:28392431dbad | 662 | } else if ( joystick.y < joystickTolerance && fabs(joystick.x) < joystickTolerance) { |
robinmc | 0:28392431dbad | 663 | joystick.direction = DOWN; |
robinmc | 0:28392431dbad | 664 | } else if ( joystick.x > joystickTolerance && fabs(joystick.y) < joystickTolerance) { |
robinmc | 0:28392431dbad | 665 | joystick.direction = LEFT; |
robinmc | 0:28392431dbad | 666 | } else if ( joystick.x < joystickTolerance && fabs(joystick.y) < joystickTolerance) { |
robinmc | 0:28392431dbad | 667 | joystick.direction = RIGHT; |
robinmc | 0:28392431dbad | 668 | } |
robinmc | 0:28392431dbad | 669 | } |
robinmc | 0:28392431dbad | 670 | |
robinmc | 1:046e66f1ca76 | 671 | struct motion { //defines the motion of the characters |
robinmc | 0:28392431dbad | 672 | int x; |
robinmc | 0:28392431dbad | 673 | int v_x; |
robinmc | 0:28392431dbad | 674 | int acc_x; |
robinmc | 0:28392431dbad | 675 | int y; |
robinmc | 0:28392431dbad | 676 | int v_y; |
robinmc | 0:28392431dbad | 677 | int acc_y; |
robinmc | 0:28392431dbad | 678 | }; |
robinmc | 0:28392431dbad | 679 | |
robinmc | 0:28392431dbad | 680 | struct menuState { |
robinmc | 0:28392431dbad | 681 | int menu_select; // output value |
robinmc | 0:28392431dbad | 682 | int nextState[5]; // array of next states 6 to account for all of the joystick states |
robinmc | 0:28392431dbad | 683 | }; |
robinmc | 0:28392431dbad | 684 | typedef const struct menuState STyp; |
robinmc | 0:28392431dbad | 685 | |
robinmc | 0:28392431dbad | 686 | STyp fsm_main_menu[5] = { |
robinmc | 0:28392431dbad | 687 | {0,{0,1,4,0,0}}, |
robinmc | 0:28392431dbad | 688 | {8,{1,2,0,1,1}}, |
robinmc | 0:28392431dbad | 689 | {16,{2,3,1,2,2}}, |
robinmc | 0:28392431dbad | 690 | {24,{3,4,2,3,3}}, |
robinmc | 0:28392431dbad | 691 | {32,{4,0,3,4,4}} |
robinmc | 0:28392431dbad | 692 | }; |
robinmc | 0:28392431dbad | 693 | |
robinmc | 0:28392431dbad | 694 | STyp fsm_settings_menu[5] = { |
robinmc | 0:28392431dbad | 695 | {0,{0,1,1,0,0}}, |
robinmc | 0:28392431dbad | 696 | {8,{1,0,0,1,1}}, |
robinmc | 0:28392431dbad | 697 | {16,{2,2,2,2,2}}, |
robinmc | 0:28392431dbad | 698 | {24,{3,3,3,3,3}}, |
robinmc | 0:28392431dbad | 699 | {32,{4,4,4,4,4}} |
robinmc | 0:28392431dbad | 700 | }; |
robinmc | 0:28392431dbad | 701 | |
robinmc | 1:046e66f1ca76 | 702 | void game(); |
robinmc | 0:28392431dbad | 703 | int main() //main function, currently used to test different functions |
robinmc | 0:28392431dbad | 704 | { |
robinmc | 0:28392431dbad | 705 | b_A.mode(PullDown); |
robinmc | 0:28392431dbad | 706 | b_B.mode(PullDown); |
robinmc | 0:28392431dbad | 707 | swJoy.mode(PullDown); |
robinmc | 0:28392431dbad | 708 | initialize_values(); |
robinmc | 0:28392431dbad | 709 | lcd.init(); |
robinmc | 0:28392431dbad | 710 | Ticker_Menu.attach(&Ticker_Menu_isr,0.2); |
robinmc | 0:28392431dbad | 711 | Ticker_Game.attach(&Ticker_Game_isr,0.1); |
robinmc | 0:28392431dbad | 712 | //press_b_A.fall(&press_b_A_isr); |
robinmc | 0:28392431dbad | 713 | //press_b_A.mode(PullDown); |
robinmc | 0:28392431dbad | 714 | calibrateJoystick(); |
robinmc | 0:28392431dbad | 715 | |
robinmc | 0:28392431dbad | 716 | Menu: //declares a "goto" location for the goto functions |
robinmc | 1:046e66f1ca76 | 717 | menuState=0; |
robinmc | 0:28392431dbad | 718 | while(1) { |
robinmc | 0:28392431dbad | 719 | if (g_Ticker_Menu_flag) { |
robinmc | 0:28392431dbad | 720 | g_Ticker_Menu_flag=0; |
robinmc | 0:28392431dbad | 721 | updateJoystick(); |
robinmc | 1:046e66f1ca76 | 722 | lcd.setBrightness(brightness); |
robinmc | 0:28392431dbad | 723 | menu_select = fsm_main_menu[menuState].menu_select; // set ouput depending on current state |
robinmc | 0:28392431dbad | 724 | 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 | 725 | lcd.clear(); |
robinmc | 0:28392431dbad | 726 | lcd.printString("Story mode",13,0); |
robinmc | 0:28392431dbad | 727 | lcd.printString("Minigame",18,1); |
robinmc | 0:28392431dbad | 728 | lcd.printString("Settings",18,2); |
robinmc | 0:28392431dbad | 729 | lcd.printString("Leaderboard",9,3); |
robinmc | 0:28392431dbad | 730 | lcd.printString("Credits",21,4); |
robinmc | 0:28392431dbad | 731 | for (int i=0; i<85; i++) { //go through every pixel on the x axis |
robinmc | 0:28392431dbad | 732 | for (int j=menu_select; j<(menu_select+8); j++) { // go through relevant pixels on the y axis |
robinmc | 0:28392431dbad | 733 | if (lcd.getPixel(i,j)== 0) { //if the pixel is on trun it off |
robinmc | 0:28392431dbad | 734 | lcd.setPixel(i,j); |
robinmc | 0:28392431dbad | 735 | } else { |
robinmc | 0:28392431dbad | 736 | lcd.clearPixel(i,j); //if the pixel is off turn it on |
robinmc | 0:28392431dbad | 737 | } |
robinmc | 0:28392431dbad | 738 | } |
robinmc | 0:28392431dbad | 739 | } |
robinmc | 0:28392431dbad | 740 | lcd.refresh(); |
robinmc | 0:28392431dbad | 741 | if (b_A & menu_select==0) { |
robinmc | 0:28392431dbad | 742 | goto Story_Mode; |
robinmc | 0:28392431dbad | 743 | } else if (b_A & menu_select==8) { |
robinmc | 0:28392431dbad | 744 | goto Minigame; |
robinmc | 0:28392431dbad | 745 | } else if (b_A & menu_select==16) { |
robinmc | 0:28392431dbad | 746 | goto Settings; |
robinmc | 0:28392431dbad | 747 | } else if (b_A & menu_select==24) { |
robinmc | 0:28392431dbad | 748 | goto Leaderboard; |
robinmc | 0:28392431dbad | 749 | } else if (b_A & menu_select==32) { |
robinmc | 0:28392431dbad | 750 | goto Credits; |
robinmc | 0:28392431dbad | 751 | } |
robinmc | 0:28392431dbad | 752 | } |
robinmc | 0:28392431dbad | 753 | sleep(); |
robinmc | 0:28392431dbad | 754 | } |
robinmc | 0:28392431dbad | 755 | |
robinmc | 0:28392431dbad | 756 | Story_Mode: |
robinmc | 1:046e66f1ca76 | 757 | menuState=0; |
robinmc | 1:046e66f1ca76 | 758 | while(1) { |
robinmc | 1:046e66f1ca76 | 759 | if (g_Ticker_Menu_flag) { |
robinmc | 1:046e66f1ca76 | 760 | g_Ticker_Menu_flag=0; |
robinmc | 1:046e66f1ca76 | 761 | updateJoystick(); |
robinmc | 1:046e66f1ca76 | 762 | lcd.setBrightness(brightness); |
robinmc | 1:046e66f1ca76 | 763 | menu_select = fsm_main_menu[menuState].menu_select; // set ouput depending on current state |
robinmc | 1:046e66f1ca76 | 764 | 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 | 765 | lcd.clear(); |
robinmc | 1:046e66f1ca76 | 766 | print_locks(); |
robinmc | 1:046e66f1ca76 | 767 | lcd.printString("Chapter 1",20,0); |
robinmc | 1:046e66f1ca76 | 768 | lcd.printString("Chapter 2",20,1); |
robinmc | 1:046e66f1ca76 | 769 | lcd.printString("Chapter 3",20,2); |
robinmc | 1:046e66f1ca76 | 770 | lcd.printString("Chapter 4",20,3); |
robinmc | 1:046e66f1ca76 | 771 | lcd.printString("Chapter 5",20,4); |
robinmc | 1:046e66f1ca76 | 772 | for (int i=0; i<85; i++) { //go through every pixel on the x axis |
robinmc | 1:046e66f1ca76 | 773 | for (int j=menu_select; j<(menu_select+8); j++) { // go through relevant pixels on the y axis |
robinmc | 1:046e66f1ca76 | 774 | if (lcd.getPixel(i,j)== 0) { //if the pixel is on trun it off |
robinmc | 1:046e66f1ca76 | 775 | lcd.setPixel(i,j); |
robinmc | 1:046e66f1ca76 | 776 | } else { |
robinmc | 1:046e66f1ca76 | 777 | lcd.clearPixel(i,j); //if the pixel is off turn it on |
robinmc | 1:046e66f1ca76 | 778 | } |
robinmc | 1:046e66f1ca76 | 779 | } |
robinmc | 1:046e66f1ca76 | 780 | } |
robinmc | 1:046e66f1ca76 | 781 | lcd.refresh(); |
robinmc | 1:046e66f1ca76 | 782 | if (b_A & menu_select==0&story_progress<=1) { |
robinmc | 1:046e66f1ca76 | 783 | goto Story_Mode; |
robinmc | 1:046e66f1ca76 | 784 | } else if (b_A & menu_select==8&story_progress<=2) { |
robinmc | 1:046e66f1ca76 | 785 | goto Minigame; |
robinmc | 1:046e66f1ca76 | 786 | } else if (b_A & menu_select==16&story_progress<=3) { |
robinmc | 1:046e66f1ca76 | 787 | goto Settings; |
robinmc | 1:046e66f1ca76 | 788 | } else if (b_A & menu_select==24&story_progress<=4) { |
robinmc | 1:046e66f1ca76 | 789 | goto Leaderboard; |
robinmc | 1:046e66f1ca76 | 790 | } else if (b_A & menu_select==32&story_progress<=5) { |
robinmc | 1:046e66f1ca76 | 791 | goto Credits; |
robinmc | 1:046e66f1ca76 | 792 | } |
robinmc | 1:046e66f1ca76 | 793 | if (b_B) { |
robinmc | 1:046e66f1ca76 | 794 | goto Menu; |
robinmc | 1:046e66f1ca76 | 795 | } |
robinmc | 1:046e66f1ca76 | 796 | } |
robinmc | 1:046e66f1ca76 | 797 | sleep(); |
robinmc | 1:046e66f1ca76 | 798 | } |
robinmc | 0:28392431dbad | 799 | Settings: |
robinmc | 0:28392431dbad | 800 | menuState=0; |
robinmc | 0:28392431dbad | 801 | while (1) { |
robinmc | 0:28392431dbad | 802 | if (g_Ticker_Menu_flag) { |
robinmc | 0:28392431dbad | 803 | g_Ticker_Menu_flag=0; |
robinmc | 0:28392431dbad | 804 | updateJoystick(); |
robinmc | 0:28392431dbad | 805 | menu_select = fsm_settings_menu[menuState].menu_select; // set ouput depending on current state |
robinmc | 0:28392431dbad | 806 | 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 | 807 | lcd.clear(); |
robinmc | 0:28392431dbad | 808 | lcd.printString("Brightness",13,0); |
robinmc | 1:046e66f1ca76 | 809 | lcd.printString("Difficulty",13,1); |
robinmc | 0:28392431dbad | 810 | for (int i=0; i<85; i++) { //go through every pixel on the x axis |
robinmc | 0:28392431dbad | 811 | for (int j=menu_select; j<(menu_select+8); j++) { // go through relevant pixels on the y axis |
robinmc | 0:28392431dbad | 812 | if (lcd.getPixel(i,j)== 0) { //if the pixel is on trun it off |
robinmc | 0:28392431dbad | 813 | lcd.setPixel(i,j); |
robinmc | 0:28392431dbad | 814 | } else { |
robinmc | 0:28392431dbad | 815 | lcd.clearPixel(i,j); //if the pixel is off turn it on |
robinmc | 0:28392431dbad | 816 | } |
robinmc | 0:28392431dbad | 817 | } |
robinmc | 0:28392431dbad | 818 | } |
robinmc | 0:28392431dbad | 819 | lcd.refresh(); |
robinmc | 0:28392431dbad | 820 | if (b_A & menu_select==0) { |
robinmc | 0:28392431dbad | 821 | goto Brightness; |
robinmc | 0:28392431dbad | 822 | } else if (b_A & menu_select==8) { |
robinmc | 1:046e66f1ca76 | 823 | goto Difficulty; |
robinmc | 1:046e66f1ca76 | 824 | } |
robinmc | 1:046e66f1ca76 | 825 | if (b_B) { |
robinmc | 1:046e66f1ca76 | 826 | goto Menu; |
robinmc | 0:28392431dbad | 827 | } |
robinmc | 0:28392431dbad | 828 | } |
robinmc | 0:28392431dbad | 829 | } |
robinmc | 0:28392431dbad | 830 | Brightness: |
robinmc | 1:046e66f1ca76 | 831 | menuState=0; |
robinmc | 1:046e66f1ca76 | 832 | while(1) { |
robinmc | 1:046e66f1ca76 | 833 | if (g_Ticker_Menu_flag) { |
robinmc | 1:046e66f1ca76 | 834 | g_Ticker_Menu_flag=0; |
robinmc | 1:046e66f1ca76 | 835 | updateJoystick(); |
robinmc | 1:046e66f1ca76 | 836 | menu_select = fsm_main_menu[menuState].menu_select; // set ouput depending on current state |
robinmc | 1:046e66f1ca76 | 837 | 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 | 838 | lcd.clear(); |
robinmc | 1:046e66f1ca76 | 839 | lcd.printString("Dark",30,0); |
robinmc | 1:046e66f1ca76 | 840 | lcd.printString("Eco",33,1); |
robinmc | 1:046e66f1ca76 | 841 | lcd.printString("Regular",23,2); |
robinmc | 1:046e66f1ca76 | 842 | lcd.printString("Bright",26,3); |
robinmc | 1:046e66f1ca76 | 843 | lcd.printString("Blinding",20,4); |
robinmc | 1:046e66f1ca76 | 844 | for (int i=0; i<85; i++) { //go through every pixel on the x axis |
robinmc | 1:046e66f1ca76 | 845 | for (int j=menu_select; j<(menu_select+8); j++) { // go through relevant pixels on the y axis |
robinmc | 1:046e66f1ca76 | 846 | if (lcd.getPixel(i,j)== 0) { //if the pixel is on trun it off |
robinmc | 1:046e66f1ca76 | 847 | lcd.setPixel(i,j); |
robinmc | 1:046e66f1ca76 | 848 | } else { |
robinmc | 1:046e66f1ca76 | 849 | lcd.clearPixel(i,j); //if the pixel is off turn it on |
robinmc | 1:046e66f1ca76 | 850 | } |
robinmc | 1:046e66f1ca76 | 851 | } |
robinmc | 1:046e66f1ca76 | 852 | } |
robinmc | 1:046e66f1ca76 | 853 | lcd.refresh(); |
robinmc | 1:046e66f1ca76 | 854 | if (b_A & menu_select==0) { |
robinmc | 1:046e66f1ca76 | 855 | brightness=0; |
robinmc | 1:046e66f1ca76 | 856 | goto Menu; |
robinmc | 1:046e66f1ca76 | 857 | } else if (b_A & menu_select==8) { |
robinmc | 1:046e66f1ca76 | 858 | brightness=0.3; |
robinmc | 1:046e66f1ca76 | 859 | goto Menu; |
robinmc | 1:046e66f1ca76 | 860 | } else if (b_A & menu_select==16) { |
robinmc | 1:046e66f1ca76 | 861 | brightness=0.5; |
robinmc | 1:046e66f1ca76 | 862 | goto Menu; |
robinmc | 1:046e66f1ca76 | 863 | } else if (b_A & menu_select==24) { |
robinmc | 1:046e66f1ca76 | 864 | brightness=0.7; |
robinmc | 1:046e66f1ca76 | 865 | goto Menu; |
robinmc | 1:046e66f1ca76 | 866 | } else if (b_A & menu_select==32) { |
robinmc | 1:046e66f1ca76 | 867 | brightness=1; |
robinmc | 1:046e66f1ca76 | 868 | goto Menu; |
robinmc | 1:046e66f1ca76 | 869 | } |
robinmc | 1:046e66f1ca76 | 870 | if (b_B) { |
robinmc | 1:046e66f1ca76 | 871 | goto Settings; |
robinmc | 1:046e66f1ca76 | 872 | } |
robinmc | 1:046e66f1ca76 | 873 | } |
robinmc | 1:046e66f1ca76 | 874 | sleep(); |
robinmc | 1:046e66f1ca76 | 875 | } |
robinmc | 1:046e66f1ca76 | 876 | Difficulty: |
robinmc | 1:046e66f1ca76 | 877 | menuState=0; |
robinmc | 1:046e66f1ca76 | 878 | while(1) { |
robinmc | 1:046e66f1ca76 | 879 | if (g_Ticker_Menu_flag) { |
robinmc | 1:046e66f1ca76 | 880 | g_Ticker_Menu_flag=0; |
robinmc | 1:046e66f1ca76 | 881 | updateJoystick(); |
robinmc | 1:046e66f1ca76 | 882 | menu_select = fsm_main_menu[menuState].menu_select; // set ouput depending on current state |
robinmc | 1:046e66f1ca76 | 883 | 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 | 884 | lcd.clear(); |
robinmc | 1:046e66f1ca76 | 885 | lcd.printString("Piece of Cake",3,0); |
robinmc | 1:046e66f1ca76 | 886 | lcd.printString("Easy",30,1); |
robinmc | 1:046e66f1ca76 | 887 | lcd.printString("Regular",23,2); |
robinmc | 1:046e66f1ca76 | 888 | lcd.printString("Hard",30,3); |
robinmc | 1:046e66f1ca76 | 889 | lcd.printString("Legendary",15,4); |
robinmc | 1:046e66f1ca76 | 890 | for (int i=0; i<85; i++) { //go through every pixel on the x axis |
robinmc | 1:046e66f1ca76 | 891 | for (int j=menu_select; j<(menu_select+8); j++) { // go through relevant pixels on the y axis |
robinmc | 1:046e66f1ca76 | 892 | if (lcd.getPixel(i,j)== 0) { //if the pixel is on trun it off |
robinmc | 1:046e66f1ca76 | 893 | lcd.setPixel(i,j); |
robinmc | 1:046e66f1ca76 | 894 | } else { |
robinmc | 1:046e66f1ca76 | 895 | lcd.clearPixel(i,j); //if the pixel is off turn it on |
robinmc | 1:046e66f1ca76 | 896 | } |
robinmc | 1:046e66f1ca76 | 897 | } |
robinmc | 1:046e66f1ca76 | 898 | } |
robinmc | 1:046e66f1ca76 | 899 | lcd.refresh(); |
robinmc | 1:046e66f1ca76 | 900 | if (b_A & menu_select==0) { |
robinmc | 1:046e66f1ca76 | 901 | difficulty=0; |
robinmc | 1:046e66f1ca76 | 902 | goto Menu; |
robinmc | 1:046e66f1ca76 | 903 | } else if (b_A & menu_select==8) { |
robinmc | 1:046e66f1ca76 | 904 | difficulty=1; |
robinmc | 1:046e66f1ca76 | 905 | goto Menu; |
robinmc | 1:046e66f1ca76 | 906 | } else if (b_A & menu_select==16) { |
robinmc | 1:046e66f1ca76 | 907 | difficulty=2; |
robinmc | 1:046e66f1ca76 | 908 | goto Menu; |
robinmc | 1:046e66f1ca76 | 909 | } else if (b_A & menu_select==24) { |
robinmc | 1:046e66f1ca76 | 910 | difficulty=3; |
robinmc | 1:046e66f1ca76 | 911 | goto Menu; |
robinmc | 1:046e66f1ca76 | 912 | } else if (b_A & menu_select==32) { |
robinmc | 1:046e66f1ca76 | 913 | difficulty=4; |
robinmc | 1:046e66f1ca76 | 914 | goto Menu; |
robinmc | 1:046e66f1ca76 | 915 | } |
robinmc | 1:046e66f1ca76 | 916 | if (b_B) { |
robinmc | 1:046e66f1ca76 | 917 | goto Settings; |
robinmc | 1:046e66f1ca76 | 918 | } |
robinmc | 1:046e66f1ca76 | 919 | } |
robinmc | 1:046e66f1ca76 | 920 | sleep(); |
robinmc | 1:046e66f1ca76 | 921 | } |
robinmc | 0:28392431dbad | 922 | Leaderboard: |
robinmc | 1:046e66f1ca76 | 923 | while(1) { |
robinmc | 1:046e66f1ca76 | 924 | lcd.clear(); |
robinmc | 1:046e66f1ca76 | 925 | char buffer[14]; |
robinmc | 1:046e66f1ca76 | 926 | int p = sprintf(buffer,"%d",score); |
robinmc | 1:046e66f1ca76 | 927 | if (g_Ticker_Menu_flag) { |
robinmc | 1:046e66f1ca76 | 928 | g_Ticker_Menu_flag=0; |
robinmc | 1:046e66f1ca76 | 929 | FILE *Highscores = fopen("/sd/Highscores.txt", "w"); |
robinmc | 1:046e66f1ca76 | 930 | if (Highscores!=NULL) { |
robinmc | 1:046e66f1ca76 | 931 | green_led=0; |
robinmc | 1:046e66f1ca76 | 932 | fscanf(Highscores, "%d", &score); |
robinmc | 1:046e66f1ca76 | 933 | fclose(Highscores); |
robinmc | 1:046e66f1ca76 | 934 | lcd.printString("Highscore:",0,0); |
robinmc | 1:046e66f1ca76 | 935 | lcd.printString(buffer,10,3); |
robinmc | 1:046e66f1ca76 | 936 | } else if (Highscores!=NULL) { |
robinmc | 1:046e66f1ca76 | 937 | red_led=0; |
robinmc | 1:046e66f1ca76 | 938 | lcd.printString("Error reading",0,0); |
robinmc | 1:046e66f1ca76 | 939 | lcd.printString("file try",0,1); |
robinmc | 1:046e66f1ca76 | 940 | lcd.printString("re-inserting",0,2); |
robinmc | 1:046e66f1ca76 | 941 | lcd.printString("SD card",0,3); |
robinmc | 1:046e66f1ca76 | 942 | } |
robinmc | 1:046e66f1ca76 | 943 | } |
robinmc | 1:046e66f1ca76 | 944 | lcd.refresh(); |
robinmc | 1:046e66f1ca76 | 945 | sleep(); |
robinmc | 1:046e66f1ca76 | 946 | } |
robinmc | 0:28392431dbad | 947 | Credits: |
robinmc | 1:046e66f1ca76 | 948 | Minigame: |
robinmc | 0:28392431dbad | 949 | Continue: |
robinmc | 0:28392431dbad | 950 | wait(0.5); |
robinmc | 0:28392431dbad | 951 | while (1) { |
robinmc | 0:28392431dbad | 952 | if (g_Ticker_Game_flag) { |
robinmc | 0:28392431dbad | 953 | g_Ticker_Game_flag=0; |
robinmc | 0:28392431dbad | 954 | if (lives==0) { |
robinmc | 0:28392431dbad | 955 | goto GameOver; |
robinmc | 0:28392431dbad | 956 | } |
robinmc | 0:28392431dbad | 957 | if (swJoy==1) { |
robinmc | 0:28392431dbad | 958 | goto Pause; |
robinmc | 0:28392431dbad | 959 | } |
robinmc | 1:046e66f1ca76 | 960 | lcd.clear(); |
robinmc | 1:046e66f1ca76 | 961 | updateJoystick(); |
robinmc | 1:046e66f1ca76 | 962 | game(); |
robinmc | 1:046e66f1ca76 | 963 | |
robinmc | 0:28392431dbad | 964 | } |
robinmc | 0:28392431dbad | 965 | i++; |
robinmc | 0:28392431dbad | 966 | lcd.refresh(); |
robinmc | 0:28392431dbad | 967 | sleep(); |
robinmc | 0:28392431dbad | 968 | } |
robinmc | 0:28392431dbad | 969 | |
robinmc | 0:28392431dbad | 970 | Pause: |
robinmc | 1:046e66f1ca76 | 971 | int q; |
robinmc | 0:28392431dbad | 972 | while (1) { |
robinmc | 1:046e66f1ca76 | 973 | q++; |
robinmc | 1:046e66f1ca76 | 974 | lcd.printString("PAUSED",25,3); |
robinmc | 1:046e66f1ca76 | 975 | if (g_Ticker_Menu_flag) { |
robinmc | 1:046e66f1ca76 | 976 | g_Ticker_Menu_flag=0; |
robinmc | 1:046e66f1ca76 | 977 | if (swJoy&q>5) { |
robinmc | 1:046e66f1ca76 | 978 | q=0; |
robinmc | 1:046e66f1ca76 | 979 | lcd.setBrightness(brightness); |
robinmc | 1:046e66f1ca76 | 980 | led_bar(); |
robinmc | 1:046e66f1ca76 | 981 | goto Continue; |
robinmc | 1:046e66f1ca76 | 982 | } else if (q>=20) { |
robinmc | 1:046e66f1ca76 | 983 | lcd.setBrightness(0); |
robinmc | 1:046e66f1ca76 | 984 | led=0; |
robinmc | 1:046e66f1ca76 | 985 | } |
robinmc | 0:28392431dbad | 986 | } |
robinmc | 1:046e66f1ca76 | 987 | sleep(); |
robinmc | 0:28392431dbad | 988 | } |
robinmc | 0:28392431dbad | 989 | GameOver: |
robinmc | 1:046e66f1ca76 | 990 | char buffer[14]; |
robinmc | 1:046e66f1ca76 | 991 | int p = sprintf(buffer,"%d",score); |
robinmc | 1:046e66f1ca76 | 992 | FILE *Highscores = fopen("/sd/Highscores.txt", "w"); |
robinmc | 1:046e66f1ca76 | 993 | if (Highscores!=NULL) { |
robinmc | 1:046e66f1ca76 | 994 | fprintf(Highscores, "%d\n", highscore); |
robinmc | 1:046e66f1ca76 | 995 | fclose(Highscores); |
robinmc | 1:046e66f1ca76 | 996 | green_led=0; |
robinmc | 1:046e66f1ca76 | 997 | } else { |
robinmc | 1:046e66f1ca76 | 998 | red_led=0; |
robinmc | 1:046e66f1ca76 | 999 | } |
robinmc | 1:046e66f1ca76 | 1000 | led_bar(); |
robinmc | 1:046e66f1ca76 | 1001 | lcd.clear(); |
robinmc | 1:046e66f1ca76 | 1002 | for (int freeze=0; freeze<=30; freeze++) { |
robinmc | 1:046e66f1ca76 | 1003 | if (g_Ticker_Menu_flag) { |
robinmc | 1:046e66f1ca76 | 1004 | g_Ticker_Menu_flag=0; |
robinmc | 1:046e66f1ca76 | 1005 | lcd.clear(); |
robinmc | 1:046e66f1ca76 | 1006 | lcd.printString("GAME",25,1); |
robinmc | 1:046e66f1ca76 | 1007 | lcd.printString("OVER",25,2); |
robinmc | 1:046e66f1ca76 | 1008 | lcd.refresh(); |
robinmc | 1:046e66f1ca76 | 1009 | } |
robinmc | 1:046e66f1ca76 | 1010 | sleep(); |
robinmc | 1:046e66f1ca76 | 1011 | } |
robinmc | 1:046e66f1ca76 | 1012 | green_led=1; |
robinmc | 1:046e66f1ca76 | 1013 | red_led=1; |
robinmc | 0:28392431dbad | 1014 | lcd.printString("A Retry",40,4); |
robinmc | 0:28392431dbad | 1015 | lcd.printString("B Back to Menu",0,5); |
robinmc | 1:046e66f1ca76 | 1016 | lcd.refresh(); |
robinmc | 0:28392431dbad | 1017 | while (1) { |
robinmc | 1:046e66f1ca76 | 1018 | if (g_Ticker_Menu_flag) { |
robinmc | 1:046e66f1ca76 | 1019 | g_Ticker_Menu_flag=0; |
robinmc | 1:046e66f1ca76 | 1020 | if (b_A==1) { |
robinmc | 1:046e66f1ca76 | 1021 | initialize_values(); |
robinmc | 1:046e66f1ca76 | 1022 | goto Continue; |
robinmc | 1:046e66f1ca76 | 1023 | } else if (b_B==1) { |
robinmc | 1:046e66f1ca76 | 1024 | initialize_values(); |
robinmc | 1:046e66f1ca76 | 1025 | goto Menu; |
robinmc | 1:046e66f1ca76 | 1026 | } |
robinmc | 0:28392431dbad | 1027 | } |
robinmc | 1:046e66f1ca76 | 1028 | sleep(); |
robinmc | 0:28392431dbad | 1029 | } |
robinmc | 0:28392431dbad | 1030 | } |
robinmc | 0:28392431dbad | 1031 | |
robinmc | 0:28392431dbad | 1032 | |
robinmc | 0:28392431dbad | 1033 | // ----------------------------------------------------------------------------------------------------------------------------------------- |
robinmc | 0:28392431dbad | 1034 | |
robinmc | 1:046e66f1ca76 | 1035 | void game() |
robinmc | 1:046e66f1ca76 | 1036 | { |
robinmc | 1:046e66f1ca76 | 1037 | led_bar(); |
robinmc | 1:046e66f1ca76 | 1038 | print_score(); |
robinmc | 1:046e66f1ca76 | 1039 | generate_random_number(); |
robinmc | 1:046e66f1ca76 | 1040 | if (lose_lives_delay_flag==1) { |
robinmc | 1:046e66f1ca76 | 1041 | lives_delay_loop++; |
robinmc | 1:046e66f1ca76 | 1042 | if (lives_delay_loop>=10) { //means that the delay between one life beeing lost and another one beeing lost is at least 1s |
robinmc | 1:046e66f1ca76 | 1043 | lives_delay_loop=0; |
robinmc | 1:046e66f1ca76 | 1044 | lose_lives_delay_flag=0; |
robinmc | 1:046e66f1ca76 | 1045 | } |
robinmc | 1:046e66f1ca76 | 1046 | |
robinmc | 1:046e66f1ca76 | 1047 | } |
robinmc | 1:046e66f1ca76 | 1048 | if (ammo<=5) { |
robinmc | 1:046e66f1ca76 | 1049 | if (i%8>=4) { |
robinmc | 1:046e66f1ca76 | 1050 | print_ammo(); |
robinmc | 1:046e66f1ca76 | 1051 | } |
robinmc | 1:046e66f1ca76 | 1052 | } else { |
robinmc | 1:046e66f1ca76 | 1053 | print_ammo(); |
robinmc | 1:046e66f1ca76 | 1054 | } |
robinmc | 1:046e66f1ca76 | 1055 | if (b_B) { |
robinmc | 1:046e66f1ca76 | 1056 | jump_flag=1; |
robinmc | 1:046e66f1ca76 | 1057 | } |
robinmc | 1:046e66f1ca76 | 1058 | if (shoot_flag==0) { |
robinmc | 1:046e66f1ca76 | 1059 | bullet=9; |
robinmc | 1:046e66f1ca76 | 1060 | if (joystick.direction==DOWN) { |
robinmc | 1:046e66f1ca76 | 1061 | bullet_height=42; |
robinmc | 1:046e66f1ca76 | 1062 | } else { |
robinmc | 1:046e66f1ca76 | 1063 | bullet_height=g_jump+4; |
robinmc | 1:046e66f1ca76 | 1064 | } |
robinmc | 1:046e66f1ca76 | 1065 | } else if (shoot_flag==1&loop==0) { |
robinmc | 1:046e66f1ca76 | 1066 | loop++; |
robinmc | 1:046e66f1ca76 | 1067 | ammo--; |
robinmc | 1:046e66f1ca76 | 1068 | if (joystick.direction==DOWN&jump_flag!=1) { |
robinmc | 1:046e66f1ca76 | 1069 | bullet_height=42; |
robinmc | 1:046e66f1ca76 | 1070 | } else { |
robinmc | 1:046e66f1ca76 | 1071 | bullet_height=g_jump+4; |
robinmc | 1:046e66f1ca76 | 1072 | } |
robinmc | 1:046e66f1ca76 | 1073 | } |
robinmc | 1:046e66f1ca76 | 1074 | if (b_A) { |
robinmc | 1:046e66f1ca76 | 1075 | if (ammo<=0) { |
robinmc | 1:046e66f1ca76 | 1076 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 1077 | } else { |
robinmc | 1:046e66f1ca76 | 1078 | shoot_flag=1; |
robinmc | 1:046e66f1ca76 | 1079 | } |
robinmc | 1:046e66f1ca76 | 1080 | } |
robinmc | 1:046e66f1ca76 | 1081 | if (random_num<1000) { |
robinmc | 1:046e66f1ca76 | 1082 | print_bear_flag=1; |
robinmc | 1:046e66f1ca76 | 1083 | } else if (random_num>=1000&random_num<3000) { |
robinmc | 1:046e66f1ca76 | 1084 | print_bird_flag=1; |
robinmc | 1:046e66f1ca76 | 1085 | } else if (random_num>=3000&random_num<3010) { |
robinmc | 1:046e66f1ca76 | 1086 | print_heart_flag=1; |
robinmc | 1:046e66f1ca76 | 1087 | } else if (random_num>=3010&random_num<3050) { |
robinmc | 1:046e66f1ca76 | 1088 | print_ammo_flag=1; |
robinmc | 1:046e66f1ca76 | 1089 | } else if (random_num>=3050&random_num<6000) { |
robinmc | 1:046e66f1ca76 | 1090 | print_cactus_flag=1; |
robinmc | 1:046e66f1ca76 | 1091 | } else if (random_num>=6000&random_num<6100) { |
robinmc | 1:046e66f1ca76 | 1092 | print_ammo_flag=1; |
robinmc | 1:046e66f1ca76 | 1093 | print_t_rex_flag=1; |
robinmc | 1:046e66f1ca76 | 1094 | } else if (random_num>=6100&random_num<7000) { |
robinmc | 1:046e66f1ca76 | 1095 | print_rat_flag=1; |
robinmc | 1:046e66f1ca76 | 1096 | } else if (random_num>=7000&random_num<800) { |
robinmc | 1:046e66f1ca76 | 1097 | print_hound_flag=1; |
robinmc | 1:046e66f1ca76 | 1098 | } |
robinmc | 1:046e66f1ca76 | 1099 | |
robinmc | 1:046e66f1ca76 | 1100 | if (print_t_rex_flag==1&random_num%10==0&fire_on_screen==0) { |
robinmc | 1:046e66f1ca76 | 1101 | fire_on_screen=1; |
robinmc | 1:046e66f1ca76 | 1102 | print_fire_ball_flag=1; |
robinmc | 1:046e66f1ca76 | 1103 | fire_ball_hMovement=t_rex_movement-6; |
robinmc | 1:046e66f1ca76 | 1104 | fire_ball_vMovement=25; |
robinmc | 1:046e66f1ca76 | 1105 | } |
robinmc | 1:046e66f1ca76 | 1106 | if (joystick.direction==CENTRE&jump_flag!=1) { |
robinmc | 1:046e66f1ca76 | 1107 | lcd.setPixel(bullet,bullet_height); |
robinmc | 1:046e66f1ca76 | 1108 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 1:046e66f1ca76 | 1109 | print_recks_still_gun(); |
robinmc | 1:046e66f1ca76 | 1110 | if (shoot_flag==1) { |
robinmc | 1:046e66f1ca76 | 1111 | bullet+=20; |
robinmc | 1:046e66f1ca76 | 1112 | if (bullet>=84) { |
robinmc | 1:046e66f1ca76 | 1113 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 1114 | loop=0; |
robinmc | 1:046e66f1ca76 | 1115 | } |
robinmc | 1:046e66f1ca76 | 1116 | } |
robinmc | 1:046e66f1ca76 | 1117 | } else if (joystick.direction==LEFT&jump_flag!=1) { |
robinmc | 1:046e66f1ca76 | 1118 | if (run%2==0) { |
robinmc | 1:046e66f1ca76 | 1119 | print_recks_still_gun(); |
robinmc | 1:046e66f1ca76 | 1120 | } else if (run%2==1) { |
robinmc | 1:046e66f1ca76 | 1121 | print_recks_moving_gun(); |
robinmc | 1:046e66f1ca76 | 1122 | } |
robinmc | 1:046e66f1ca76 | 1123 | lcd.setPixel(bullet,bullet_height); |
robinmc | 1:046e66f1ca76 | 1124 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 1:046e66f1ca76 | 1125 | if (shoot_flag==1) { |
robinmc | 1:046e66f1ca76 | 1126 | bullet+=21; |
robinmc | 1:046e66f1ca76 | 1127 | if (bullet>=84) { |
robinmc | 1:046e66f1ca76 | 1128 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 1129 | loop=0; |
robinmc | 1:046e66f1ca76 | 1130 | } |
robinmc | 1:046e66f1ca76 | 1131 | } |
robinmc | 1:046e66f1ca76 | 1132 | h_movement--; |
robinmc | 1:046e66f1ca76 | 1133 | run++; |
robinmc | 1:046e66f1ca76 | 1134 | } else if (joystick.direction==RIGHT&jump_flag!=1) { |
robinmc | 1:046e66f1ca76 | 1135 | if (run%2==0) { |
robinmc | 1:046e66f1ca76 | 1136 | print_recks_still_gun(); |
robinmc | 1:046e66f1ca76 | 1137 | } else if (run%2==1) { |
robinmc | 1:046e66f1ca76 | 1138 | print_recks_moving_gun(); |
robinmc | 1:046e66f1ca76 | 1139 | } |
robinmc | 1:046e66f1ca76 | 1140 | lcd.setPixel(bullet,bullet_height); |
robinmc | 1:046e66f1ca76 | 1141 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 1:046e66f1ca76 | 1142 | if (shoot_flag==1) { |
robinmc | 1:046e66f1ca76 | 1143 | bullet+=19; |
robinmc | 1:046e66f1ca76 | 1144 | if (bullet>=84) { |
robinmc | 1:046e66f1ca76 | 1145 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 1146 | loop=0; |
robinmc | 1:046e66f1ca76 | 1147 | } |
robinmc | 1:046e66f1ca76 | 1148 | } |
robinmc | 1:046e66f1ca76 | 1149 | h_movement++; |
robinmc | 1:046e66f1ca76 | 1150 | run++; |
robinmc | 1:046e66f1ca76 | 1151 | } else if (joystick.direction==DOWN&jump_flag!=1) { |
robinmc | 1:046e66f1ca76 | 1152 | lcd.setPixel(bullet,bullet_height); |
robinmc | 1:046e66f1ca76 | 1153 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 1:046e66f1ca76 | 1154 | print_recks_crouch_gun(); |
robinmc | 1:046e66f1ca76 | 1155 | bullet_height=42; |
robinmc | 1:046e66f1ca76 | 1156 | if (shoot_flag==1) { |
robinmc | 1:046e66f1ca76 | 1157 | bullet+=20; |
robinmc | 1:046e66f1ca76 | 1158 | if (bullet>=84) { |
robinmc | 1:046e66f1ca76 | 1159 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 1160 | loop=0; |
robinmc | 1:046e66f1ca76 | 1161 | } |
robinmc | 1:046e66f1ca76 | 1162 | } |
robinmc | 1:046e66f1ca76 | 1163 | } else if (jump_flag==1) { |
robinmc | 1:046e66f1ca76 | 1164 | if (joystick.direction==LEFT) { |
robinmc | 1:046e66f1ca76 | 1165 | if (shoot_flag==1) { |
robinmc | 1:046e66f1ca76 | 1166 | bullet+=21; |
robinmc | 1:046e66f1ca76 | 1167 | if (bullet>=84) { |
robinmc | 1:046e66f1ca76 | 1168 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 1169 | loop=0; |
robinmc | 1:046e66f1ca76 | 1170 | } |
robinmc | 1:046e66f1ca76 | 1171 | } |
robinmc | 1:046e66f1ca76 | 1172 | h_movement--; |
robinmc | 1:046e66f1ca76 | 1173 | } else if (joystick.direction==RIGHT) { |
robinmc | 1:046e66f1ca76 | 1174 | if (shoot_flag==1) { |
robinmc | 1:046e66f1ca76 | 1175 | bullet+=19; |
robinmc | 1:046e66f1ca76 | 1176 | if (bullet>=84) { |
robinmc | 1:046e66f1ca76 | 1177 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 1178 | loop=0; |
robinmc | 1:046e66f1ca76 | 1179 | } |
robinmc | 1:046e66f1ca76 | 1180 | } |
robinmc | 1:046e66f1ca76 | 1181 | h_movement++; |
robinmc | 1:046e66f1ca76 | 1182 | } else if (joystick.direction==CENTRE) { |
robinmc | 1:046e66f1ca76 | 1183 | if (shoot_flag==1) { |
robinmc | 1:046e66f1ca76 | 1184 | bullet+=20; |
robinmc | 1:046e66f1ca76 | 1185 | if (bullet>=84) { |
robinmc | 1:046e66f1ca76 | 1186 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 1187 | loop=0; |
robinmc | 1:046e66f1ca76 | 1188 | } |
robinmc | 1:046e66f1ca76 | 1189 | } |
robinmc | 1:046e66f1ca76 | 1190 | } |
robinmc | 1:046e66f1ca76 | 1191 | if (g_jump<=36&jumpUp==0&g_jump!=15) { |
robinmc | 1:046e66f1ca76 | 1192 | lcd.setPixel(bullet,bullet_height); |
robinmc | 1:046e66f1ca76 | 1193 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 1:046e66f1ca76 | 1194 | if (bullet>=84) { |
robinmc | 1:046e66f1ca76 | 1195 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 1196 | loop=0; |
robinmc | 1:046e66f1ca76 | 1197 | } |
robinmc | 1:046e66f1ca76 | 1198 | print_recks_jump_gun(); |
robinmc | 1:046e66f1ca76 | 1199 | g_jump-=6-accel; |
robinmc | 1:046e66f1ca76 | 1200 | accel++; |
robinmc | 1:046e66f1ca76 | 1201 | } else if (g_jump>=15&g_jump!=36) { |
robinmc | 1:046e66f1ca76 | 1202 | lcd.setPixel(bullet,bullet_height); |
robinmc | 1:046e66f1ca76 | 1203 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 1:046e66f1ca76 | 1204 | if (bullet>=84) { |
robinmc | 1:046e66f1ca76 | 1205 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 1206 | loop=0; |
robinmc | 1:046e66f1ca76 | 1207 | } |
robinmc | 1:046e66f1ca76 | 1208 | print_recks_jump_gun(); |
robinmc | 1:046e66f1ca76 | 1209 | g_jump+=6-accel; |
robinmc | 1:046e66f1ca76 | 1210 | accel--; |
robinmc | 1:046e66f1ca76 | 1211 | jumpUp=1; |
robinmc | 1:046e66f1ca76 | 1212 | } else if (g_jump==36&jumpUp==1) { |
robinmc | 1:046e66f1ca76 | 1213 | lcd.setPixel(bullet,bullet_height); |
robinmc | 1:046e66f1ca76 | 1214 | lcd.setPixel(bullet+1,bullet_height); |
robinmc | 1:046e66f1ca76 | 1215 | if (bullet>=84) { |
robinmc | 1:046e66f1ca76 | 1216 | shoot_flag=0; |
robinmc | 1:046e66f1ca76 | 1217 | loop=0; |
robinmc | 1:046e66f1ca76 | 1218 | } |
robinmc | 1:046e66f1ca76 | 1219 | print_recks_still_gun(); |
robinmc | 1:046e66f1ca76 | 1220 | jump_flag=0; |
robinmc | 1:046e66f1ca76 | 1221 | jumpUp=0; |
robinmc | 1:046e66f1ca76 | 1222 | g_jump=36; |
robinmc | 1:046e66f1ca76 | 1223 | accel=0; |
robinmc | 1:046e66f1ca76 | 1224 | } |
robinmc | 1:046e66f1ca76 | 1225 | } |
robinmc | 1:046e66f1ca76 | 1226 | if (print_rat_flag==1) { |
robinmc | 1:046e66f1ca76 | 1227 | if (i%4>=2) { |
robinmc | 1:046e66f1ca76 | 1228 | print_mob_rat_p1(); |
robinmc | 1:046e66f1ca76 | 1229 | } else if (i%4<2) { |
robinmc | 1:046e66f1ca76 | 1230 | print_mob_rat_p2(); |
robinmc | 1:046e66f1ca76 | 1231 | } |
robinmc | 1:046e66f1ca76 | 1232 | if (joystick.direction==LEFT) { |
robinmc | 1:046e66f1ca76 | 1233 | rat_movement++; |
robinmc | 1:046e66f1ca76 | 1234 | } else if (joystick.direction==RIGHT) { |
robinmc | 1:046e66f1ca76 | 1235 | rat_movement--; |
robinmc | 1:046e66f1ca76 | 1236 | } |
robinmc | 1:046e66f1ca76 | 1237 | rat_movement-=3; |
robinmc | 1:046e66f1ca76 | 1238 | if (rat_movement<=-15) { |
robinmc | 1:046e66f1ca76 | 1239 | rat_movement=100; |
robinmc | 1:046e66f1ca76 | 1240 | print_rat_flag=0; |
robinmc | 1:046e66f1ca76 | 1241 | } |
robinmc | 1:046e66f1ca76 | 1242 | if (rat_movement<=5&rat_movement>=-3&g_jump>32&lose_lives_delay_flag==0) { //a life is lost if recks has an vertical and horizontal position equal to one of the pixels corresponding to the bears position |
robinmc | 1:046e66f1ca76 | 1243 | lives--; |
robinmc | 1:046e66f1ca76 | 1244 | lose_lives_delay_flag=1; |
robinmc | 1:046e66f1ca76 | 1245 | } |
robinmc | 1:046e66f1ca76 | 1246 | } |
robinmc | 1:046e66f1ca76 | 1247 | if (print_hound_flag==1) { |
robinmc | 1:046e66f1ca76 | 1248 | if (i%4>=2&hound_jump_flag!=1) { |
robinmc | 1:046e66f1ca76 | 1249 | print_mob_hound_p1(); |
robinmc | 1:046e66f1ca76 | 1250 | } else if (i%4<2&hound_jump_flag!=1) { |
robinmc | 1:046e66f1ca76 | 1251 | print_mob_hound_p2(); |
robinmc | 1:046e66f1ca76 | 1252 | } |
robinmc | 1:046e66f1ca76 | 1253 | if (joystick.direction==LEFT) { |
robinmc | 1:046e66f1ca76 | 1254 | hound_hMovement++; |
robinmc | 1:046e66f1ca76 | 1255 | } else if (joystick.direction==RIGHT) { |
robinmc | 1:046e66f1ca76 | 1256 | hound_hMovement--; |
robinmc | 1:046e66f1ca76 | 1257 | } |
robinmc | 1:046e66f1ca76 | 1258 | hound_hMovement-=2; |
robinmc | 1:046e66f1ca76 | 1259 | if (hound_hMovement<=-15) { |
robinmc | 1:046e66f1ca76 | 1260 | hound_hMovement=100; |
robinmc | 1:046e66f1ca76 | 1261 | print_hound_flag=0; |
robinmc | 1:046e66f1ca76 | 1262 | } |
robinmc | 1:046e66f1ca76 | 1263 | if (random_num%10==0) { |
robinmc | 1:046e66f1ca76 | 1264 | hound_jump_flag=1; |
robinmc | 1:046e66f1ca76 | 1265 | } |
robinmc | 1:046e66f1ca76 | 1266 | if (hound_jump_flag==1) { |
robinmc | 1:046e66f1ca76 | 1267 | hound_jump++; |
robinmc | 1:046e66f1ca76 | 1268 | hound_hMovement--; |
robinmc | 1:046e66f1ca76 | 1269 | if (hound_jump==1) { |
robinmc | 1:046e66f1ca76 | 1270 | hound_vMovement-=3; |
robinmc | 1:046e66f1ca76 | 1271 | } else if (hound_jump==2) { |
robinmc | 1:046e66f1ca76 | 1272 | hound_vMovement-=2; |
robinmc | 1:046e66f1ca76 | 1273 | } else if (hound_jump==3) { |
robinmc | 1:046e66f1ca76 | 1274 | hound_vMovement-=1; |
robinmc | 1:046e66f1ca76 | 1275 | } else if (hound_jump==4) { |
robinmc | 1:046e66f1ca76 | 1276 | hound_vMovement+=1; |
robinmc | 1:046e66f1ca76 | 1277 | } else if (hound_jump==5) { |
robinmc | 1:046e66f1ca76 | 1278 | hound_vMovement+=2; |
robinmc | 1:046e66f1ca76 | 1279 | } else if (hound_jump==6) { |
robinmc | 1:046e66f1ca76 | 1280 | hound_vMovement+=3; |
robinmc | 1:046e66f1ca76 | 1281 | } else if (hound_jump==7) { |
robinmc | 1:046e66f1ca76 | 1282 | hound_jump_flag=0; |
robinmc | 1:046e66f1ca76 | 1283 | hound_jump=0; |
robinmc | 1:046e66f1ca76 | 1284 | } |
robinmc | 1:046e66f1ca76 | 1285 | print_mob_hound_p2(); |
robinmc | 1:046e66f1ca76 | 1286 | |
robinmc | 1:046e66f1ca76 | 1287 | } |
robinmc | 1:046e66f1ca76 | 1288 | if ((hound_hMovement<=8&hound_hMovement>=-5&g_jump>28&lose_lives_delay_flag==0&hound_jump_flag!=1)|(hound_hMovement<=8&hound_hMovement>=-5&g_jump>22&lose_lives_delay_flag==0&hound_jump_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 | 1:046e66f1ca76 | 1289 | lives--; |
robinmc | 1:046e66f1ca76 | 1290 | lose_lives_delay_flag=1; |
robinmc | 1:046e66f1ca76 | 1291 | } |
robinmc | 1:046e66f1ca76 | 1292 | if (shoot_flag==1&bullet_height>hound_vMovement&bullet_height<hound_vMovement+8) { |
robinmc | 1:046e66f1ca76 | 1293 | print_mob_hound_dead(); |
robinmc | 1:046e66f1ca76 | 1294 | print_hound_flag=0; |
robinmc | 1:046e66f1ca76 | 1295 | hound_hMovement=90; |
robinmc | 1:046e66f1ca76 | 1296 | kill_score+=5; |
robinmc | 1:046e66f1ca76 | 1297 | } |
robinmc | 1:046e66f1ca76 | 1298 | } |
robinmc | 1:046e66f1ca76 | 1299 | if (print_bear_flag==1) { |
robinmc | 1:046e66f1ca76 | 1300 | if (i%4>=2) { |
robinmc | 1:046e66f1ca76 | 1301 | print_mob_bear_p1(); |
robinmc | 1:046e66f1ca76 | 1302 | } else if (i%4<2) { |
robinmc | 1:046e66f1ca76 | 1303 | print_mob_bear_p2(); |
robinmc | 1:046e66f1ca76 | 1304 | } |
robinmc | 1:046e66f1ca76 | 1305 | if (joystick.direction==LEFT) { |
robinmc | 1:046e66f1ca76 | 1306 | bear_movement++; |
robinmc | 1:046e66f1ca76 | 1307 | } else if (joystick.direction==RIGHT) { |
robinmc | 1:046e66f1ca76 | 1308 | bear_movement--; |
robinmc | 1:046e66f1ca76 | 1309 | } |
robinmc | 1:046e66f1ca76 | 1310 | bear_movement-=2; |
robinmc | 1:046e66f1ca76 | 1311 | if (bear_movement<=-15) { |
robinmc | 1:046e66f1ca76 | 1312 | bear_movement=100; |
robinmc | 1:046e66f1ca76 | 1313 | print_bear_flag=0; |
robinmc | 1:046e66f1ca76 | 1314 | } |
robinmc | 1:046e66f1ca76 | 1315 | if (bear_movement<=8&bear_movement>=-5&g_jump>26&lose_lives_delay_flag==0) { //a life is lost if recks has an vertical and horizontal position equal to one of the pixels corresponding to the bears position |
robinmc | 1:046e66f1ca76 | 1316 | lives--; |
robinmc | 1:046e66f1ca76 | 1317 | lose_lives_delay_flag=1; |
robinmc | 1:046e66f1ca76 | 1318 | } |
robinmc | 1:046e66f1ca76 | 1319 | if (shoot_flag==1&bullet_height>8) { |
robinmc | 1:046e66f1ca76 | 1320 | bear_lives++; |
robinmc | 1:046e66f1ca76 | 1321 | if (bear_lives==12-3*g_g1-3*g_g2) { |
robinmc | 1:046e66f1ca76 | 1322 | print_mob_bear_dead(); |
robinmc | 1:046e66f1ca76 | 1323 | print_bear_flag=0; |
robinmc | 1:046e66f1ca76 | 1324 | bear_movement=100; |
robinmc | 1:046e66f1ca76 | 1325 | kill_score+=7; |
robinmc | 1:046e66f1ca76 | 1326 | bear_lives=0; |
robinmc | 1:046e66f1ca76 | 1327 | } |
robinmc | 1:046e66f1ca76 | 1328 | } |
robinmc | 1:046e66f1ca76 | 1329 | } |
robinmc | 1:046e66f1ca76 | 1330 | if (print_bird_flag==1) { |
robinmc | 1:046e66f1ca76 | 1331 | if (i%8>=4) { |
robinmc | 1:046e66f1ca76 | 1332 | print_mob_bird_p1(); |
robinmc | 1:046e66f1ca76 | 1333 | } else if (i%8<4) { |
robinmc | 1:046e66f1ca76 | 1334 | print_mob_bird_p2(); |
robinmc | 1:046e66f1ca76 | 1335 | } |
robinmc | 1:046e66f1ca76 | 1336 | bird_hMovement-=2; |
robinmc | 1:046e66f1ca76 | 1337 | if (joystick.direction==LEFT) { |
robinmc | 1:046e66f1ca76 | 1338 | bird_hMovement++; |
robinmc | 1:046e66f1ca76 | 1339 | } else if (joystick.direction==RIGHT) { |
robinmc | 1:046e66f1ca76 | 1340 | bird_hMovement--; |
robinmc | 1:046e66f1ca76 | 1341 | } |
robinmc | 1:046e66f1ca76 | 1342 | if (random_num%6==0) { |
robinmc | 1:046e66f1ca76 | 1343 | bird_vMovement--; |
robinmc | 1:046e66f1ca76 | 1344 | } else if (random_num%6>=4) { |
robinmc | 1:046e66f1ca76 | 1345 | bird_vMovement++; |
robinmc | 1:046e66f1ca76 | 1346 | } |
robinmc | 1:046e66f1ca76 | 1347 | if (bird_vMovement>=37) { |
robinmc | 1:046e66f1ca76 | 1348 | bird_vMovement=37; |
robinmc | 1:046e66f1ca76 | 1349 | } else if (bird_vMovement<=10) { |
robinmc | 1:046e66f1ca76 | 1350 | bird_vMovement=10; |
robinmc | 1:046e66f1ca76 | 1351 | } |
robinmc | 1:046e66f1ca76 | 1352 | if (bird_hMovement<=-10) { |
robinmc | 1:046e66f1ca76 | 1353 | print_bird_flag=0; |
robinmc | 1:046e66f1ca76 | 1354 | bird_hMovement=100; |
robinmc | 1:046e66f1ca76 | 1355 | bird_vMovement=20; |
robinmc | 1:046e66f1ca76 | 1356 | bear_lives=0; |
robinmc | 1:046e66f1ca76 | 1357 | } |
robinmc | 1:046e66f1ca76 | 1358 | if ((bird_hMovement>=0&bird_hMovement<=10)&(bird_vMovement+5>=g_jump&bird_vMovement+5<=g_jump+10&lose_lives_delay_flag==0)) { |
robinmc | 1:046e66f1ca76 | 1359 | lives--; |
robinmc | 1:046e66f1ca76 | 1360 | lose_lives_delay_flag=1; |
robinmc | 1:046e66f1ca76 | 1361 | } |
robinmc | 1:046e66f1ca76 | 1362 | if (shoot_flag==1&(bullet_height==bird_vMovement+5|bullet_height==bird_vMovement+4)) { |
robinmc | 1:046e66f1ca76 | 1363 | print_mob_bird_dead(); |
robinmc | 1:046e66f1ca76 | 1364 | print_bird_flag=0; |
robinmc | 1:046e66f1ca76 | 1365 | bird_hMovement=100; |
robinmc | 1:046e66f1ca76 | 1366 | bird_vMovement=20; |
robinmc | 1:046e66f1ca76 | 1367 | kill_score+=5; |
robinmc | 1:046e66f1ca76 | 1368 | } |
robinmc | 1:046e66f1ca76 | 1369 | } |
robinmc | 1:046e66f1ca76 | 1370 | if (print_cactus_flag==1) { |
robinmc | 1:046e66f1ca76 | 1371 | print_cactus(); |
robinmc | 1:046e66f1ca76 | 1372 | if (joystick.direction==LEFT) { |
robinmc | 1:046e66f1ca76 | 1373 | cactus_movement++; |
robinmc | 1:046e66f1ca76 | 1374 | } else if (joystick.direction==RIGHT) { |
robinmc | 1:046e66f1ca76 | 1375 | cactus_movement--; |
robinmc | 1:046e66f1ca76 | 1376 | } |
robinmc | 1:046e66f1ca76 | 1377 | if (cactus_movement<=-10) { |
robinmc | 1:046e66f1ca76 | 1378 | cactus_movement=110; |
robinmc | 1:046e66f1ca76 | 1379 | print_cactus_flag=0; |
robinmc | 1:046e66f1ca76 | 1380 | } |
robinmc | 1:046e66f1ca76 | 1381 | if (cactus_movement<=10&cactus_movement>=2&g_jump>32&lose_lives_delay_flag==0) { |
robinmc | 1:046e66f1ca76 | 1382 | lives--; |
robinmc | 1:046e66f1ca76 | 1383 | lose_lives_delay_flag=1; |
robinmc | 1:046e66f1ca76 | 1384 | } |
robinmc | 1:046e66f1ca76 | 1385 | } |
robinmc | 1:046e66f1ca76 | 1386 | |
robinmc | 1:046e66f1ca76 | 1387 | if (print_t_rex_flag==1) { |
robinmc | 1:046e66f1ca76 | 1388 | if (joystick.direction==LEFT) { |
robinmc | 1:046e66f1ca76 | 1389 | t_rex_movement++; |
robinmc | 1:046e66f1ca76 | 1390 | } else if (joystick.direction==RIGHT) { |
robinmc | 1:046e66f1ca76 | 1391 | t_rex_movement--; |
robinmc | 1:046e66f1ca76 | 1392 | } |
robinmc | 1:046e66f1ca76 | 1393 | if (random_num%4==0&print_fire_ball_flag!=1) { |
robinmc | 1:046e66f1ca76 | 1394 | t_rex_movement+=2; |
robinmc | 1:046e66f1ca76 | 1395 | print_t_rex_moving(); |
robinmc | 1:046e66f1ca76 | 1396 | } else if (random_num%4==1&print_fire_ball_flag!=1) { |
robinmc | 1:046e66f1ca76 | 1397 | t_rex_movement-=2; |
robinmc | 1:046e66f1ca76 | 1398 | print_t_rex_moving(); |
robinmc | 1:046e66f1ca76 | 1399 | } else if (random_num%4>1&print_fire_ball_flag!=1) { |
robinmc | 1:046e66f1ca76 | 1400 | print_t_rex(); |
robinmc | 1:046e66f1ca76 | 1401 | } |
robinmc | 1:046e66f1ca76 | 1402 | if (t_rex_movement<=-100) { |
robinmc | 1:046e66f1ca76 | 1403 | t_rex_movement=120; |
robinmc | 1:046e66f1ca76 | 1404 | print_t_rex_flag=0; |
robinmc | 1:046e66f1ca76 | 1405 | } |
robinmc | 1:046e66f1ca76 | 1406 | if (t_rex_movement<=6&t_rex_movement>=2&lose_lives_delay_flag==0) { |
robinmc | 1:046e66f1ca76 | 1407 | lives--; |
robinmc | 1:046e66f1ca76 | 1408 | lose_lives_delay_flag=1; |
robinmc | 1:046e66f1ca76 | 1409 | } |
robinmc | 1:046e66f1ca76 | 1410 | } |
robinmc | 1:046e66f1ca76 | 1411 | if (print_fire_ball_flag==1) { |
robinmc | 1:046e66f1ca76 | 1412 | print_t_rex_attack(); |
robinmc | 1:046e66f1ca76 | 1413 | fire_ball_hMovement-=2; |
robinmc | 1:046e66f1ca76 | 1414 | if (joystick.direction==LEFT) { |
robinmc | 1:046e66f1ca76 | 1415 | fire_ball_hMovement++; |
robinmc | 1:046e66f1ca76 | 1416 | } else if (joystick.direction==RIGHT) { |
robinmc | 1:046e66f1ca76 | 1417 | fire_ball_hMovement--; |
robinmc | 1:046e66f1ca76 | 1418 | } |
robinmc | 1:046e66f1ca76 | 1419 | if (i%4>=2) { |
robinmc | 1:046e66f1ca76 | 1420 | print_fire_ball_p1(); |
robinmc | 1:046e66f1ca76 | 1421 | } else { |
robinmc | 1:046e66f1ca76 | 1422 | print_fire_ball_p2(); |
robinmc | 1:046e66f1ca76 | 1423 | } |
robinmc | 1:046e66f1ca76 | 1424 | if (fire_ball_vMovement>=37) { |
robinmc | 1:046e66f1ca76 | 1425 | fire_ball_vMovement=37; |
robinmc | 1:046e66f1ca76 | 1426 | } |
robinmc | 1:046e66f1ca76 | 1427 | if (random_num%3==0) { |
robinmc | 1:046e66f1ca76 | 1428 | fire_ball_vMovement++; |
robinmc | 1:046e66f1ca76 | 1429 | } else if (random_num%3==1) { |
robinmc | 1:046e66f1ca76 | 1430 | fire_ball_vMovement+=2; |
robinmc | 1:046e66f1ca76 | 1431 | } |
robinmc | 1:046e66f1ca76 | 1432 | if (fire_ball_hMovement<=-10) { |
robinmc | 1:046e66f1ca76 | 1433 | fire_ball_vMovement=27; |
robinmc | 1:046e66f1ca76 | 1434 | fire_ball_hMovement=t_rex_movement-6; |
robinmc | 1:046e66f1ca76 | 1435 | print_fire_ball_flag=0; |
robinmc | 1:046e66f1ca76 | 1436 | fire_on_screen=0; |
robinmc | 1:046e66f1ca76 | 1437 | } |
robinmc | 1:046e66f1ca76 | 1438 | 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) { |
robinmc | 1:046e66f1ca76 | 1439 | lives--; |
robinmc | 1:046e66f1ca76 | 1440 | lose_lives_delay_flag=1; |
robinmc | 1:046e66f1ca76 | 1441 | } |
robinmc | 1:046e66f1ca76 | 1442 | if (shoot_flag==1) { |
robinmc | 1:046e66f1ca76 | 1443 | t_rex_lives++; |
robinmc | 1:046e66f1ca76 | 1444 | if (t_rex_lives>=24-3*g_g1-3*g_g2) { |
robinmc | 1:046e66f1ca76 | 1445 | print_t_rex_flag=0; |
robinmc | 1:046e66f1ca76 | 1446 | t_rex_movement=120; |
robinmc | 1:046e66f1ca76 | 1447 | kill_score+=20; |
robinmc | 1:046e66f1ca76 | 1448 | t_rex_lives=0; |
robinmc | 1:046e66f1ca76 | 1449 | } |
robinmc | 1:046e66f1ca76 | 1450 | } |
robinmc | 1:046e66f1ca76 | 1451 | } |
robinmc | 1:046e66f1ca76 | 1452 | if (print_heart_flag==1) { |
robinmc | 1:046e66f1ca76 | 1453 | print_heart(); |
robinmc | 1:046e66f1ca76 | 1454 | if (joystick.direction==LEFT) { |
robinmc | 1:046e66f1ca76 | 1455 | heart_movement++; |
robinmc | 1:046e66f1ca76 | 1456 | } else if (joystick.direction==RIGHT) { |
robinmc | 1:046e66f1ca76 | 1457 | heart_movement--; |
robinmc | 1:046e66f1ca76 | 1458 | } |
robinmc | 1:046e66f1ca76 | 1459 | if (heart_movement<=7&g_jump>26) { |
robinmc | 1:046e66f1ca76 | 1460 | heart_movement=90; |
robinmc | 1:046e66f1ca76 | 1461 | print_heart_flag=0; |
robinmc | 1:046e66f1ca76 | 1462 | lives++; |
robinmc | 1:046e66f1ca76 | 1463 | } |
robinmc | 1:046e66f1ca76 | 1464 | } |
robinmc | 1:046e66f1ca76 | 1465 | if (print_ammo_flag==1) { |
robinmc | 1:046e66f1ca76 | 1466 | print_ammo_pickUp(); |
robinmc | 1:046e66f1ca76 | 1467 | if (joystick.direction==LEFT) { |
robinmc | 1:046e66f1ca76 | 1468 | ammo_movement++; |
robinmc | 1:046e66f1ca76 | 1469 | } else if (joystick.direction==RIGHT) { |
robinmc | 1:046e66f1ca76 | 1470 | ammo_movement--; |
robinmc | 1:046e66f1ca76 | 1471 | } |
robinmc | 1:046e66f1ca76 | 1472 | if (ammo_movement<=7&g_jump>26) { |
robinmc | 1:046e66f1ca76 | 1473 | ammo_movement=90; |
robinmc | 1:046e66f1ca76 | 1474 | print_ammo_flag=0; |
robinmc | 1:046e66f1ca76 | 1475 | ammo+=5; |
robinmc | 1:046e66f1ca76 | 1476 | ammo+=rand()%7; |
robinmc | 1:046e66f1ca76 | 1477 | } |
robinmc | 1:046e66f1ca76 | 1478 | } |
robinmc | 1:046e66f1ca76 | 1479 | print_clouds(); |
robinmc | 1:046e66f1ca76 | 1480 | ground(); |
robinmc | 1:046e66f1ca76 | 1481 | } |
robinmc | 0:28392431dbad | 1482 | |
robinmc | 0:28392431dbad | 1483 | void print_ammo() |
robinmc | 0:28392431dbad | 1484 | { |
robinmc | 0:28392431dbad | 1485 | for(int c=0; c<=2; c++) { // 2 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 1486 | for(int r=0; r<=4; r++) { |
robinmc | 0:28392431dbad | 1487 | for (int n=70; n<=74; n+=4) { |
robinmc | 0:28392431dbad | 1488 | if (n==74&ammo%10==0) { |
robinmc | 0:28392431dbad | 1489 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 1490 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1491 | } else { |
robinmc | 0:28392431dbad | 1492 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1493 | } |
robinmc | 0:28392431dbad | 1494 | } else if (n==74&ammo%10==1) { |
robinmc | 0:28392431dbad | 1495 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 1496 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1497 | } else { |
robinmc | 0:28392431dbad | 1498 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1499 | } |
robinmc | 0:28392431dbad | 1500 | } else if (n==74&ammo%10==2) { |
robinmc | 0:28392431dbad | 1501 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 1502 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1503 | } else { |
robinmc | 0:28392431dbad | 1504 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1505 | } |
robinmc | 0:28392431dbad | 1506 | } else if (n==74&ammo%10==3) { |
robinmc | 0:28392431dbad | 1507 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 1508 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1509 | } else { |
robinmc | 0:28392431dbad | 1510 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1511 | } |
robinmc | 0:28392431dbad | 1512 | } else if (n==74&ammo%10==4) { |
robinmc | 0:28392431dbad | 1513 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 1514 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1515 | } else { |
robinmc | 0:28392431dbad | 1516 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1517 | } |
robinmc | 0:28392431dbad | 1518 | } else if (n==74&ammo%10==5) { |
robinmc | 0:28392431dbad | 1519 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 1520 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1521 | } else { |
robinmc | 0:28392431dbad | 1522 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1523 | } |
robinmc | 0:28392431dbad | 1524 | } else if (n==74&ammo%10==6) { |
robinmc | 0:28392431dbad | 1525 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 1526 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1527 | } else { |
robinmc | 0:28392431dbad | 1528 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1529 | } |
robinmc | 0:28392431dbad | 1530 | } else if (n==74&ammo%10==7) { |
robinmc | 0:28392431dbad | 1531 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 1532 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1533 | } else { |
robinmc | 0:28392431dbad | 1534 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1535 | } |
robinmc | 0:28392431dbad | 1536 | } else if (n==74&ammo%10==8) { |
robinmc | 0:28392431dbad | 1537 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 1538 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1539 | } else { |
robinmc | 0:28392431dbad | 1540 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1541 | } |
robinmc | 0:28392431dbad | 1542 | } else if (n==74&ammo%10==9) { |
robinmc | 0:28392431dbad | 1543 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 1544 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1545 | } else { |
robinmc | 0:28392431dbad | 1546 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1547 | } |
robinmc | 0:28392431dbad | 1548 | } |
robinmc | 0:28392431dbad | 1549 | |
robinmc | 0:28392431dbad | 1550 | if (n==70&(ammo%100>=0&ammo%100<10)) { |
robinmc | 0:28392431dbad | 1551 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 1552 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1553 | } else { |
robinmc | 0:28392431dbad | 1554 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1555 | } |
robinmc | 0:28392431dbad | 1556 | } else if (n==70&(ammo%100>=10&ammo%100<20)) { |
robinmc | 0:28392431dbad | 1557 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 1558 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1559 | } else { |
robinmc | 0:28392431dbad | 1560 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1561 | } |
robinmc | 0:28392431dbad | 1562 | } else if (n==70&(ammo%100>=20&ammo%100<30)) { |
robinmc | 0:28392431dbad | 1563 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 1564 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1565 | } else { |
robinmc | 0:28392431dbad | 1566 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1567 | } |
robinmc | 0:28392431dbad | 1568 | } else if (n==70&(ammo%100>=30&ammo%100<40)) { |
robinmc | 0:28392431dbad | 1569 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 1570 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1571 | } else { |
robinmc | 0:28392431dbad | 1572 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1573 | } |
robinmc | 0:28392431dbad | 1574 | } else if (n==70&(ammo%100>=40&ammo%100<50)) { |
robinmc | 0:28392431dbad | 1575 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 1576 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1577 | } else { |
robinmc | 0:28392431dbad | 1578 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1579 | } |
robinmc | 0:28392431dbad | 1580 | } else if (n==70&(ammo%100>=50&ammo%100<60)) { |
robinmc | 0:28392431dbad | 1581 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 1582 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1583 | } else { |
robinmc | 0:28392431dbad | 1584 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1585 | } |
robinmc | 0:28392431dbad | 1586 | } else if (n==70&(ammo%100>=60&ammo%100<70)) { |
robinmc | 0:28392431dbad | 1587 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 1588 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1589 | } else { |
robinmc | 0:28392431dbad | 1590 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1591 | } |
robinmc | 0:28392431dbad | 1592 | } else if (n==70&(ammo%100>=70&ammo%100<80)) { |
robinmc | 0:28392431dbad | 1593 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 1594 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1595 | } else { |
robinmc | 0:28392431dbad | 1596 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1597 | } |
robinmc | 0:28392431dbad | 1598 | } else if (n==70&(ammo%100>=80&ammo%100<90)) { |
robinmc | 0:28392431dbad | 1599 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 1600 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1601 | } else { |
robinmc | 0:28392431dbad | 1602 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1603 | } |
robinmc | 0:28392431dbad | 1604 | } else if (n==70&(ammo%100>=90&ammo%100<100)) { |
robinmc | 0:28392431dbad | 1605 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 1606 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1607 | } else { |
robinmc | 0:28392431dbad | 1608 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1609 | } |
robinmc | 0:28392431dbad | 1610 | } |
robinmc | 0:28392431dbad | 1611 | } |
robinmc | 0:28392431dbad | 1612 | } |
robinmc | 0:28392431dbad | 1613 | } |
robinmc | 0:28392431dbad | 1614 | for(int c=0; c<=14; c++) { //14 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 1615 | for(int r=0; r<=4; r++) { |
robinmc | 0:28392431dbad | 1616 | if (g_ammo[r][c]==0) { |
robinmc | 0:28392431dbad | 1617 | lcd.clearPixel(c+50,r); |
robinmc | 0:28392431dbad | 1618 | } else if (g_ammo[r][c]==1) { |
robinmc | 0:28392431dbad | 1619 | lcd.setPixel(c+50,r); |
robinmc | 0:28392431dbad | 1620 | } |
robinmc | 0:28392431dbad | 1621 | } |
robinmc | 0:28392431dbad | 1622 | } |
robinmc | 0:28392431dbad | 1623 | if (ammo>=99) { |
robinmc | 0:28392431dbad | 1624 | ammo=99; |
robinmc | 0:28392431dbad | 1625 | } |
robinmc | 0:28392431dbad | 1626 | lcd.refresh(); |
robinmc | 0:28392431dbad | 1627 | } |
robinmc | 0:28392431dbad | 1628 | |
robinmc | 0:28392431dbad | 1629 | void print_score() |
robinmc | 0:28392431dbad | 1630 | { |
robinmc | 0:28392431dbad | 1631 | score=h_movement/10+kill_score; |
robinmc | 0:28392431dbad | 1632 | if (score<=0) { |
robinmc | 0:28392431dbad | 1633 | score=0; |
robinmc | 0:28392431dbad | 1634 | } |
robinmc | 0:28392431dbad | 1635 | for(int c=0; c<=2; c++) { //2 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 1636 | for(int r=0; r<=4; r++) { |
robinmc | 0:28392431dbad | 1637 | for (int n=24; n<=36; n+=4) { |
robinmc | 0:28392431dbad | 1638 | if (n==36&score%10==0) { |
robinmc | 0:28392431dbad | 1639 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 1640 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1641 | } else { |
robinmc | 0:28392431dbad | 1642 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1643 | } |
robinmc | 0:28392431dbad | 1644 | } else if (n==36&score%10==1) { |
robinmc | 0:28392431dbad | 1645 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 1646 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1647 | } else { |
robinmc | 0:28392431dbad | 1648 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1649 | } |
robinmc | 0:28392431dbad | 1650 | } else if (n==36&score%10==2) { |
robinmc | 0:28392431dbad | 1651 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 1652 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1653 | } else { |
robinmc | 0:28392431dbad | 1654 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1655 | } |
robinmc | 0:28392431dbad | 1656 | } else if (n==36&score%10==3) { |
robinmc | 0:28392431dbad | 1657 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 1658 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1659 | } else { |
robinmc | 0:28392431dbad | 1660 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1661 | } |
robinmc | 0:28392431dbad | 1662 | } else if (n==36&score%10==4) { |
robinmc | 0:28392431dbad | 1663 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 1664 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1665 | } else { |
robinmc | 0:28392431dbad | 1666 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1667 | } |
robinmc | 0:28392431dbad | 1668 | } else if (n==36&score%10==5) { |
robinmc | 0:28392431dbad | 1669 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 1670 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1671 | } else { |
robinmc | 0:28392431dbad | 1672 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1673 | } |
robinmc | 0:28392431dbad | 1674 | } else if (n==36&score%10==6) { |
robinmc | 0:28392431dbad | 1675 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 1676 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1677 | } else { |
robinmc | 0:28392431dbad | 1678 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1679 | } |
robinmc | 0:28392431dbad | 1680 | } else if (n==36&score%10==7) { |
robinmc | 0:28392431dbad | 1681 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 1682 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1683 | } else { |
robinmc | 0:28392431dbad | 1684 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1685 | } |
robinmc | 0:28392431dbad | 1686 | } else if (n==36&score%10==8) { |
robinmc | 0:28392431dbad | 1687 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 1688 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1689 | } else { |
robinmc | 0:28392431dbad | 1690 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1691 | } |
robinmc | 0:28392431dbad | 1692 | } else if (n==36&score%10==9) { |
robinmc | 0:28392431dbad | 1693 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 1694 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1695 | } else { |
robinmc | 0:28392431dbad | 1696 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1697 | } |
robinmc | 0:28392431dbad | 1698 | } |
robinmc | 0:28392431dbad | 1699 | |
robinmc | 0:28392431dbad | 1700 | if (n==32&(score%100>=0&score%100<10)) { |
robinmc | 0:28392431dbad | 1701 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 1702 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1703 | } else { |
robinmc | 0:28392431dbad | 1704 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1705 | } |
robinmc | 0:28392431dbad | 1706 | } else if (n==32&(score%100>=10&score%100<20)) { |
robinmc | 0:28392431dbad | 1707 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 1708 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1709 | } else { |
robinmc | 0:28392431dbad | 1710 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1711 | } |
robinmc | 0:28392431dbad | 1712 | } else if (n==32&(score%100>=20&score%100<30)) { |
robinmc | 0:28392431dbad | 1713 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 1714 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1715 | } else { |
robinmc | 0:28392431dbad | 1716 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1717 | } |
robinmc | 0:28392431dbad | 1718 | } else if (n==32&(score%100>=30&score%100<40)) { |
robinmc | 0:28392431dbad | 1719 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 1720 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1721 | } else { |
robinmc | 0:28392431dbad | 1722 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1723 | } |
robinmc | 0:28392431dbad | 1724 | } else if (n==32&(score%100>=40&score%100<50)) { |
robinmc | 0:28392431dbad | 1725 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 1726 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1727 | } else { |
robinmc | 0:28392431dbad | 1728 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1729 | } |
robinmc | 0:28392431dbad | 1730 | } else if (n==32&(score%100>=50&score%100<60)) { |
robinmc | 0:28392431dbad | 1731 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 1732 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1733 | } else { |
robinmc | 0:28392431dbad | 1734 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1735 | } |
robinmc | 0:28392431dbad | 1736 | } else if (n==32&(score%100>=60&score%100<70)) { |
robinmc | 0:28392431dbad | 1737 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 1738 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1739 | } else { |
robinmc | 0:28392431dbad | 1740 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1741 | } |
robinmc | 0:28392431dbad | 1742 | } else if (n==32&(score%100>=70&score%100<80)) { |
robinmc | 0:28392431dbad | 1743 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 1744 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1745 | } else { |
robinmc | 0:28392431dbad | 1746 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1747 | } |
robinmc | 0:28392431dbad | 1748 | } else if (n==32&(score%100>=80&score%100<90)) { |
robinmc | 0:28392431dbad | 1749 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 1750 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1751 | } else { |
robinmc | 0:28392431dbad | 1752 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1753 | } |
robinmc | 0:28392431dbad | 1754 | } else if (n==32&(score%100>=90&score%100<100)) { |
robinmc | 0:28392431dbad | 1755 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 1756 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1757 | } else { |
robinmc | 0:28392431dbad | 1758 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1759 | } |
robinmc | 0:28392431dbad | 1760 | } |
robinmc | 0:28392431dbad | 1761 | if (n==28&(score%1000>=0&score%1000<100)) { |
robinmc | 0:28392431dbad | 1762 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 1763 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1764 | } else { |
robinmc | 0:28392431dbad | 1765 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1766 | } |
robinmc | 0:28392431dbad | 1767 | } else if (n==28&(score%1000>=100&score%1000<200)) { |
robinmc | 0:28392431dbad | 1768 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 1769 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1770 | } else { |
robinmc | 0:28392431dbad | 1771 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1772 | } |
robinmc | 0:28392431dbad | 1773 | } else if (n==28&(score%1000>=200&score%1000<300)) { |
robinmc | 0:28392431dbad | 1774 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 1775 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1776 | } else { |
robinmc | 0:28392431dbad | 1777 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1778 | } |
robinmc | 0:28392431dbad | 1779 | } else if (n==28&(score%1000>=300&score%1000<400)) { |
robinmc | 0:28392431dbad | 1780 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 1781 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1782 | } else { |
robinmc | 0:28392431dbad | 1783 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1784 | } |
robinmc | 0:28392431dbad | 1785 | } else if (n==28&(score%1000>=400&score%1000<500)) { |
robinmc | 0:28392431dbad | 1786 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 1787 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1788 | } else { |
robinmc | 0:28392431dbad | 1789 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1790 | } |
robinmc | 0:28392431dbad | 1791 | } else if (n==28&(score%1000>=500&score%1000<600)) { |
robinmc | 0:28392431dbad | 1792 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 1793 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1794 | } else { |
robinmc | 0:28392431dbad | 1795 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1796 | } |
robinmc | 0:28392431dbad | 1797 | } else if (n==28&(score%1000>=600&score%1000<700)) { |
robinmc | 0:28392431dbad | 1798 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 1799 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1800 | } else { |
robinmc | 0:28392431dbad | 1801 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1802 | } |
robinmc | 0:28392431dbad | 1803 | } else if (n==28&(score%1000>=700&score%1000<800)) { |
robinmc | 0:28392431dbad | 1804 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 1805 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1806 | } else { |
robinmc | 0:28392431dbad | 1807 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1808 | } |
robinmc | 0:28392431dbad | 1809 | } else if (n==28&(score%1000>=800&score%1000<900)) { |
robinmc | 0:28392431dbad | 1810 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 1811 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1812 | } else { |
robinmc | 0:28392431dbad | 1813 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1814 | } |
robinmc | 0:28392431dbad | 1815 | } else if (n==28&(score%1000>=900&score%1000<1000)) { |
robinmc | 0:28392431dbad | 1816 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 1817 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1818 | } else { |
robinmc | 0:28392431dbad | 1819 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1820 | } |
robinmc | 0:28392431dbad | 1821 | } |
robinmc | 0:28392431dbad | 1822 | if (n==24&(score%10000>=0&score%10000<1000)) { |
robinmc | 0:28392431dbad | 1823 | if (zero[r][c]==1) { |
robinmc | 0:28392431dbad | 1824 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1825 | } else { |
robinmc | 0:28392431dbad | 1826 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1827 | } |
robinmc | 0:28392431dbad | 1828 | } else if (n==24&(score%10000>=1000&score%10000<2000)) { |
robinmc | 0:28392431dbad | 1829 | if (one[r][c]==1) { |
robinmc | 0:28392431dbad | 1830 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1831 | } else { |
robinmc | 0:28392431dbad | 1832 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1833 | } |
robinmc | 0:28392431dbad | 1834 | } else if (n==24&(score%10000>=2000&score%10000<3000)) { |
robinmc | 0:28392431dbad | 1835 | if (two[r][c]==1) { |
robinmc | 0:28392431dbad | 1836 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1837 | } else { |
robinmc | 0:28392431dbad | 1838 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1839 | } |
robinmc | 0:28392431dbad | 1840 | } else if (n==24&(score%10000>=3000&score%10000<4000)) { |
robinmc | 0:28392431dbad | 1841 | if (three[r][c]==1) { |
robinmc | 0:28392431dbad | 1842 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1843 | } else { |
robinmc | 0:28392431dbad | 1844 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1845 | } |
robinmc | 0:28392431dbad | 1846 | } else if (n==24&(score%10000>=4000&score%10000<5000)) { |
robinmc | 0:28392431dbad | 1847 | if (four[r][c]==1) { |
robinmc | 0:28392431dbad | 1848 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1849 | } else { |
robinmc | 0:28392431dbad | 1850 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1851 | } |
robinmc | 0:28392431dbad | 1852 | } else if (n==24&(score%10000>=5000&score%10000<6000)) { |
robinmc | 0:28392431dbad | 1853 | if (five[r][c]==1) { |
robinmc | 0:28392431dbad | 1854 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1855 | } else { |
robinmc | 0:28392431dbad | 1856 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1857 | } |
robinmc | 0:28392431dbad | 1858 | } else if (n==24&(score%10000>=6000&score%10000<7000)) { |
robinmc | 0:28392431dbad | 1859 | if (six[r][c]==1) { |
robinmc | 0:28392431dbad | 1860 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1861 | } else { |
robinmc | 0:28392431dbad | 1862 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1863 | } |
robinmc | 0:28392431dbad | 1864 | } else if (n==24&(score%10000>=7000&score%10000<8000)) { |
robinmc | 0:28392431dbad | 1865 | if (seven[r][c]==1) { |
robinmc | 0:28392431dbad | 1866 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1867 | } else { |
robinmc | 0:28392431dbad | 1868 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1869 | } |
robinmc | 0:28392431dbad | 1870 | } else if (n==24&(score%10000>=8000&score%10000<9000)) { |
robinmc | 0:28392431dbad | 1871 | if (eight[r][c]==1) { |
robinmc | 0:28392431dbad | 1872 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1873 | } else { |
robinmc | 0:28392431dbad | 1874 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1875 | } |
robinmc | 0:28392431dbad | 1876 | } else if (n==24&(score%10000>=9000&score%10000<10000)) { |
robinmc | 0:28392431dbad | 1877 | if (nine[r][c]==1) { |
robinmc | 0:28392431dbad | 1878 | lcd.setPixel(c+n,r); |
robinmc | 0:28392431dbad | 1879 | } else { |
robinmc | 0:28392431dbad | 1880 | lcd.clearPixel(c+n,r); |
robinmc | 0:28392431dbad | 1881 | } |
robinmc | 0:28392431dbad | 1882 | } |
robinmc | 0:28392431dbad | 1883 | } |
robinmc | 0:28392431dbad | 1884 | } |
robinmc | 0:28392431dbad | 1885 | } |
robinmc | 0:28392431dbad | 1886 | for(int c=0; c<=18; c++) { //18 beacause the the loop stats from 0 but the array size from 1 |
robinmc | 0:28392431dbad | 1887 | for(int r=0; r<=4; r++) { |
robinmc | 0:28392431dbad | 1888 | if (g_score[r][c]==0) { |
robinmc | 0:28392431dbad | 1889 | lcd.clearPixel(c,r); |
robinmc | 0:28392431dbad | 1890 | } else if (g_score[r][c]==1) { |
robinmc | 0:28392431dbad | 1891 | lcd.setPixel(c,r); |
robinmc | 0:28392431dbad | 1892 | } |
robinmc | 0:28392431dbad | 1893 | } |
robinmc | 0:28392431dbad | 1894 | } |
robinmc | 0:28392431dbad | 1895 | lcd.refresh(); |
robinmc | 0:28392431dbad | 1896 | } |