
updated 7seg controls for new 7 seg boards
Dependencies: PixelArray WS2812 mbed
Fork of frdm_pong_table_controller by
main.cpp@6:5e8e2645cd93, 2017-07-10 (annotated)
- Committer:
- DanGibbons
- Date:
- Mon Jul 10 11:05:06 2017 +0000
- Revision:
- 6:5e8e2645cd93
- Parent:
- 5:2d439ccefc7d
- Child:
- 7:dc6f1f105c52
All animations added. ; Prior version to adding start/idle button
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DanGibbons | 4:2e80bd814f57 | 1 | #include "main.h" |
benswindell | 0:f2b739e846ae | 2 | |
DanGibbons | 4:2e80bd814f57 | 3 | int main() |
DanGibbons | 4:2e80bd814f57 | 4 | { |
DanGibbons | 4:2e80bd814f57 | 5 | Setup(); |
benswindell | 0:f2b739e846ae | 6 | |
DanGibbons | 4:2e80bd814f57 | 7 | while(1) { |
DanGibbons | 4:2e80bd814f57 | 8 | |
DanGibbons | 4:2e80bd814f57 | 9 | double rbbValue = robotBreakBeam; // Read Robot Break beam |
DanGibbons | 4:2e80bd814f57 | 10 | double pbbValue = playerBreakBeam; // Read Player Break beam |
benswindell | 0:f2b739e846ae | 11 | |
DanGibbons | 4:2e80bd814f57 | 12 | // IF PLAYER HAS SCORED A GOAL |
DanGibbons | 4:2e80bd814f57 | 13 | if (((prevRbbValue - rbbValue)>0.03)|| (PB1==0)) { |
DanGibbons | 4:2e80bd814f57 | 14 | pc.printf("Player has scored a goal \n\r"); |
DanGibbons | 4:2e80bd814f57 | 15 | HandleGoal(false); |
DanGibbons | 4:2e80bd814f57 | 16 | } |
benswindell | 0:f2b739e846ae | 17 | |
DanGibbons | 4:2e80bd814f57 | 18 | // IF ROBOT HAS SCORED A GOAL |
DanGibbons | 4:2e80bd814f57 | 19 | if (((prevPbbValue - pbbValue) > 0.03)|| (PB2==0)) { |
DanGibbons | 4:2e80bd814f57 | 20 | pc.printf("Robot has scored a goal \n\r"); |
DanGibbons | 4:2e80bd814f57 | 21 | HandleGoal(true); |
DanGibbons | 4:2e80bd814f57 | 22 | } |
benswindell | 0:f2b739e846ae | 23 | |
DanGibbons | 4:2e80bd814f57 | 24 | prevRbbValue = rbbValue; |
DanGibbons | 4:2e80bd814f57 | 25 | prevPbbValue = pbbValue; |
benswindell | 0:f2b739e846ae | 26 | |
DanGibbons | 4:2e80bd814f57 | 27 | pc.printf("PlayerGoal: %f, RobotGoal: %f \r\n",pbbValue,rbbValue); |
DanGibbons | 4:2e80bd814f57 | 28 | pc.printf("Player: %i v %i : Robot \r\n",playerScore,robotScore); |
DanGibbons | 4:2e80bd814f57 | 29 | wait(0.02); |
benswindell | 0:f2b739e846ae | 30 | |
DanGibbons | 4:2e80bd814f57 | 31 | } |
DanGibbons | 6:5e8e2645cd93 | 32 | |
DanGibbons | 4:2e80bd814f57 | 33 | } |
samuelmoss | 2:ff409472bc08 | 34 | |
DanGibbons | 4:2e80bd814f57 | 35 | void Setup() |
benswindell | 0:f2b739e846ae | 36 | { |
benswindell | 0:f2b739e846ae | 37 | // Turn on green LED |
benswindell | 0:f2b739e846ae | 38 | led_green = 0; |
DanGibbons | 6:5e8e2645cd93 | 39 | |
DanGibbons | 6:5e8e2645cd93 | 40 | // attach idle button isr to rising edge of button press |
DanGibbons | 6:5e8e2645cd93 | 41 | idleButton.rise(&idleButtonISR); |
DanGibbons | 6:5e8e2645cd93 | 42 | |
DanGibbons | 6:5e8e2645cd93 | 43 | // enable the internal pull-down resistor on idleButton |
DanGibbons | 6:5e8e2645cd93 | 44 | idleButton.mode(PullDown); |
benswindell | 0:f2b739e846ae | 45 | |
benswindell | 1:24bc4d8ed2ae | 46 | // Set brightness of the 4 LED strips |
samuelmoss | 2:ff409472bc08 | 47 | robotScoreLED.setII(0xB0); |
benswindell | 1:24bc4d8ed2ae | 48 | robotScoreLED.useII(WS2812::GLOBAL); |
samuelmoss | 2:ff409472bc08 | 49 | playerScoreLED.setII(0xB0); |
benswindell | 1:24bc4d8ed2ae | 50 | playerScoreLED.useII(WS2812::GLOBAL); |
DanGibbons | 4:2e80bd814f57 | 51 | |
benswindell | 0:f2b739e846ae | 52 | // Set scores to 0 |
benswindell | 0:f2b739e846ae | 53 | robotScore = 0; |
benswindell | 0:f2b739e846ae | 54 | playerScore = 0; |
benswindell | 0:f2b739e846ae | 55 | numFlashes = 0; |
DanGibbons | 5:2d439ccefc7d | 56 | |
DanGibbons | 6:5e8e2645cd93 | 57 | CircleAnimation(true,true,true,true,2); |
DanGibbons | 6:5e8e2645cd93 | 58 | SetNumberPatterns(); |
DanGibbons | 6:5e8e2645cd93 | 59 | |
DanGibbons | 5:2d439ccefc7d | 60 | DrainAnimation(true,true,robotScore,true,true,playerScore); // run animation for both scores with random colour pattern |
DanGibbons | 5:2d439ccefc7d | 61 | |
DanGibbons | 6:5e8e2645cd93 | 62 | wait(1.5); |
DanGibbons | 5:2d439ccefc7d | 63 | |
DanGibbons | 6:5e8e2645cd93 | 64 | ZeroInAnimation(true,false,true,false); |
samuelmoss | 2:ff409472bc08 | 65 | |
benswindell | 0:f2b739e846ae | 66 | // Turn off green LED |
benswindell | 0:f2b739e846ae | 67 | led_green = 1; |
benswindell | 0:f2b739e846ae | 68 | } |
benswindell | 0:f2b739e846ae | 69 | |
DanGibbons | 5:2d439ccefc7d | 70 | // set segment number patterns |
DanGibbons | 4:2e80bd814f57 | 71 | void SetNumberPatterns() |
benswindell | 0:f2b739e846ae | 72 | { |
DanGibbons | 4:2e80bd814f57 | 73 | for (int num = 0; num < 11; num++) { |
benswindell | 0:f2b739e846ae | 74 | |
DanGibbons | 4:2e80bd814f57 | 75 | switch (num) { |
DanGibbons | 4:2e80bd814f57 | 76 | case 0 : |
DanGibbons | 4:2e80bd814f57 | 77 | // 0 |
DanGibbons | 4:2e80bd814f57 | 78 | seg1A = 1; |
DanGibbons | 4:2e80bd814f57 | 79 | seg1B = 1; |
DanGibbons | 4:2e80bd814f57 | 80 | seg1C = 1; |
DanGibbons | 4:2e80bd814f57 | 81 | seg1D = 1; |
DanGibbons | 4:2e80bd814f57 | 82 | seg1E = 1; |
DanGibbons | 4:2e80bd814f57 | 83 | seg1F = 1; |
DanGibbons | 4:2e80bd814f57 | 84 | seg1G = 0; |
benswindell | 0:f2b739e846ae | 85 | |
DanGibbons | 4:2e80bd814f57 | 86 | SetLEDArray(0); |
DanGibbons | 4:2e80bd814f57 | 87 | break; |
benswindell | 0:f2b739e846ae | 88 | |
DanGibbons | 4:2e80bd814f57 | 89 | case 1 : |
DanGibbons | 4:2e80bd814f57 | 90 | // 1 |
DanGibbons | 4:2e80bd814f57 | 91 | seg1A = 0; |
DanGibbons | 4:2e80bd814f57 | 92 | seg1B = 1; |
DanGibbons | 4:2e80bd814f57 | 93 | seg1C = 1; |
DanGibbons | 4:2e80bd814f57 | 94 | seg1D = 0; |
DanGibbons | 4:2e80bd814f57 | 95 | seg1E = 0; |
DanGibbons | 4:2e80bd814f57 | 96 | seg1F = 0; |
DanGibbons | 4:2e80bd814f57 | 97 | seg1G = 0; |
benswindell | 0:f2b739e846ae | 98 | |
DanGibbons | 4:2e80bd814f57 | 99 | SetLEDArray(1); |
DanGibbons | 4:2e80bd814f57 | 100 | break; |
benswindell | 0:f2b739e846ae | 101 | |
DanGibbons | 4:2e80bd814f57 | 102 | case 2 : |
DanGibbons | 4:2e80bd814f57 | 103 | // 2 |
DanGibbons | 4:2e80bd814f57 | 104 | seg1A = 1; |
DanGibbons | 4:2e80bd814f57 | 105 | seg1B = 1; |
DanGibbons | 4:2e80bd814f57 | 106 | seg1C = 0; |
DanGibbons | 4:2e80bd814f57 | 107 | seg1D = 1; |
DanGibbons | 4:2e80bd814f57 | 108 | seg1E = 1; |
DanGibbons | 4:2e80bd814f57 | 109 | seg1F = 0; |
DanGibbons | 4:2e80bd814f57 | 110 | seg1G = 1; |
benswindell | 0:f2b739e846ae | 111 | |
DanGibbons | 4:2e80bd814f57 | 112 | SetLEDArray(2); |
DanGibbons | 4:2e80bd814f57 | 113 | break; |
benswindell | 0:f2b739e846ae | 114 | |
DanGibbons | 4:2e80bd814f57 | 115 | case 3 : |
DanGibbons | 4:2e80bd814f57 | 116 | // 3 |
DanGibbons | 4:2e80bd814f57 | 117 | seg1A = 1; |
DanGibbons | 4:2e80bd814f57 | 118 | seg1B = 1; |
DanGibbons | 4:2e80bd814f57 | 119 | seg1C = 1; |
DanGibbons | 4:2e80bd814f57 | 120 | seg1D = 1; |
DanGibbons | 4:2e80bd814f57 | 121 | seg1E = 0; |
DanGibbons | 4:2e80bd814f57 | 122 | seg1F = 0; |
DanGibbons | 4:2e80bd814f57 | 123 | seg1G = 1; |
benswindell | 0:f2b739e846ae | 124 | |
DanGibbons | 4:2e80bd814f57 | 125 | SetLEDArray(3); |
DanGibbons | 4:2e80bd814f57 | 126 | break; |
benswindell | 0:f2b739e846ae | 127 | |
DanGibbons | 4:2e80bd814f57 | 128 | case 4: |
DanGibbons | 4:2e80bd814f57 | 129 | // 4 |
DanGibbons | 4:2e80bd814f57 | 130 | seg1A = 0; |
DanGibbons | 4:2e80bd814f57 | 131 | seg1B = 1; |
DanGibbons | 4:2e80bd814f57 | 132 | seg1C = 1; |
DanGibbons | 4:2e80bd814f57 | 133 | seg1D = 0; |
DanGibbons | 4:2e80bd814f57 | 134 | seg1E = 0; |
DanGibbons | 4:2e80bd814f57 | 135 | seg1F = 1; |
DanGibbons | 4:2e80bd814f57 | 136 | seg1G = 1; |
benswindell | 0:f2b739e846ae | 137 | |
DanGibbons | 4:2e80bd814f57 | 138 | SetLEDArray(4); |
DanGibbons | 4:2e80bd814f57 | 139 | break; |
benswindell | 0:f2b739e846ae | 140 | |
DanGibbons | 4:2e80bd814f57 | 141 | case 5: |
DanGibbons | 4:2e80bd814f57 | 142 | // 5 |
DanGibbons | 4:2e80bd814f57 | 143 | seg1A = 1; |
DanGibbons | 4:2e80bd814f57 | 144 | seg1B = 0; |
DanGibbons | 4:2e80bd814f57 | 145 | seg1C = 1; |
DanGibbons | 4:2e80bd814f57 | 146 | seg1D = 1; |
DanGibbons | 4:2e80bd814f57 | 147 | seg1E = 0; |
DanGibbons | 4:2e80bd814f57 | 148 | seg1F = 1; |
DanGibbons | 4:2e80bd814f57 | 149 | seg1G = 1; |
benswindell | 0:f2b739e846ae | 150 | |
DanGibbons | 4:2e80bd814f57 | 151 | SetLEDArray(5); |
DanGibbons | 4:2e80bd814f57 | 152 | break; |
benswindell | 0:f2b739e846ae | 153 | |
DanGibbons | 4:2e80bd814f57 | 154 | case 6: |
DanGibbons | 4:2e80bd814f57 | 155 | // 6 |
DanGibbons | 4:2e80bd814f57 | 156 | seg1A = 1; |
DanGibbons | 4:2e80bd814f57 | 157 | seg1B = 0; |
DanGibbons | 4:2e80bd814f57 | 158 | seg1C = 1; |
DanGibbons | 4:2e80bd814f57 | 159 | seg1D = 1; |
DanGibbons | 4:2e80bd814f57 | 160 | seg1E = 1; |
DanGibbons | 4:2e80bd814f57 | 161 | seg1F = 1; |
DanGibbons | 4:2e80bd814f57 | 162 | seg1G = 1; |
benswindell | 0:f2b739e846ae | 163 | |
DanGibbons | 4:2e80bd814f57 | 164 | SetLEDArray(6); |
DanGibbons | 4:2e80bd814f57 | 165 | break; |
benswindell | 0:f2b739e846ae | 166 | |
DanGibbons | 4:2e80bd814f57 | 167 | case 7: |
DanGibbons | 4:2e80bd814f57 | 168 | // 7 |
DanGibbons | 4:2e80bd814f57 | 169 | seg1A = 1; |
DanGibbons | 4:2e80bd814f57 | 170 | seg1B = 1; |
DanGibbons | 4:2e80bd814f57 | 171 | seg1C = 1; |
DanGibbons | 4:2e80bd814f57 | 172 | seg1D = 0; |
DanGibbons | 4:2e80bd814f57 | 173 | seg1E = 0; |
DanGibbons | 4:2e80bd814f57 | 174 | seg1F = 0; |
DanGibbons | 4:2e80bd814f57 | 175 | seg1G = 0; |
benswindell | 0:f2b739e846ae | 176 | |
DanGibbons | 4:2e80bd814f57 | 177 | SetLEDArray(7); |
DanGibbons | 4:2e80bd814f57 | 178 | break; |
benswindell | 0:f2b739e846ae | 179 | |
DanGibbons | 4:2e80bd814f57 | 180 | case 8: |
DanGibbons | 4:2e80bd814f57 | 181 | // 8 |
DanGibbons | 4:2e80bd814f57 | 182 | seg1A = 1; |
DanGibbons | 4:2e80bd814f57 | 183 | seg1B = 1; |
DanGibbons | 4:2e80bd814f57 | 184 | seg1C = 1; |
DanGibbons | 4:2e80bd814f57 | 185 | seg1D = 1; |
DanGibbons | 4:2e80bd814f57 | 186 | seg1E = 1; |
DanGibbons | 4:2e80bd814f57 | 187 | seg1F = 1; |
DanGibbons | 4:2e80bd814f57 | 188 | seg1G = 1; |
benswindell | 0:f2b739e846ae | 189 | |
DanGibbons | 4:2e80bd814f57 | 190 | SetLEDArray(8); |
DanGibbons | 4:2e80bd814f57 | 191 | break; |
benswindell | 0:f2b739e846ae | 192 | |
DanGibbons | 4:2e80bd814f57 | 193 | case 9: |
DanGibbons | 4:2e80bd814f57 | 194 | // 9 |
DanGibbons | 4:2e80bd814f57 | 195 | seg1A = 1; |
DanGibbons | 4:2e80bd814f57 | 196 | seg1B = 1; |
DanGibbons | 4:2e80bd814f57 | 197 | seg1C = 1; |
DanGibbons | 4:2e80bd814f57 | 198 | seg1D = 0; |
DanGibbons | 4:2e80bd814f57 | 199 | seg1E = 0; |
DanGibbons | 4:2e80bd814f57 | 200 | seg1F = 1; |
DanGibbons | 4:2e80bd814f57 | 201 | seg1G = 1; |
benswindell | 0:f2b739e846ae | 202 | |
DanGibbons | 4:2e80bd814f57 | 203 | SetLEDArray(9); |
DanGibbons | 4:2e80bd814f57 | 204 | break; |
benswindell | 0:f2b739e846ae | 205 | |
DanGibbons | 4:2e80bd814f57 | 206 | case 10: |
DanGibbons | 4:2e80bd814f57 | 207 | // OFF |
DanGibbons | 4:2e80bd814f57 | 208 | seg1A = 0; |
DanGibbons | 4:2e80bd814f57 | 209 | seg1B = 0; |
DanGibbons | 4:2e80bd814f57 | 210 | seg1C = 0; |
DanGibbons | 4:2e80bd814f57 | 211 | seg1D = 0; |
DanGibbons | 4:2e80bd814f57 | 212 | seg1E = 0; |
DanGibbons | 4:2e80bd814f57 | 213 | seg1F = 0; |
DanGibbons | 4:2e80bd814f57 | 214 | seg1G = 0; |
benswindell | 0:f2b739e846ae | 215 | |
DanGibbons | 4:2e80bd814f57 | 216 | SetLEDArray(10); |
DanGibbons | 4:2e80bd814f57 | 217 | break; |
benswindell | 0:f2b739e846ae | 218 | |
DanGibbons | 4:2e80bd814f57 | 219 | default : |
benswindell | 0:f2b739e846ae | 220 | |
DanGibbons | 4:2e80bd814f57 | 221 | break; |
DanGibbons | 4:2e80bd814f57 | 222 | |
DanGibbons | 4:2e80bd814f57 | 223 | } |
benswindell | 0:f2b739e846ae | 224 | |
benswindell | 0:f2b739e846ae | 225 | } |
DanGibbons | 4:2e80bd814f57 | 226 | |
DanGibbons | 4:2e80bd814f57 | 227 | } |
DanGibbons | 4:2e80bd814f57 | 228 | |
benswindell | 0:f2b739e846ae | 229 | // Write segment config to main array |
benswindell | 0:f2b739e846ae | 230 | void SetLEDArray(int x) |
benswindell | 0:f2b739e846ae | 231 | { |
benswindell | 0:f2b739e846ae | 232 | for (int i = 0; i < WS2812_BUF; i++) { |
samuelmoss | 2:ff409472bc08 | 233 | if (i < 18) { |
DanGibbons | 5:2d439ccefc7d | 234 | mainArray[x][i] = seg1A; |
benswindell | 0:f2b739e846ae | 235 | } |
benswindell | 0:f2b739e846ae | 236 | |
samuelmoss | 2:ff409472bc08 | 237 | if ( i >= 18 && i < 35) { |
benswindell | 0:f2b739e846ae | 238 | mainArray[x][i] = seg1B; |
benswindell | 0:f2b739e846ae | 239 | } |
benswindell | 0:f2b739e846ae | 240 | |
samuelmoss | 2:ff409472bc08 | 241 | if (i >= 35 && i < 52) { |
benswindell | 0:f2b739e846ae | 242 | mainArray[x][i] = seg1C; |
benswindell | 0:f2b739e846ae | 243 | } |
benswindell | 0:f2b739e846ae | 244 | |
samuelmoss | 2:ff409472bc08 | 245 | if (i >= 52 && i < 70) { |
benswindell | 0:f2b739e846ae | 246 | mainArray[x][i]= seg1D; |
benswindell | 0:f2b739e846ae | 247 | } |
benswindell | 0:f2b739e846ae | 248 | |
samuelmoss | 2:ff409472bc08 | 249 | if ( i >= 70 && i < 87) { |
benswindell | 0:f2b739e846ae | 250 | mainArray[x][i] = seg1E; |
benswindell | 0:f2b739e846ae | 251 | } |
benswindell | 0:f2b739e846ae | 252 | |
samuelmoss | 2:ff409472bc08 | 253 | if (i >= 87 && i < 104) { |
benswindell | 0:f2b739e846ae | 254 | mainArray[x][i] = seg1F; |
benswindell | 0:f2b739e846ae | 255 | } |
benswindell | 0:f2b739e846ae | 256 | |
samuelmoss | 2:ff409472bc08 | 257 | if ( i >= 104 && i < 122) { |
benswindell | 0:f2b739e846ae | 258 | mainArray[x][i] = seg1G; |
benswindell | 0:f2b739e846ae | 259 | } |
DanGibbons | 4:2e80bd814f57 | 260 | } |
benswindell | 0:f2b739e846ae | 261 | } |
benswindell | 0:f2b739e846ae | 262 | |
benswindell | 1:24bc4d8ed2ae | 263 | // Update both Score LEDs with the current score |
DanGibbons | 6:5e8e2645cd93 | 264 | void WriteAnimation() |
benswindell | 0:f2b739e846ae | 265 | { |
DanGibbons | 6:5e8e2645cd93 | 266 | WritePxAnimation(playerScore,false,false); |
benswindell | 1:24bc4d8ed2ae | 267 | playerScoreLED.write(playerScorePx.getBuf()); |
benswindell | 0:f2b739e846ae | 268 | wait(0.01); |
DanGibbons | 6:5e8e2645cd93 | 269 | WritePxAnimation(robotScore,true,false); |
benswindell | 1:24bc4d8ed2ae | 270 | robotScoreLED.write(robotScorePx.getBuf()); |
benswindell | 0:f2b739e846ae | 271 | } |
benswindell | 0:f2b739e846ae | 272 | |
DanGibbons | 6:5e8e2645cd93 | 273 | // Write Pixel array with either random colour pattern or in standard blue |
DanGibbons | 6:5e8e2645cd93 | 274 | void WritePxAnimation(int line_num,bool isRobot,bool colour) |
benswindell | 0:f2b739e846ae | 275 | { |
DanGibbons | 6:5e8e2645cd93 | 276 | if (colour == true) { // random colours |
DanGibbons | 6:5e8e2645cd93 | 277 | if(isRobot == true) { |
benswindell | 1:24bc4d8ed2ae | 278 | |
DanGibbons | 6:5e8e2645cd93 | 279 | for (int i = 0; i < WS2812_BUF; i++) { |
DanGibbons | 6:5e8e2645cd93 | 280 | if (mainArray[line_num][i] == 0) { |
DanGibbons | 6:5e8e2645cd93 | 281 | robotScorePx.Set(i,OFF); |
DanGibbons | 6:5e8e2645cd93 | 282 | } |
DanGibbons | 5:2d439ccefc7d | 283 | |
DanGibbons | 6:5e8e2645cd93 | 284 | if (mainArray[line_num][i] == 1) { |
DanGibbons | 6:5e8e2645cd93 | 285 | robotScorePx.Set(i,rand_colors[rand() % 10]); |
DanGibbons | 6:5e8e2645cd93 | 286 | } |
DanGibbons | 5:2d439ccefc7d | 287 | } |
DanGibbons | 6:5e8e2645cd93 | 288 | } else { |
DanGibbons | 6:5e8e2645cd93 | 289 | for (int i = 0; i < WS2812_BUF; i++) { |
DanGibbons | 6:5e8e2645cd93 | 290 | if (mainArray[line_num][i] == 0) { |
DanGibbons | 6:5e8e2645cd93 | 291 | playerScorePx.Set(i,OFF); |
DanGibbons | 6:5e8e2645cd93 | 292 | } |
DanGibbons | 5:2d439ccefc7d | 293 | |
DanGibbons | 6:5e8e2645cd93 | 294 | if (mainArray[line_num][i] == 1) { |
DanGibbons | 6:5e8e2645cd93 | 295 | playerScorePx.Set(i,rand_colors[rand() % 10]); |
DanGibbons | 6:5e8e2645cd93 | 296 | } |
DanGibbons | 5:2d439ccefc7d | 297 | } |
DanGibbons | 5:2d439ccefc7d | 298 | } |
DanGibbons | 6:5e8e2645cd93 | 299 | } else { // blue |
DanGibbons | 6:5e8e2645cd93 | 300 | if(isRobot == true) { |
DanGibbons | 6:5e8e2645cd93 | 301 | |
DanGibbons | 6:5e8e2645cd93 | 302 | for (int i = 0; i < WS2812_BUF; i++) { |
DanGibbons | 6:5e8e2645cd93 | 303 | if (mainArray[line_num][i] == 0) { |
DanGibbons | 6:5e8e2645cd93 | 304 | robotScorePx.Set(i,OFF); |
DanGibbons | 6:5e8e2645cd93 | 305 | } |
DanGibbons | 6:5e8e2645cd93 | 306 | |
DanGibbons | 6:5e8e2645cd93 | 307 | if (mainArray[line_num][i] == 1) { |
DanGibbons | 6:5e8e2645cd93 | 308 | robotScorePx.Set(i,BLUE); |
DanGibbons | 6:5e8e2645cd93 | 309 | } |
DanGibbons | 5:2d439ccefc7d | 310 | } |
DanGibbons | 6:5e8e2645cd93 | 311 | } else { |
DanGibbons | 6:5e8e2645cd93 | 312 | for (int i = 0; i < WS2812_BUF; i++) { |
DanGibbons | 6:5e8e2645cd93 | 313 | if (mainArray[line_num][i] == 0) { |
DanGibbons | 6:5e8e2645cd93 | 314 | playerScorePx.Set(i,OFF); |
DanGibbons | 6:5e8e2645cd93 | 315 | } |
DanGibbons | 5:2d439ccefc7d | 316 | |
DanGibbons | 6:5e8e2645cd93 | 317 | if (mainArray[line_num][i] == 1) { |
DanGibbons | 6:5e8e2645cd93 | 318 | playerScorePx.Set(i,BLUE); |
DanGibbons | 6:5e8e2645cd93 | 319 | } |
DanGibbons | 5:2d439ccefc7d | 320 | } |
DanGibbons | 5:2d439ccefc7d | 321 | } |
DanGibbons | 5:2d439ccefc7d | 322 | |
DanGibbons | 6:5e8e2645cd93 | 323 | } |
DanGibbons | 6:5e8e2645cd93 | 324 | } |
benswindell | 0:f2b739e846ae | 325 | |
DanGibbons | 6:5e8e2645cd93 | 326 | // Handle behaviour for the goal scored event |
benswindell | 0:f2b739e846ae | 327 | void HandleGoal(bool hasRobotScored) |
benswindell | 0:f2b739e846ae | 328 | { |
DanGibbons | 4:2e80bd814f57 | 329 | GoalAnimation(hasRobotScored); |
benswindell | 1:24bc4d8ed2ae | 330 | |
benswindell | 1:24bc4d8ed2ae | 331 | // If either player reaches the score limit, then call HandleWin(). If not, then turn goal LEDs off |
benswindell | 1:24bc4d8ed2ae | 332 | if(robotScore == scoreLimit || playerScore == scoreLimit) { |
benswindell | 1:24bc4d8ed2ae | 333 | HandleWin(); |
samuelmoss | 2:ff409472bc08 | 334 | } |
benswindell | 1:24bc4d8ed2ae | 335 | } |
benswindell | 1:24bc4d8ed2ae | 336 | |
benswindell | 1:24bc4d8ed2ae | 337 | // Handle behaviour when either the player or robot has won a game. |
benswindell | 1:24bc4d8ed2ae | 338 | void HandleWin() |
benswindell | 1:24bc4d8ed2ae | 339 | { |
benswindell | 1:24bc4d8ed2ae | 340 | // Initalise variable as true |
benswindell | 1:24bc4d8ed2ae | 341 | bool isRobotWinner = true; |
benswindell | 1:24bc4d8ed2ae | 342 | |
benswindell | 1:24bc4d8ed2ae | 343 | // Decide if the robot is the winner. If not, then change isRobotWinner to false |
benswindell | 1:24bc4d8ed2ae | 344 | if(playerScore == scoreLimit) { |
DanGibbons | 4:2e80bd814f57 | 345 | |
benswindell | 1:24bc4d8ed2ae | 346 | isRobotWinner = false; |
benswindell | 1:24bc4d8ed2ae | 347 | pc.printf("Player won!"); |
DanGibbons | 4:2e80bd814f57 | 348 | WinAnimation(isRobotWinner); |
benswindell | 1:24bc4d8ed2ae | 349 | |
benswindell | 1:24bc4d8ed2ae | 350 | } else { |
benswindell | 1:24bc4d8ed2ae | 351 | pc.printf("Robot won!"); |
DanGibbons | 4:2e80bd814f57 | 352 | WinAnimation(isRobotWinner); |
benswindell | 1:24bc4d8ed2ae | 353 | |
benswindell | 1:24bc4d8ed2ae | 354 | } |
benswindell | 1:24bc4d8ed2ae | 355 | |
benswindell | 1:24bc4d8ed2ae | 356 | // Reset scores then write to LEDs |
benswindell | 1:24bc4d8ed2ae | 357 | robotScore = 0; |
benswindell | 1:24bc4d8ed2ae | 358 | playerScore = 0; |
DanGibbons | 5:2d439ccefc7d | 359 | |
DanGibbons | 6:5e8e2645cd93 | 360 | CircleAnimation(true,true,true,true,2); |
DanGibbons | 6:5e8e2645cd93 | 361 | DrainAnimation(true,true,robotScore,true,true,playerScore); |
DanGibbons | 5:2d439ccefc7d | 362 | |
DanGibbons | 6:5e8e2645cd93 | 363 | wait(2); |
DanGibbons | 6:5e8e2645cd93 | 364 | |
DanGibbons | 6:5e8e2645cd93 | 365 | ZeroInAnimation(true,false,true,false); |
benswindell | 0:f2b739e846ae | 366 | } |
benswindell | 0:f2b739e846ae | 367 | |
DanGibbons | 5:2d439ccefc7d | 368 | // animation for when a goal is scored |
DanGibbons | 4:2e80bd814f57 | 369 | void GoalAnimation(bool hasRobotScored) |
benswindell | 0:f2b739e846ae | 370 | { |
DanGibbons | 4:2e80bd814f57 | 371 | if(hasRobotScored == true) { |
DanGibbons | 6:5e8e2645cd93 | 372 | |
DanGibbons | 6:5e8e2645cd93 | 373 | switch (robotScore) { |
DanGibbons | 6:5e8e2645cd93 | 374 | case 0: |
DanGibbons | 6:5e8e2645cd93 | 375 | ZeroOutAnimation(true,false,false,false); |
DanGibbons | 6:5e8e2645cd93 | 376 | break; |
DanGibbons | 6:5e8e2645cd93 | 377 | case 1: |
DanGibbons | 6:5e8e2645cd93 | 378 | OneOutAnimation(true,false,false,false); |
DanGibbons | 6:5e8e2645cd93 | 379 | break; |
DanGibbons | 6:5e8e2645cd93 | 380 | case 2: |
DanGibbons | 6:5e8e2645cd93 | 381 | TwoOutAnimation(true,false,false,false); |
DanGibbons | 6:5e8e2645cd93 | 382 | break; |
DanGibbons | 6:5e8e2645cd93 | 383 | case 3: |
DanGibbons | 6:5e8e2645cd93 | 384 | ThreeOutAnimation(true,false,false,false); |
DanGibbons | 6:5e8e2645cd93 | 385 | default : |
DanGibbons | 6:5e8e2645cd93 | 386 | break; |
DanGibbons | 6:5e8e2645cd93 | 387 | } |
DanGibbons | 6:5e8e2645cd93 | 388 | |
DanGibbons | 4:2e80bd814f57 | 389 | robotScore++; |
DanGibbons | 5:2d439ccefc7d | 390 | wait_ms(250); |
DanGibbons | 6:5e8e2645cd93 | 391 | |
DanGibbons | 6:5e8e2645cd93 | 392 | switch (robotScore) { |
DanGibbons | 6:5e8e2645cd93 | 393 | case 0: |
DanGibbons | 6:5e8e2645cd93 | 394 | ZeroInAnimation(true,false,false,false); |
DanGibbons | 6:5e8e2645cd93 | 395 | break; |
DanGibbons | 6:5e8e2645cd93 | 396 | case 1: |
DanGibbons | 6:5e8e2645cd93 | 397 | OneInAnimation(true,false,false,false); |
DanGibbons | 6:5e8e2645cd93 | 398 | break; |
DanGibbons | 6:5e8e2645cd93 | 399 | case 2: |
DanGibbons | 6:5e8e2645cd93 | 400 | TwoInAnimation(true,false,false,false); |
DanGibbons | 6:5e8e2645cd93 | 401 | break; |
DanGibbons | 6:5e8e2645cd93 | 402 | case 3: |
DanGibbons | 6:5e8e2645cd93 | 403 | ThreeInAnimation(true,true,false,false); |
DanGibbons | 6:5e8e2645cd93 | 404 | default : |
DanGibbons | 6:5e8e2645cd93 | 405 | break; |
DanGibbons | 6:5e8e2645cd93 | 406 | } |
DanGibbons | 4:2e80bd814f57 | 407 | |
DanGibbons | 4:2e80bd814f57 | 408 | } else { |
DanGibbons | 6:5e8e2645cd93 | 409 | |
DanGibbons | 6:5e8e2645cd93 | 410 | switch (playerScore) { |
DanGibbons | 6:5e8e2645cd93 | 411 | case 0: |
DanGibbons | 6:5e8e2645cd93 | 412 | ZeroOutAnimation(false,false,true,false); |
DanGibbons | 6:5e8e2645cd93 | 413 | break; |
DanGibbons | 6:5e8e2645cd93 | 414 | case 1: |
DanGibbons | 6:5e8e2645cd93 | 415 | OneOutAnimation(false,false,true,false); |
DanGibbons | 6:5e8e2645cd93 | 416 | break; |
DanGibbons | 6:5e8e2645cd93 | 417 | case 2: |
DanGibbons | 6:5e8e2645cd93 | 418 | TwoOutAnimation(false,false,true,false); |
DanGibbons | 6:5e8e2645cd93 | 419 | break; |
DanGibbons | 6:5e8e2645cd93 | 420 | case 3: |
DanGibbons | 6:5e8e2645cd93 | 421 | ThreeOutAnimation(false,false ,true,false); |
DanGibbons | 6:5e8e2645cd93 | 422 | default : |
DanGibbons | 6:5e8e2645cd93 | 423 | break; |
DanGibbons | 6:5e8e2645cd93 | 424 | } |
DanGibbons | 4:2e80bd814f57 | 425 | playerScore++; |
DanGibbons | 5:2d439ccefc7d | 426 | wait_ms(250); |
DanGibbons | 6:5e8e2645cd93 | 427 | |
DanGibbons | 6:5e8e2645cd93 | 428 | switch (playerScore) { |
DanGibbons | 6:5e8e2645cd93 | 429 | case 0: |
DanGibbons | 6:5e8e2645cd93 | 430 | ZeroInAnimation(false,false,true,false); |
DanGibbons | 6:5e8e2645cd93 | 431 | break; |
DanGibbons | 6:5e8e2645cd93 | 432 | case 1: |
DanGibbons | 6:5e8e2645cd93 | 433 | OneInAnimation(false,false,true,false); |
DanGibbons | 6:5e8e2645cd93 | 434 | break; |
DanGibbons | 6:5e8e2645cd93 | 435 | case 2: |
DanGibbons | 6:5e8e2645cd93 | 436 | TwoInAnimation(false,false,true,false); |
DanGibbons | 6:5e8e2645cd93 | 437 | break; |
DanGibbons | 6:5e8e2645cd93 | 438 | case 3: |
DanGibbons | 6:5e8e2645cd93 | 439 | ThreeInAnimation(false,false,true,true); |
DanGibbons | 6:5e8e2645cd93 | 440 | default : |
DanGibbons | 6:5e8e2645cd93 | 441 | break; |
DanGibbons | 6:5e8e2645cd93 | 442 | } |
DanGibbons | 4:2e80bd814f57 | 443 | } |
DanGibbons | 4:2e80bd814f57 | 444 | |
DanGibbons | 4:2e80bd814f57 | 445 | } |
benswindell | 0:f2b739e846ae | 446 | |
DanGibbons | 5:2d439ccefc7d | 447 | // animation when player or robot win the game |
DanGibbons | 4:2e80bd814f57 | 448 | void WinAnimation(bool isRobotWinner) |
DanGibbons | 4:2e80bd814f57 | 449 | { |
DanGibbons | 4:2e80bd814f57 | 450 | if(isRobotWinner == false) { |
DanGibbons | 4:2e80bd814f57 | 451 | |
DanGibbons | 6:5e8e2645cd93 | 452 | // dim brightness of the robot score because it lost |
DanGibbons | 6:5e8e2645cd93 | 453 | robotScoreLED.setII(0x20); |
DanGibbons | 6:5e8e2645cd93 | 454 | robotScoreLED.useII(WS2812::GLOBAL); |
DanGibbons | 6:5e8e2645cd93 | 455 | robotScoreLED.write(robotScorePx.getBuf()); // rewrite buffer to change brightness |
DanGibbons | 6:5e8e2645cd93 | 456 | |
DanGibbons | 6:5e8e2645cd93 | 457 | for (int i = 0; i < 80; i++) { // flash player score with changing random colours |
DanGibbons | 6:5e8e2645cd93 | 458 | WritePxAnimation(playerScore,false,true); |
DanGibbons | 5:2d439ccefc7d | 459 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 460 | wait_ms(50); |
DanGibbons | 5:2d439ccefc7d | 461 | } |
DanGibbons | 5:2d439ccefc7d | 462 | |
DanGibbons | 6:5e8e2645cd93 | 463 | DrainAnimation(true,false,robotScore,true,true,playerScore); // drain both scores away with the player score in random colours |
DanGibbons | 6:5e8e2645cd93 | 464 | |
DanGibbons | 6:5e8e2645cd93 | 465 | // reset robot score brightness |
DanGibbons | 6:5e8e2645cd93 | 466 | robotScoreLED.setII(0xB0); |
DanGibbons | 6:5e8e2645cd93 | 467 | robotScoreLED.useII(WS2812::GLOBAL); |
DanGibbons | 5:2d439ccefc7d | 468 | |
DanGibbons | 4:2e80bd814f57 | 469 | } else { |
DanGibbons | 4:2e80bd814f57 | 470 | |
DanGibbons | 6:5e8e2645cd93 | 471 | // dim brightness of the player score because they lost |
DanGibbons | 6:5e8e2645cd93 | 472 | playerScoreLED.setII(0x20); |
DanGibbons | 6:5e8e2645cd93 | 473 | playerScoreLED.useII(WS2812::GLOBAL); |
DanGibbons | 6:5e8e2645cd93 | 474 | playerScoreLED.write(playerScorePx.getBuf()); // rewrite buffer to change brightness |
DanGibbons | 6:5e8e2645cd93 | 475 | |
DanGibbons | 6:5e8e2645cd93 | 476 | for (int i = 0; i < 80; i++) { // flash robot score with changing random colours |
DanGibbons | 6:5e8e2645cd93 | 477 | WritePxAnimation(robotScore,true,true); |
DanGibbons | 5:2d439ccefc7d | 478 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 479 | wait_ms(50); |
DanGibbons | 5:2d439ccefc7d | 480 | } |
DanGibbons | 4:2e80bd814f57 | 481 | |
DanGibbons | 6:5e8e2645cd93 | 482 | DrainAnimation(true,true,robotScore,true,false,playerScore); // drain both scores away with the robot score in random colours |
DanGibbons | 6:5e8e2645cd93 | 483 | |
DanGibbons | 6:5e8e2645cd93 | 484 | // reset player score brightness |
DanGibbons | 6:5e8e2645cd93 | 485 | playerScoreLED.setII(0xB0); |
DanGibbons | 6:5e8e2645cd93 | 486 | playerScoreLED.useII(WS2812::GLOBAL); |
benswindell | 0:f2b739e846ae | 487 | } |
DanGibbons | 4:2e80bd814f57 | 488 | |
DanGibbons | 5:2d439ccefc7d | 489 | wait(3); |
DanGibbons | 5:2d439ccefc7d | 490 | |
DanGibbons | 4:2e80bd814f57 | 491 | } |
DanGibbons | 4:2e80bd814f57 | 492 | |
DanGibbons | 6:5e8e2645cd93 | 493 | |
DanGibbons | 6:5e8e2645cd93 | 494 | void CircleAnimation(bool robot, bool robotColour, bool player, bool playerColour, int numberOfRepititions) |
DanGibbons | 4:2e80bd814f57 | 495 | { |
DanGibbons | 6:5e8e2645cd93 | 496 | memset(mainArray, 0, sizeof mainArray); |
DanGibbons | 6:5e8e2645cd93 | 497 | |
DanGibbons | 6:5e8e2645cd93 | 498 | for (int loops = 0; loops < numberOfRepititions; loops++) { |
DanGibbons | 6:5e8e2645cd93 | 499 | |
DanGibbons | 6:5e8e2645cd93 | 500 | for (int i = 0; i < 115; i++) { // loop to set LEDs around the circle from start of segment A to end of Segment F |
DanGibbons | 5:2d439ccefc7d | 501 | |
DanGibbons | 6:5e8e2645cd93 | 502 | if ( i < 104) { |
DanGibbons | 6:5e8e2645cd93 | 503 | mainArray[0][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 504 | } |
DanGibbons | 6:5e8e2645cd93 | 505 | |
DanGibbons | 6:5e8e2645cd93 | 506 | for (int j = 0; j < i-10; j++) { // Loop to clear previously set LEDs so that the chain that animates round the display is 9 LEDs long |
DanGibbons | 6:5e8e2645cd93 | 507 | mainArray[0][j] = 0; |
DanGibbons | 6:5e8e2645cd93 | 508 | } |
DanGibbons | 6:5e8e2645cd93 | 509 | |
DanGibbons | 6:5e8e2645cd93 | 510 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 511 | |
DanGibbons | 6:5e8e2645cd93 | 512 | if (player == true) { |
DanGibbons | 6:5e8e2645cd93 | 513 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 5:2d439ccefc7d | 514 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 5:2d439ccefc7d | 515 | } |
DanGibbons | 6:5e8e2645cd93 | 516 | if (robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 517 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 518 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 519 | } |
DanGibbons | 6:5e8e2645cd93 | 520 | } |
DanGibbons | 6:5e8e2645cd93 | 521 | |
DanGibbons | 6:5e8e2645cd93 | 522 | } |
DanGibbons | 6:5e8e2645cd93 | 523 | |
DanGibbons | 6:5e8e2645cd93 | 524 | for (int i = 0; i < 104; i++) { |
DanGibbons | 6:5e8e2645cd93 | 525 | |
DanGibbons | 6:5e8e2645cd93 | 526 | mainArray[0][i] = 1; |
DanGibbons | 4:2e80bd814f57 | 527 | |
DanGibbons | 6:5e8e2645cd93 | 528 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 529 | |
DanGibbons | 6:5e8e2645cd93 | 530 | if (player == true) { |
DanGibbons | 6:5e8e2645cd93 | 531 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 532 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 5:2d439ccefc7d | 533 | } |
DanGibbons | 6:5e8e2645cd93 | 534 | if (robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 535 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 536 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 537 | } |
DanGibbons | 6:5e8e2645cd93 | 538 | |
DanGibbons | 5:2d439ccefc7d | 539 | } |
DanGibbons | 5:2d439ccefc7d | 540 | |
DanGibbons | 5:2d439ccefc7d | 541 | SetNumberPatterns(); |
DanGibbons | 5:2d439ccefc7d | 542 | |
DanGibbons | 5:2d439ccefc7d | 543 | } |
DanGibbons | 5:2d439ccefc7d | 544 | |
DanGibbons | 4:2e80bd814f57 | 545 | |
DanGibbons | 5:2d439ccefc7d | 546 | |
DanGibbons | 5:2d439ccefc7d | 547 | // animation that drains the display from the top segment A to the bottom segment D |
DanGibbons | 5:2d439ccefc7d | 548 | void DrainAnimation(bool robot, bool robotColour, int robotScore, bool player, bool playerColour, int playerScore) |
DanGibbons | 5:2d439ccefc7d | 549 | { |
DanGibbons | 6:5e8e2645cd93 | 550 | for (int i = 0; i < 10; i++) { // A |
DanGibbons | 6:5e8e2645cd93 | 551 | mainArray[robotScore][9+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 552 | mainArray[robotScore][9-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 553 | mainArray[playerScore][9+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 554 | mainArray[playerScore][9-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 555 | wait_ms(30); |
DanGibbons | 6:5e8e2645cd93 | 556 | if (player == true){ |
DanGibbons | 6:5e8e2645cd93 | 557 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 5:2d439ccefc7d | 558 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 559 | } |
DanGibbons | 6:5e8e2645cd93 | 560 | if (robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 561 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 562 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 5:2d439ccefc7d | 563 | } |
DanGibbons | 6:5e8e2645cd93 | 564 | } |
DanGibbons | 6:5e8e2645cd93 | 565 | for (int i = 0; i < 18; i++) { // B and F |
DanGibbons | 6:5e8e2645cd93 | 566 | mainArray[robotScore][18+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 567 | mainArray[robotScore][103-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 568 | mainArray[playerScore][18+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 569 | mainArray[playerScore][103-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 570 | wait_ms(30); |
DanGibbons | 6:5e8e2645cd93 | 571 | if (player == true){ |
DanGibbons | 6:5e8e2645cd93 | 572 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 5:2d439ccefc7d | 573 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 574 | } |
DanGibbons | 6:5e8e2645cd93 | 575 | if (robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 576 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 577 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 578 | } |
DanGibbons | 6:5e8e2645cd93 | 579 | } |
DanGibbons | 6:5e8e2645cd93 | 580 | if (robotScore != 0 | playerScore != 0) { // endgame - at least one score is three |
DanGibbons | 6:5e8e2645cd93 | 581 | |
DanGibbons | 6:5e8e2645cd93 | 582 | for (int i = 0; i < 18; i++) { // G |
DanGibbons | 6:5e8e2645cd93 | 583 | mainArray[robotScore][104+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 584 | mainArray[playerScore][104+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 585 | if (player == true) { |
DanGibbons | 6:5e8e2645cd93 | 586 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 587 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 588 | } |
DanGibbons | 6:5e8e2645cd93 | 589 | if (robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 590 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 591 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 592 | } |
DanGibbons | 6:5e8e2645cd93 | 593 | } |
DanGibbons | 6:5e8e2645cd93 | 594 | } else { // start of game - both scores are 0 |
DanGibbons | 5:2d439ccefc7d | 595 | for (int i = 0; i < 18; i++) { // G |
DanGibbons | 5:2d439ccefc7d | 596 | mainArray[robotScore][104+i] = 0; |
DanGibbons | 5:2d439ccefc7d | 597 | mainArray[playerScore][104+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 598 | } |
DanGibbons | 6:5e8e2645cd93 | 599 | if (player == true) { |
DanGibbons | 6:5e8e2645cd93 | 600 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 601 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 602 | } |
DanGibbons | 6:5e8e2645cd93 | 603 | if (robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 604 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 605 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 606 | } |
DanGibbons | 6:5e8e2645cd93 | 607 | } |
DanGibbons | 6:5e8e2645cd93 | 608 | |
DanGibbons | 6:5e8e2645cd93 | 609 | for (int i = 0; i < 18; i++) { // C and E |
DanGibbons | 6:5e8e2645cd93 | 610 | mainArray[robotScore][35+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 611 | mainArray[robotScore][86-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 612 | mainArray[playerScore][35+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 613 | mainArray[playerScore][86-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 614 | wait_ms(30); |
DanGibbons | 6:5e8e2645cd93 | 615 | if (player == true){ |
DanGibbons | 6:5e8e2645cd93 | 616 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 617 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 618 | } |
DanGibbons | 6:5e8e2645cd93 | 619 | if (robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 620 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 5:2d439ccefc7d | 621 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 622 | } |
DanGibbons | 6:5e8e2645cd93 | 623 | } |
DanGibbons | 6:5e8e2645cd93 | 624 | for (int i = 0; i < 10; i++) { // D |
DanGibbons | 6:5e8e2645cd93 | 625 | mainArray[robotScore][52+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 626 | mainArray[robotScore][70-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 627 | mainArray[playerScore][52+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 628 | mainArray[playerScore][70-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 629 | wait_ms(30); |
DanGibbons | 6:5e8e2645cd93 | 630 | if (player == true){ |
DanGibbons | 6:5e8e2645cd93 | 631 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 632 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 633 | } |
DanGibbons | 6:5e8e2645cd93 | 634 | if (robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 635 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 636 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 637 | } |
DanGibbons | 6:5e8e2645cd93 | 638 | } |
DanGibbons | 6:5e8e2645cd93 | 639 | |
DanGibbons | 6:5e8e2645cd93 | 640 | |
DanGibbons | 6:5e8e2645cd93 | 641 | SetNumberPatterns(); |
DanGibbons | 6:5e8e2645cd93 | 642 | |
DanGibbons | 6:5e8e2645cd93 | 643 | } |
DanGibbons | 6:5e8e2645cd93 | 644 | |
DanGibbons | 6:5e8e2645cd93 | 645 | void ZeroInAnimation(bool robot, bool robotColour, bool player, bool playerColour) |
DanGibbons | 6:5e8e2645cd93 | 646 | { |
DanGibbons | 6:5e8e2645cd93 | 647 | memset(mainArray, 0, sizeof mainArray); |
DanGibbons | 6:5e8e2645cd93 | 648 | |
DanGibbons | 6:5e8e2645cd93 | 649 | if (player == true && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 650 | |
DanGibbons | 6:5e8e2645cd93 | 651 | for (int i = 0; i < 10; i++) { // A |
DanGibbons | 6:5e8e2645cd93 | 652 | mainArray[0][9+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 653 | mainArray[0][9-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 654 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 655 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 656 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 657 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 658 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 659 | } |
DanGibbons | 6:5e8e2645cd93 | 660 | for (int i = 0; i < 18; i++) { // B and F |
DanGibbons | 6:5e8e2645cd93 | 661 | mainArray[0][18+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 662 | mainArray[0][103-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 663 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 664 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 665 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 666 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 667 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 668 | } |
DanGibbons | 5:2d439ccefc7d | 669 | for (int i = 0; i < 18; i++) { // C and E |
DanGibbons | 6:5e8e2645cd93 | 670 | mainArray[0][35+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 671 | mainArray[0][86-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 672 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 673 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 5:2d439ccefc7d | 674 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 675 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 5:2d439ccefc7d | 676 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 677 | } |
DanGibbons | 5:2d439ccefc7d | 678 | for (int i = 0; i < 10; i++) { // D |
DanGibbons | 6:5e8e2645cd93 | 679 | mainArray[0][52+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 680 | mainArray[0][70-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 681 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 682 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 683 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 684 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 685 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 686 | } |
DanGibbons | 6:5e8e2645cd93 | 687 | |
DanGibbons | 6:5e8e2645cd93 | 688 | } |
DanGibbons | 6:5e8e2645cd93 | 689 | |
DanGibbons | 6:5e8e2645cd93 | 690 | if (player == true && robot == false) { |
DanGibbons | 6:5e8e2645cd93 | 691 | |
DanGibbons | 6:5e8e2645cd93 | 692 | for (int i = 0; i < 10; i++) { // A |
DanGibbons | 6:5e8e2645cd93 | 693 | mainArray[0][9+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 694 | mainArray[0][9-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 695 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 696 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 697 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 698 | } |
DanGibbons | 6:5e8e2645cd93 | 699 | for (int i = 0; i < 18; i++) { // B and F |
DanGibbons | 6:5e8e2645cd93 | 700 | mainArray[0][18+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 701 | mainArray[0][103-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 702 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 703 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 704 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 705 | } |
DanGibbons | 6:5e8e2645cd93 | 706 | for (int i = 0; i < 18; i++) { // G |
DanGibbons | 6:5e8e2645cd93 | 707 | mainArray[0][104+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 708 | } |
DanGibbons | 6:5e8e2645cd93 | 709 | |
DanGibbons | 6:5e8e2645cd93 | 710 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 711 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 712 | |
DanGibbons | 6:5e8e2645cd93 | 713 | for (int i = 0; i < 18; i++) { // C and E |
DanGibbons | 6:5e8e2645cd93 | 714 | mainArray[0][35+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 715 | mainArray[0][86-i] = 1; |
DanGibbons | 5:2d439ccefc7d | 716 | wait_ms(30); |
DanGibbons | 6:5e8e2645cd93 | 717 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 718 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 719 | } |
DanGibbons | 6:5e8e2645cd93 | 720 | for (int i = 0; i < 10; i++) { // D |
DanGibbons | 6:5e8e2645cd93 | 721 | mainArray[0][52+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 722 | mainArray[0][70-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 723 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 724 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 5:2d439ccefc7d | 725 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 726 | } |
DanGibbons | 6:5e8e2645cd93 | 727 | |
DanGibbons | 6:5e8e2645cd93 | 728 | } |
DanGibbons | 6:5e8e2645cd93 | 729 | |
DanGibbons | 6:5e8e2645cd93 | 730 | if (player == false && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 731 | |
DanGibbons | 6:5e8e2645cd93 | 732 | for (int i = 0; i < 10; i++) { // A |
DanGibbons | 6:5e8e2645cd93 | 733 | mainArray[0][9+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 734 | mainArray[0][9-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 735 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 736 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 737 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 738 | } |
DanGibbons | 6:5e8e2645cd93 | 739 | for (int i = 0; i < 18; i++) { // B and F |
DanGibbons | 6:5e8e2645cd93 | 740 | mainArray[0][18+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 741 | mainArray[0][103-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 742 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 743 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 5:2d439ccefc7d | 744 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 745 | } |
DanGibbons | 6:5e8e2645cd93 | 746 | for (int i = 0; i < 18; i++) { // G |
DanGibbons | 6:5e8e2645cd93 | 747 | mainArray[0][104+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 748 | } |
DanGibbons | 6:5e8e2645cd93 | 749 | |
DanGibbons | 6:5e8e2645cd93 | 750 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 751 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 752 | |
DanGibbons | 6:5e8e2645cd93 | 753 | for (int i = 0; i < 18; i++) { // C and E |
DanGibbons | 6:5e8e2645cd93 | 754 | mainArray[0][35+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 755 | mainArray[0][86-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 756 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 757 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 758 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 759 | } |
DanGibbons | 6:5e8e2645cd93 | 760 | for (int i = 0; i < 10; i++) { // D |
DanGibbons | 6:5e8e2645cd93 | 761 | mainArray[0][52+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 762 | mainArray[0][70-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 763 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 764 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 765 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 766 | } |
DanGibbons | 6:5e8e2645cd93 | 767 | |
DanGibbons | 6:5e8e2645cd93 | 768 | } |
DanGibbons | 6:5e8e2645cd93 | 769 | |
DanGibbons | 6:5e8e2645cd93 | 770 | SetNumberPatterns(); |
DanGibbons | 5:2d439ccefc7d | 771 | |
DanGibbons | 6:5e8e2645cd93 | 772 | |
DanGibbons | 6:5e8e2645cd93 | 773 | } |
DanGibbons | 6:5e8e2645cd93 | 774 | |
DanGibbons | 6:5e8e2645cd93 | 775 | void ZeroOutAnimation(bool robot, bool robotColour, bool player, bool playerColour) |
DanGibbons | 6:5e8e2645cd93 | 776 | { |
DanGibbons | 6:5e8e2645cd93 | 777 | if (player == true && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 778 | |
DanGibbons | 5:2d439ccefc7d | 779 | for (int i = 0; i < 10; i++) { // A |
DanGibbons | 6:5e8e2645cd93 | 780 | mainArray[0][9+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 781 | mainArray[0][9-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 782 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 783 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 784 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 785 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 786 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 787 | } |
DanGibbons | 6:5e8e2645cd93 | 788 | for (int i = 0; i < 18; i++) { // B and F |
DanGibbons | 6:5e8e2645cd93 | 789 | mainArray[0][18+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 790 | mainArray[0][103-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 791 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 792 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 793 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 794 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 795 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 796 | } |
DanGibbons | 6:5e8e2645cd93 | 797 | for (int i = 0; i < 18; i++) { // G |
DanGibbons | 6:5e8e2645cd93 | 798 | mainArray[0][104+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 799 | } |
DanGibbons | 6:5e8e2645cd93 | 800 | |
DanGibbons | 6:5e8e2645cd93 | 801 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 802 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 803 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 804 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 805 | |
DanGibbons | 6:5e8e2645cd93 | 806 | for (int i = 0; i < 18; i++) { // C and E |
DanGibbons | 6:5e8e2645cd93 | 807 | mainArray[0][35+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 808 | mainArray[0][86-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 809 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 810 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 811 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 812 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 813 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 814 | } |
DanGibbons | 6:5e8e2645cd93 | 815 | for (int i = 0; i < 10; i++) { // D |
DanGibbons | 6:5e8e2645cd93 | 816 | mainArray[0][52+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 817 | mainArray[0][70-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 818 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 819 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 820 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 821 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 822 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 823 | } |
DanGibbons | 6:5e8e2645cd93 | 824 | |
DanGibbons | 6:5e8e2645cd93 | 825 | } |
DanGibbons | 6:5e8e2645cd93 | 826 | |
DanGibbons | 6:5e8e2645cd93 | 827 | if (player == true && robot == false) { |
DanGibbons | 6:5e8e2645cd93 | 828 | |
DanGibbons | 6:5e8e2645cd93 | 829 | for (int i = 0; i < 10; i++) { // A |
DanGibbons | 6:5e8e2645cd93 | 830 | mainArray[0][9+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 831 | mainArray[0][9-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 832 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 833 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 5:2d439ccefc7d | 834 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 5:2d439ccefc7d | 835 | } |
DanGibbons | 5:2d439ccefc7d | 836 | for (int i = 0; i < 18; i++) { // B and F |
DanGibbons | 6:5e8e2645cd93 | 837 | mainArray[0][18+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 838 | mainArray[0][103-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 839 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 840 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 5:2d439ccefc7d | 841 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 842 | } |
DanGibbons | 5:2d439ccefc7d | 843 | for (int i = 0; i < 18; i++) { // G |
DanGibbons | 6:5e8e2645cd93 | 844 | mainArray[0][104+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 845 | } |
DanGibbons | 6:5e8e2645cd93 | 846 | |
DanGibbons | 6:5e8e2645cd93 | 847 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 848 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 849 | |
DanGibbons | 5:2d439ccefc7d | 850 | for (int i = 0; i < 18; i++) { // C and E |
DanGibbons | 6:5e8e2645cd93 | 851 | mainArray[0][35+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 852 | mainArray[0][86-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 853 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 854 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 5:2d439ccefc7d | 855 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 856 | } |
DanGibbons | 5:2d439ccefc7d | 857 | for (int i = 0; i < 10; i++) { // D |
DanGibbons | 6:5e8e2645cd93 | 858 | mainArray[0][52+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 859 | mainArray[0][70-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 860 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 861 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 5:2d439ccefc7d | 862 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 863 | } |
DanGibbons | 6:5e8e2645cd93 | 864 | |
DanGibbons | 6:5e8e2645cd93 | 865 | } |
DanGibbons | 6:5e8e2645cd93 | 866 | |
DanGibbons | 5:2d439ccefc7d | 867 | if (player == false && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 868 | |
DanGibbons | 5:2d439ccefc7d | 869 | for (int i = 0; i < 10; i++) { // A |
DanGibbons | 6:5e8e2645cd93 | 870 | mainArray[0][9+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 871 | mainArray[0][9-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 872 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 873 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 5:2d439ccefc7d | 874 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 5:2d439ccefc7d | 875 | } |
DanGibbons | 5:2d439ccefc7d | 876 | for (int i = 0; i < 18; i++) { // B and F |
DanGibbons | 6:5e8e2645cd93 | 877 | mainArray[0][18+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 878 | mainArray[0][103-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 879 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 880 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 5:2d439ccefc7d | 881 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 882 | } |
DanGibbons | 5:2d439ccefc7d | 883 | for (int i = 0; i < 18; i++) { // G |
DanGibbons | 6:5e8e2645cd93 | 884 | mainArray[0][104+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 885 | } |
DanGibbons | 6:5e8e2645cd93 | 886 | |
DanGibbons | 6:5e8e2645cd93 | 887 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 888 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 889 | |
DanGibbons | 5:2d439ccefc7d | 890 | for (int i = 0; i < 18; i++) { // C and E |
DanGibbons | 6:5e8e2645cd93 | 891 | mainArray[0][35+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 892 | mainArray[0][86-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 893 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 894 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 5:2d439ccefc7d | 895 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 896 | } |
DanGibbons | 5:2d439ccefc7d | 897 | for (int i = 0; i < 10; i++) { // D |
DanGibbons | 6:5e8e2645cd93 | 898 | mainArray[0][52+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 899 | mainArray[0][70-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 900 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 901 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 902 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 903 | } |
DanGibbons | 6:5e8e2645cd93 | 904 | |
DanGibbons | 6:5e8e2645cd93 | 905 | } |
DanGibbons | 6:5e8e2645cd93 | 906 | |
DanGibbons | 6:5e8e2645cd93 | 907 | SetNumberPatterns(); |
DanGibbons | 6:5e8e2645cd93 | 908 | |
DanGibbons | 6:5e8e2645cd93 | 909 | |
DanGibbons | 6:5e8e2645cd93 | 910 | } |
DanGibbons | 6:5e8e2645cd93 | 911 | |
DanGibbons | 6:5e8e2645cd93 | 912 | void OneInAnimation(bool robot, bool robotColour,bool player, bool playerColour) |
DanGibbons | 6:5e8e2645cd93 | 913 | { |
DanGibbons | 6:5e8e2645cd93 | 914 | memset(mainArray, 0, sizeof mainArray); |
DanGibbons | 6:5e8e2645cd93 | 915 | |
DanGibbons | 6:5e8e2645cd93 | 916 | if (player == true && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 917 | |
DanGibbons | 6:5e8e2645cd93 | 918 | for (int i = 51; i > 17; i--) { |
DanGibbons | 6:5e8e2645cd93 | 919 | mainArray[1][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 920 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 921 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 922 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 923 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 924 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 925 | } |
DanGibbons | 6:5e8e2645cd93 | 926 | |
DanGibbons | 6:5e8e2645cd93 | 927 | } |
DanGibbons | 6:5e8e2645cd93 | 928 | |
DanGibbons | 6:5e8e2645cd93 | 929 | if (player == true && robot == false) { |
DanGibbons | 6:5e8e2645cd93 | 930 | |
DanGibbons | 6:5e8e2645cd93 | 931 | for (int i = 51; i > 17; i--) { |
DanGibbons | 6:5e8e2645cd93 | 932 | mainArray[1][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 933 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 934 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 935 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 936 | } |
DanGibbons | 6:5e8e2645cd93 | 937 | |
DanGibbons | 6:5e8e2645cd93 | 938 | } |
DanGibbons | 6:5e8e2645cd93 | 939 | |
DanGibbons | 6:5e8e2645cd93 | 940 | if (player == false && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 941 | |
DanGibbons | 6:5e8e2645cd93 | 942 | for (int i = 51; i > 17; i--) { // B and F |
DanGibbons | 6:5e8e2645cd93 | 943 | mainArray[1][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 944 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 945 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 946 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 947 | } |
DanGibbons | 6:5e8e2645cd93 | 948 | |
DanGibbons | 6:5e8e2645cd93 | 949 | } |
DanGibbons | 6:5e8e2645cd93 | 950 | |
DanGibbons | 6:5e8e2645cd93 | 951 | SetNumberPatterns(); |
DanGibbons | 6:5e8e2645cd93 | 952 | |
DanGibbons | 6:5e8e2645cd93 | 953 | |
DanGibbons | 6:5e8e2645cd93 | 954 | } |
DanGibbons | 6:5e8e2645cd93 | 955 | |
DanGibbons | 6:5e8e2645cd93 | 956 | void OneOutAnimation(bool robot, bool robotColour,bool player, bool playerColour) |
DanGibbons | 6:5e8e2645cd93 | 957 | { |
DanGibbons | 6:5e8e2645cd93 | 958 | if (player == true && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 959 | |
DanGibbons | 6:5e8e2645cd93 | 960 | for (int i = 18; i < 52; i++) { |
DanGibbons | 6:5e8e2645cd93 | 961 | mainArray[1][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 962 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 963 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 964 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 965 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 5:2d439ccefc7d | 966 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 967 | } |
DanGibbons | 6:5e8e2645cd93 | 968 | |
DanGibbons | 6:5e8e2645cd93 | 969 | } |
DanGibbons | 6:5e8e2645cd93 | 970 | |
DanGibbons | 6:5e8e2645cd93 | 971 | if (player == true && robot == false) { |
DanGibbons | 6:5e8e2645cd93 | 972 | |
DanGibbons | 6:5e8e2645cd93 | 973 | for (int i = 18; i < 52; i++) { |
DanGibbons | 6:5e8e2645cd93 | 974 | mainArray[1][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 975 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 976 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 977 | playerScoreLED.write(playerScorePx.getBuf());; |
DanGibbons | 6:5e8e2645cd93 | 978 | } |
DanGibbons | 6:5e8e2645cd93 | 979 | |
DanGibbons | 6:5e8e2645cd93 | 980 | } |
DanGibbons | 6:5e8e2645cd93 | 981 | |
DanGibbons | 6:5e8e2645cd93 | 982 | if (player == false && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 983 | |
DanGibbons | 6:5e8e2645cd93 | 984 | for (int i = 18; i < 52; i++) { |
DanGibbons | 6:5e8e2645cd93 | 985 | mainArray[1][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 986 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 987 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 988 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 989 | } |
DanGibbons | 6:5e8e2645cd93 | 990 | |
DanGibbons | 6:5e8e2645cd93 | 991 | } |
DanGibbons | 6:5e8e2645cd93 | 992 | |
DanGibbons | 6:5e8e2645cd93 | 993 | SetNumberPatterns(); |
DanGibbons | 6:5e8e2645cd93 | 994 | |
DanGibbons | 6:5e8e2645cd93 | 995 | } |
DanGibbons | 6:5e8e2645cd93 | 996 | |
DanGibbons | 6:5e8e2645cd93 | 997 | void TwoInAnimation(bool robot, bool robotColour,bool player, bool playerColour) |
DanGibbons | 6:5e8e2645cd93 | 998 | { |
DanGibbons | 6:5e8e2645cd93 | 999 | memset(mainArray, 0, sizeof mainArray); |
DanGibbons | 5:2d439ccefc7d | 1000 | |
DanGibbons | 6:5e8e2645cd93 | 1001 | if (player == true && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 1002 | |
DanGibbons | 6:5e8e2645cd93 | 1003 | for (int i = 0; i < 35; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1004 | mainArray[2][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1005 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1006 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1007 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1008 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1009 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1010 | } |
DanGibbons | 6:5e8e2645cd93 | 1011 | for (int i = 121; i > 103; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1012 | mainArray[2][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1013 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1014 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1015 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1016 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1017 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1018 | } |
DanGibbons | 6:5e8e2645cd93 | 1019 | for (int i = 86; i > 51; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1020 | mainArray[2][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1021 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1022 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1023 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1024 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1025 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1026 | } |
DanGibbons | 6:5e8e2645cd93 | 1027 | |
DanGibbons | 6:5e8e2645cd93 | 1028 | } |
DanGibbons | 6:5e8e2645cd93 | 1029 | |
DanGibbons | 6:5e8e2645cd93 | 1030 | if (player == true && robot == false) { |
DanGibbons | 6:5e8e2645cd93 | 1031 | |
DanGibbons | 6:5e8e2645cd93 | 1032 | for (int i = 0; i < 35; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1033 | mainArray[2][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1034 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1035 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1036 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1037 | } |
DanGibbons | 6:5e8e2645cd93 | 1038 | for (int i = 121; i > 103; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1039 | mainArray[2][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1040 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1041 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1042 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1043 | } |
DanGibbons | 6:5e8e2645cd93 | 1044 | for (int i = 86; i > 51; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1045 | mainArray[2][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1046 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1047 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1048 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1049 | } |
DanGibbons | 6:5e8e2645cd93 | 1050 | |
DanGibbons | 6:5e8e2645cd93 | 1051 | } |
DanGibbons | 6:5e8e2645cd93 | 1052 | |
DanGibbons | 6:5e8e2645cd93 | 1053 | if (player == false && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 1054 | |
DanGibbons | 6:5e8e2645cd93 | 1055 | for (int i = 0; i < 35; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1056 | mainArray[2][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1057 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1058 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1059 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1060 | } |
DanGibbons | 6:5e8e2645cd93 | 1061 | for (int i = 121; i > 103; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1062 | mainArray[2][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1063 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1064 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1065 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1066 | } |
DanGibbons | 6:5e8e2645cd93 | 1067 | for (int i = 86; i > 51; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1068 | mainArray[2][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1069 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1070 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1071 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1072 | } |
DanGibbons | 6:5e8e2645cd93 | 1073 | |
DanGibbons | 6:5e8e2645cd93 | 1074 | } |
DanGibbons | 6:5e8e2645cd93 | 1075 | |
DanGibbons | 5:2d439ccefc7d | 1076 | SetNumberPatterns(); |
DanGibbons | 5:2d439ccefc7d | 1077 | |
DanGibbons | 6:5e8e2645cd93 | 1078 | } |
DanGibbons | 6:5e8e2645cd93 | 1079 | |
DanGibbons | 6:5e8e2645cd93 | 1080 | void TwoOutAnimation(bool robot, bool robotColour,bool player, bool playerColour) |
DanGibbons | 6:5e8e2645cd93 | 1081 | { |
DanGibbons | 6:5e8e2645cd93 | 1082 | if (player == true && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 1083 | |
DanGibbons | 6:5e8e2645cd93 | 1084 | for (int i = 0; i < 35; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1085 | mainArray[2][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1086 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1087 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1088 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1089 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1090 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1091 | } |
DanGibbons | 6:5e8e2645cd93 | 1092 | for (int i = 121; i > 103; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1093 | mainArray[2][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1094 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1095 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1096 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1097 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1098 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1099 | } |
DanGibbons | 6:5e8e2645cd93 | 1100 | for (int i = 86; i > 51; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1101 | mainArray[2][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1102 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1103 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1104 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1105 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1106 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1107 | } |
DanGibbons | 6:5e8e2645cd93 | 1108 | |
DanGibbons | 6:5e8e2645cd93 | 1109 | } |
DanGibbons | 6:5e8e2645cd93 | 1110 | |
DanGibbons | 6:5e8e2645cd93 | 1111 | if (player == true && robot == false) { |
DanGibbons | 6:5e8e2645cd93 | 1112 | |
DanGibbons | 6:5e8e2645cd93 | 1113 | for (int i = 0; i < 35; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1114 | mainArray[2][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1115 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1116 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1117 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1118 | } |
DanGibbons | 6:5e8e2645cd93 | 1119 | for (int i = 121; i > 103; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1120 | mainArray[2][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1121 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1122 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1123 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1124 | } |
DanGibbons | 6:5e8e2645cd93 | 1125 | for (int i = 86; i > 51; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1126 | mainArray[2][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1127 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1128 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1129 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1130 | } |
DanGibbons | 6:5e8e2645cd93 | 1131 | |
DanGibbons | 6:5e8e2645cd93 | 1132 | } |
DanGibbons | 6:5e8e2645cd93 | 1133 | |
DanGibbons | 6:5e8e2645cd93 | 1134 | if (player == false && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 1135 | |
DanGibbons | 6:5e8e2645cd93 | 1136 | for (int i = 0; i < 35; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1137 | mainArray[2][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1138 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1139 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1140 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1141 | } |
DanGibbons | 6:5e8e2645cd93 | 1142 | for (int i = 121; i > 103; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1143 | mainArray[2][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1144 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1145 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1146 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1147 | } |
DanGibbons | 6:5e8e2645cd93 | 1148 | for (int i = 86; i > 51; i--) { |
DanGibbons | 6:5e8e2645cd93 | 1149 | mainArray[2][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1150 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1151 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1152 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1153 | } |
DanGibbons | 6:5e8e2645cd93 | 1154 | |
DanGibbons | 6:5e8e2645cd93 | 1155 | } |
DanGibbons | 6:5e8e2645cd93 | 1156 | |
DanGibbons | 6:5e8e2645cd93 | 1157 | SetNumberPatterns(); |
DanGibbons | 6:5e8e2645cd93 | 1158 | |
DanGibbons | 6:5e8e2645cd93 | 1159 | } |
DanGibbons | 6:5e8e2645cd93 | 1160 | |
DanGibbons | 6:5e8e2645cd93 | 1161 | void ThreeInAnimation(bool robot, bool robotColour,bool player, bool playerColour) |
DanGibbons | 6:5e8e2645cd93 | 1162 | { |
DanGibbons | 6:5e8e2645cd93 | 1163 | memset(mainArray, 0, sizeof mainArray); |
DanGibbons | 6:5e8e2645cd93 | 1164 | |
DanGibbons | 6:5e8e2645cd93 | 1165 | if (player == true && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 1166 | |
DanGibbons | 6:5e8e2645cd93 | 1167 | for (int i = 0; i < 35; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1168 | mainArray[3][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1169 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1170 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1171 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1172 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1173 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1174 | } |
DanGibbons | 6:5e8e2645cd93 | 1175 | for (int i = 0; i < 17; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1176 | mainArray[3][35+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1177 | mainArray[3][121-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1178 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1179 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1180 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1181 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1182 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1183 | } |
DanGibbons | 6:5e8e2645cd93 | 1184 | for (int i = 52; i < 70; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1185 | mainArray[3][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1186 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1187 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1188 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1189 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1190 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1191 | } |
DanGibbons | 6:5e8e2645cd93 | 1192 | |
DanGibbons | 6:5e8e2645cd93 | 1193 | } |
DanGibbons | 6:5e8e2645cd93 | 1194 | |
DanGibbons | 6:5e8e2645cd93 | 1195 | if (player == true && robot == false) { |
DanGibbons | 6:5e8e2645cd93 | 1196 | |
DanGibbons | 6:5e8e2645cd93 | 1197 | for (int i = 0; i < 35; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1198 | mainArray[3][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1199 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1200 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1201 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1202 | } |
DanGibbons | 6:5e8e2645cd93 | 1203 | for (int i = 0; i < 17; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1204 | mainArray[3][35+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1205 | mainArray[3][121-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1206 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1207 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1208 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1209 | } |
DanGibbons | 6:5e8e2645cd93 | 1210 | for (int i = 52; i < 70; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1211 | mainArray[3][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1212 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1213 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1214 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1215 | } |
DanGibbons | 6:5e8e2645cd93 | 1216 | |
DanGibbons | 6:5e8e2645cd93 | 1217 | } |
DanGibbons | 6:5e8e2645cd93 | 1218 | |
DanGibbons | 6:5e8e2645cd93 | 1219 | if (player == false && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 1220 | |
DanGibbons | 6:5e8e2645cd93 | 1221 | for (int i = 0; i < 35; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1222 | mainArray[3][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1223 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1224 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1225 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1226 | } |
DanGibbons | 6:5e8e2645cd93 | 1227 | for (int i = 0; i < 18; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1228 | mainArray[3][35+i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1229 | mainArray[3][121-i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1230 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1231 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1232 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1233 | } |
DanGibbons | 6:5e8e2645cd93 | 1234 | for (int i = 52; i < 70; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1235 | mainArray[3][i] = 1; |
DanGibbons | 6:5e8e2645cd93 | 1236 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1237 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1238 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1239 | } |
DanGibbons | 6:5e8e2645cd93 | 1240 | |
DanGibbons | 6:5e8e2645cd93 | 1241 | } |
DanGibbons | 6:5e8e2645cd93 | 1242 | |
DanGibbons | 6:5e8e2645cd93 | 1243 | SetNumberPatterns(); |
DanGibbons | 6:5e8e2645cd93 | 1244 | |
DanGibbons | 6:5e8e2645cd93 | 1245 | } |
DanGibbons | 6:5e8e2645cd93 | 1246 | |
DanGibbons | 6:5e8e2645cd93 | 1247 | void ThreeOutAnimation(bool robot, bool robotColour,bool player, bool playerColour) |
DanGibbons | 6:5e8e2645cd93 | 1248 | { |
DanGibbons | 6:5e8e2645cd93 | 1249 | if (player == true && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 1250 | |
DanGibbons | 6:5e8e2645cd93 | 1251 | for (int i = 0; i < 18; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1252 | mainArray[3][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1253 | mainArray[3][104+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1254 | mainArray[3][69-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1255 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1256 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1257 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1258 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1259 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1260 | } |
DanGibbons | 6:5e8e2645cd93 | 1261 | for (int i = 0; i < 18; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1262 | mainArray[3][18+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1263 | mainArray[3][51-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1264 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1265 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1266 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1267 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1268 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1269 | } |
DanGibbons | 6:5e8e2645cd93 | 1270 | |
DanGibbons | 6:5e8e2645cd93 | 1271 | } |
DanGibbons | 6:5e8e2645cd93 | 1272 | |
DanGibbons | 6:5e8e2645cd93 | 1273 | if (player == true && robot == false) { |
DanGibbons | 6:5e8e2645cd93 | 1274 | |
DanGibbons | 6:5e8e2645cd93 | 1275 | for (int i = 0; i < 18; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1276 | mainArray[3][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1277 | mainArray[3][104+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1278 | mainArray[3][69-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1279 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1280 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1281 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1282 | } |
DanGibbons | 6:5e8e2645cd93 | 1283 | for (int i = 0; i < 18; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1284 | mainArray[3][18+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1285 | mainArray[3][51-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1286 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1287 | WritePxAnimation(playerScore,false,playerColour); |
DanGibbons | 6:5e8e2645cd93 | 1288 | playerScoreLED.write(playerScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1289 | } |
DanGibbons | 6:5e8e2645cd93 | 1290 | |
DanGibbons | 6:5e8e2645cd93 | 1291 | } |
DanGibbons | 6:5e8e2645cd93 | 1292 | |
DanGibbons | 6:5e8e2645cd93 | 1293 | if (player == false && robot == true) { |
DanGibbons | 6:5e8e2645cd93 | 1294 | |
DanGibbons | 6:5e8e2645cd93 | 1295 | for (int i = 0; i < 18; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1296 | mainArray[3][i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1297 | mainArray[3][104+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1298 | mainArray[3][69-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1299 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1300 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1301 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1302 | } |
DanGibbons | 6:5e8e2645cd93 | 1303 | for (int i = 0; i < 18; i++) { |
DanGibbons | 6:5e8e2645cd93 | 1304 | mainArray[3][18+i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1305 | mainArray[3][51-i] = 0; |
DanGibbons | 6:5e8e2645cd93 | 1306 | wait_ms(10); |
DanGibbons | 6:5e8e2645cd93 | 1307 | WritePxAnimation(robotScore,true,robotColour); |
DanGibbons | 6:5e8e2645cd93 | 1308 | robotScoreLED.write(robotScorePx.getBuf()); |
DanGibbons | 6:5e8e2645cd93 | 1309 | } |
DanGibbons | 6:5e8e2645cd93 | 1310 | |
DanGibbons | 6:5e8e2645cd93 | 1311 | } |
DanGibbons | 6:5e8e2645cd93 | 1312 | |
DanGibbons | 6:5e8e2645cd93 | 1313 | SetNumberPatterns(); |
DanGibbons | 6:5e8e2645cd93 | 1314 | |
DanGibbons | 6:5e8e2645cd93 | 1315 | } |
DanGibbons | 6:5e8e2645cd93 | 1316 | |
DanGibbons | 6:5e8e2645cd93 | 1317 | void idleButtonISR() |
DanGibbons | 6:5e8e2645cd93 | 1318 | { |
DanGibbons | 6:5e8e2645cd93 | 1319 | idle_flag = !idle_flag; |
DanGibbons | 6:5e8e2645cd93 | 1320 | } |