This is the Mexican Standoff prototype made by Francisco Martin and Andrew Smith. Please refer to the following link for instructions on hardware hookup: https://developer.mbed.org/users/fomartin/notebook/mexican-standoff-reaction-game/
Dependencies: SDFileSystem mbed-rtos mbed wave_player 4DGL-uLCD-SE PinDetect
States/Gameplay.cpp@0:75716bd37804, 2016-03-14 (annotated)
- Committer:
- fomartin
- Date:
- Mon Mar 14 03:04:08 2016 +0000
- Revision:
- 0:75716bd37804
- Child:
- 1:4976bbb3376f
Mexican Standoff Prototype;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fomartin | 0:75716bd37804 | 1 | #include "States.h" |
fomartin | 0:75716bd37804 | 2 | #include "mbed.h" |
fomartin | 0:75716bd37804 | 3 | |
fomartin | 0:75716bd37804 | 4 | //////////////////////////////////////////////////////////////// |
fomartin | 0:75716bd37804 | 5 | // CONSTRUCTORS |
fomartin | 0:75716bd37804 | 6 | //////////////////////////////////////////////////////////////// |
fomartin | 0:75716bd37804 | 7 | Gameplay::Gameplay(uLCD_4DGL &uLCD, int numberOfPlayers, PinDetect &P1_Left, PinDetect &P1_Right, PinDetect &P2_Left, PinDetect &P2_Right) |
fomartin | 0:75716bd37804 | 8 | { |
fomartin | 0:75716bd37804 | 9 | uLCD.background_color(LGREY); |
fomartin | 0:75716bd37804 | 10 | uLCD.cls(); |
fomartin | 0:75716bd37804 | 11 | //random seed setup |
fomartin | 0:75716bd37804 | 12 | srand(time(NULL)); |
fomartin | 0:75716bd37804 | 13 | |
fomartin | 0:75716bd37804 | 14 | numPlayers = numberOfPlayers; |
fomartin | 0:75716bd37804 | 15 | points = new int[2]; |
fomartin | 0:75716bd37804 | 16 | CPU cpu; |
fomartin | 0:75716bd37804 | 17 | |
fomartin | 0:75716bd37804 | 18 | DigitalOut led1(LED1); |
fomartin | 0:75716bd37804 | 19 | DigitalOut led4(LED4); |
fomartin | 0:75716bd37804 | 20 | |
fomartin | 0:75716bd37804 | 21 | //LCD setup |
fomartin | 0:75716bd37804 | 22 | uLCD.color(BLACK); |
fomartin | 0:75716bd37804 | 23 | uLCD.textbackground_color(LGREY); |
fomartin | 0:75716bd37804 | 24 | uLCD.set_font(FONT_7X8); |
fomartin | 0:75716bd37804 | 25 | |
fomartin | 0:75716bd37804 | 26 | //points setup |
fomartin | 0:75716bd37804 | 27 | resetPoints(uLCD); |
fomartin | 0:75716bd37804 | 28 | |
fomartin | 0:75716bd37804 | 29 | //it takes 5-6 seconds for guns to get drawn, but we only draw |
fomartin | 0:75716bd37804 | 30 | //them once at the beginning of the game |
fomartin | 0:75716bd37804 | 31 | drawGun(uLCD, 10, 30, true); |
fomartin | 0:75716bd37804 | 32 | drawGun(uLCD, 10, 92, true); |
fomartin | 0:75716bd37804 | 33 | |
fomartin | 0:75716bd37804 | 34 | drawGun(uLCD, 127 - 10 - 42, 30, false); |
fomartin | 0:75716bd37804 | 35 | drawGun(uLCD, 127 - 10 - 42, 92, false); |
fomartin | 0:75716bd37804 | 36 | |
fomartin | 0:75716bd37804 | 37 | while(getPoints(1) != 0 && getPoints(2) != 0) |
fomartin | 0:75716bd37804 | 38 | { |
fomartin | 0:75716bd37804 | 39 | //gameplay here |
fomartin | 0:75716bd37804 | 40 | //basic structure should be this: |
fomartin | 0:75716bd37804 | 41 | Prompt prompt = (Prompt)(rand() % 4); |
fomartin | 0:75716bd37804 | 42 | |
fomartin | 0:75716bd37804 | 43 | countdown(uLCD); |
fomartin | 0:75716bd37804 | 44 | clearCountdown(uLCD); |
fomartin | 0:75716bd37804 | 45 | |
fomartin | 0:75716bd37804 | 46 | if(prompt == HoldFire) |
fomartin | 0:75716bd37804 | 47 | { |
fomartin | 0:75716bd37804 | 48 | //hold fire |
fomartin | 0:75716bd37804 | 49 | displayXs(uLCD); |
fomartin | 0:75716bd37804 | 50 | |
fomartin | 0:75716bd37804 | 51 | Timer timer; |
fomartin | 0:75716bd37804 | 52 | timer.start(); |
fomartin | 0:75716bd37804 | 53 | |
fomartin | 0:75716bd37804 | 54 | //hold fire for 2 seconds |
fomartin | 0:75716bd37804 | 55 | while(timer.read_ms() < 2000) |
fomartin | 0:75716bd37804 | 56 | { |
fomartin | 0:75716bd37804 | 57 | if(!P1_Left || !P1_Right) |
fomartin | 0:75716bd37804 | 58 | { |
fomartin | 0:75716bd37804 | 59 | setPoints(1, getPoints(1) - 1, uLCD); |
fomartin | 0:75716bd37804 | 60 | led4 = 1; |
fomartin | 0:75716bd37804 | 61 | break; |
fomartin | 0:75716bd37804 | 62 | } |
fomartin | 0:75716bd37804 | 63 | |
fomartin | 0:75716bd37804 | 64 | //AI will never mis-fire |
fomartin | 0:75716bd37804 | 65 | if(numPlayers == 1 && (!P2_Left || !P2_Right)) |
fomartin | 0:75716bd37804 | 66 | { |
fomartin | 0:75716bd37804 | 67 | setPoints(2, getPoints(2) - 1, uLCD); |
fomartin | 0:75716bd37804 | 68 | led1 = 1; |
fomartin | 0:75716bd37804 | 69 | break; |
fomartin | 0:75716bd37804 | 70 | } |
fomartin | 0:75716bd37804 | 71 | } |
fomartin | 0:75716bd37804 | 72 | } |
fomartin | 0:75716bd37804 | 73 | else |
fomartin | 0:75716bd37804 | 74 | { |
fomartin | 0:75716bd37804 | 75 | if(prompt == Either) |
fomartin | 0:75716bd37804 | 76 | { |
fomartin | 0:75716bd37804 | 77 | displayCircle(uLCD); |
fomartin | 0:75716bd37804 | 78 | } |
fomartin | 0:75716bd37804 | 79 | else if(prompt == Down) |
fomartin | 0:75716bd37804 | 80 | { |
fomartin | 0:75716bd37804 | 81 | displayDownArrow(uLCD); |
fomartin | 0:75716bd37804 | 82 | } |
fomartin | 0:75716bd37804 | 83 | else if(prompt == Up) |
fomartin | 0:75716bd37804 | 84 | { |
fomartin | 0:75716bd37804 | 85 | displayUpArrow(uLCD); |
fomartin | 0:75716bd37804 | 86 | } |
fomartin | 0:75716bd37804 | 87 | |
fomartin | 0:75716bd37804 | 88 | int aiShootTime = 0; |
fomartin | 0:75716bd37804 | 89 | |
fomartin | 0:75716bd37804 | 90 | if(numPlayers == 1) |
fomartin | 0:75716bd37804 | 91 | aiShootTime = (int)(cpu.shootTime() * 1000); |
fomartin | 0:75716bd37804 | 92 | |
fomartin | 0:75716bd37804 | 93 | Timer timer; |
fomartin | 0:75716bd37804 | 94 | timer.start(); |
fomartin | 0:75716bd37804 | 95 | bool p1l = false, p1r = false, p2l = false, p2r = false; |
fomartin | 0:75716bd37804 | 96 | |
fomartin | 0:75716bd37804 | 97 | //wait for button to be pressed |
fomartin | 0:75716bd37804 | 98 | while(true) |
fomartin | 0:75716bd37804 | 99 | { |
fomartin | 0:75716bd37804 | 100 | if(numPlayers == 1 && timer.read_ms() > aiShootTime) |
fomartin | 0:75716bd37804 | 101 | { |
fomartin | 0:75716bd37804 | 102 | bool aiCorrect = cpu.shootAnswer(prompt); |
fomartin | 0:75716bd37804 | 103 | |
fomartin | 0:75716bd37804 | 104 | if(prompt == Up) |
fomartin | 0:75716bd37804 | 105 | { |
fomartin | 0:75716bd37804 | 106 | if(aiCorrect) |
fomartin | 0:75716bd37804 | 107 | { |
fomartin | 0:75716bd37804 | 108 | p2r = true; |
fomartin | 0:75716bd37804 | 109 | p2l = false; |
fomartin | 0:75716bd37804 | 110 | } |
fomartin | 0:75716bd37804 | 111 | else |
fomartin | 0:75716bd37804 | 112 | { |
fomartin | 0:75716bd37804 | 113 | p2l = true; |
fomartin | 0:75716bd37804 | 114 | p2r = false; |
fomartin | 0:75716bd37804 | 115 | } |
fomartin | 0:75716bd37804 | 116 | } |
fomartin | 0:75716bd37804 | 117 | else if (prompt == Down) |
fomartin | 0:75716bd37804 | 118 | { |
fomartin | 0:75716bd37804 | 119 | if(aiCorrect) |
fomartin | 0:75716bd37804 | 120 | { |
fomartin | 0:75716bd37804 | 121 | p2l = true; |
fomartin | 0:75716bd37804 | 122 | p2r = false; |
fomartin | 0:75716bd37804 | 123 | } |
fomartin | 0:75716bd37804 | 124 | else |
fomartin | 0:75716bd37804 | 125 | { |
fomartin | 0:75716bd37804 | 126 | p2r = true; |
fomartin | 0:75716bd37804 | 127 | p2l = false; |
fomartin | 0:75716bd37804 | 128 | } |
fomartin | 0:75716bd37804 | 129 | } |
fomartin | 0:75716bd37804 | 130 | else |
fomartin | 0:75716bd37804 | 131 | { |
fomartin | 0:75716bd37804 | 132 | //prompt = either, just press left |
fomartin | 0:75716bd37804 | 133 | p2l = true; |
fomartin | 0:75716bd37804 | 134 | p2r = false; |
fomartin | 0:75716bd37804 | 135 | } |
fomartin | 0:75716bd37804 | 136 | |
fomartin | 0:75716bd37804 | 137 | break; |
fomartin | 0:75716bd37804 | 138 | } |
fomartin | 0:75716bd37804 | 139 | |
fomartin | 0:75716bd37804 | 140 | if(!P1_Left) |
fomartin | 0:75716bd37804 | 141 | { |
fomartin | 0:75716bd37804 | 142 | p1l = true; |
fomartin | 0:75716bd37804 | 143 | p1r = false; |
fomartin | 0:75716bd37804 | 144 | p2l = false; |
fomartin | 0:75716bd37804 | 145 | p2r = false; |
fomartin | 0:75716bd37804 | 146 | break; |
fomartin | 0:75716bd37804 | 147 | } |
fomartin | 0:75716bd37804 | 148 | |
fomartin | 0:75716bd37804 | 149 | if(!P1_Right) |
fomartin | 0:75716bd37804 | 150 | { |
fomartin | 0:75716bd37804 | 151 | p1l = false; |
fomartin | 0:75716bd37804 | 152 | p1r = true; |
fomartin | 0:75716bd37804 | 153 | p2l = false; |
fomartin | 0:75716bd37804 | 154 | p2r = false; |
fomartin | 0:75716bd37804 | 155 | break; |
fomartin | 0:75716bd37804 | 156 | } |
fomartin | 0:75716bd37804 | 157 | |
fomartin | 0:75716bd37804 | 158 | if(numPlayers == 2 && !P2_Left) |
fomartin | 0:75716bd37804 | 159 | { |
fomartin | 0:75716bd37804 | 160 | p1l = false; |
fomartin | 0:75716bd37804 | 161 | p1r = false; |
fomartin | 0:75716bd37804 | 162 | p2l = true; |
fomartin | 0:75716bd37804 | 163 | p2r = false; |
fomartin | 0:75716bd37804 | 164 | break; |
fomartin | 0:75716bd37804 | 165 | } |
fomartin | 0:75716bd37804 | 166 | |
fomartin | 0:75716bd37804 | 167 | if(numPlayers == 2 && !P2_Right) |
fomartin | 0:75716bd37804 | 168 | { |
fomartin | 0:75716bd37804 | 169 | p1l = false; |
fomartin | 0:75716bd37804 | 170 | p1r = false; |
fomartin | 0:75716bd37804 | 171 | p2l = false; |
fomartin | 0:75716bd37804 | 172 | p2r = true; |
fomartin | 0:75716bd37804 | 173 | break; |
fomartin | 0:75716bd37804 | 174 | } |
fomartin | 0:75716bd37804 | 175 | } |
fomartin | 0:75716bd37804 | 176 | |
fomartin | 0:75716bd37804 | 177 | if(p1l) |
fomartin | 0:75716bd37804 | 178 | { |
fomartin | 0:75716bd37804 | 179 | if(prompt == Either || prompt == Up) |
fomartin | 0:75716bd37804 | 180 | { |
fomartin | 0:75716bd37804 | 181 | setPoints(2, getPoints(2) - 1, uLCD); |
fomartin | 0:75716bd37804 | 182 | led1 = 1; |
fomartin | 0:75716bd37804 | 183 | } |
fomartin | 0:75716bd37804 | 184 | else |
fomartin | 0:75716bd37804 | 185 | { |
fomartin | 0:75716bd37804 | 186 | setPoints(1, getPoints(1) - 1, uLCD); |
fomartin | 0:75716bd37804 | 187 | led4 = 1; |
fomartin | 0:75716bd37804 | 188 | } |
fomartin | 0:75716bd37804 | 189 | } |
fomartin | 0:75716bd37804 | 190 | else if(p1r) |
fomartin | 0:75716bd37804 | 191 | { |
fomartin | 0:75716bd37804 | 192 | if(prompt == Either || prompt == Down) |
fomartin | 0:75716bd37804 | 193 | { |
fomartin | 0:75716bd37804 | 194 | setPoints(2, getPoints(2) - 1, uLCD); |
fomartin | 0:75716bd37804 | 195 | led1 = 1; |
fomartin | 0:75716bd37804 | 196 | } |
fomartin | 0:75716bd37804 | 197 | else |
fomartin | 0:75716bd37804 | 198 | { |
fomartin | 0:75716bd37804 | 199 | setPoints(1, getPoints(1) - 1, uLCD); |
fomartin | 0:75716bd37804 | 200 | led4 = 1; |
fomartin | 0:75716bd37804 | 201 | } |
fomartin | 0:75716bd37804 | 202 | } |
fomartin | 0:75716bd37804 | 203 | else if(p2l) |
fomartin | 0:75716bd37804 | 204 | { |
fomartin | 0:75716bd37804 | 205 | if(prompt == Either || prompt == Down) |
fomartin | 0:75716bd37804 | 206 | { |
fomartin | 0:75716bd37804 | 207 | setPoints(1, getPoints(1) - 1, uLCD); |
fomartin | 0:75716bd37804 | 208 | led4 = 1; |
fomartin | 0:75716bd37804 | 209 | } |
fomartin | 0:75716bd37804 | 210 | else |
fomartin | 0:75716bd37804 | 211 | { |
fomartin | 0:75716bd37804 | 212 | setPoints(2, getPoints(2) - 1, uLCD); |
fomartin | 0:75716bd37804 | 213 | led1 = 1; |
fomartin | 0:75716bd37804 | 214 | } |
fomartin | 0:75716bd37804 | 215 | } |
fomartin | 0:75716bd37804 | 216 | else if(p2r) |
fomartin | 0:75716bd37804 | 217 | { |
fomartin | 0:75716bd37804 | 218 | if(prompt == Either || prompt == Up) |
fomartin | 0:75716bd37804 | 219 | { |
fomartin | 0:75716bd37804 | 220 | setPoints(1, getPoints(1) - 1, uLCD); |
fomartin | 0:75716bd37804 | 221 | led4 = 1; |
fomartin | 0:75716bd37804 | 222 | } |
fomartin | 0:75716bd37804 | 223 | else |
fomartin | 0:75716bd37804 | 224 | { |
fomartin | 0:75716bd37804 | 225 | setPoints(2, getPoints(2) - 1, uLCD); |
fomartin | 0:75716bd37804 | 226 | led1 = 1; |
fomartin | 0:75716bd37804 | 227 | } |
fomartin | 0:75716bd37804 | 228 | } |
fomartin | 0:75716bd37804 | 229 | } |
fomartin | 0:75716bd37804 | 230 | |
fomartin | 0:75716bd37804 | 231 | clearPrompt(uLCD); |
fomartin | 0:75716bd37804 | 232 | Thread::wait(2000); |
fomartin | 0:75716bd37804 | 233 | led1 = 0; |
fomartin | 0:75716bd37804 | 234 | led4 = 0; |
fomartin | 0:75716bd37804 | 235 | } |
fomartin | 0:75716bd37804 | 236 | |
fomartin | 0:75716bd37804 | 237 | if(getPoints(1) == 0) |
fomartin | 0:75716bd37804 | 238 | winningPlayer = 2; |
fomartin | 0:75716bd37804 | 239 | else |
fomartin | 0:75716bd37804 | 240 | winningPlayer = 1; |
fomartin | 0:75716bd37804 | 241 | } |
fomartin | 0:75716bd37804 | 242 | |
fomartin | 0:75716bd37804 | 243 | //////////////////////////////////////////////////////////////// |
fomartin | 0:75716bd37804 | 244 | // GET FUNCTIONS |
fomartin | 0:75716bd37804 | 245 | //////////////////////////////////////////////////////////////// |
fomartin | 0:75716bd37804 | 246 | int Gameplay::getPoints(int player) |
fomartin | 0:75716bd37804 | 247 | { |
fomartin | 0:75716bd37804 | 248 | return points[player - 1]; |
fomartin | 0:75716bd37804 | 249 | } |
fomartin | 0:75716bd37804 | 250 | |
fomartin | 0:75716bd37804 | 251 | int Gameplay::getWinningPlayer() |
fomartin | 0:75716bd37804 | 252 | { |
fomartin | 0:75716bd37804 | 253 | return winningPlayer; |
fomartin | 0:75716bd37804 | 254 | } |
fomartin | 0:75716bd37804 | 255 | |
fomartin | 0:75716bd37804 | 256 | //////////////////////////////////////////////////////////////// |
fomartin | 0:75716bd37804 | 257 | // SET FUNCTIONS |
fomartin | 0:75716bd37804 | 258 | //////////////////////////////////////////////////////////////// |
fomartin | 0:75716bd37804 | 259 | void Gameplay::resetPoints(uLCD_4DGL &uLCD) |
fomartin | 0:75716bd37804 | 260 | { |
fomartin | 0:75716bd37804 | 261 | points[0] = 5; |
fomartin | 0:75716bd37804 | 262 | points[1] = 5; |
fomartin | 0:75716bd37804 | 263 | renderScore(uLCD); |
fomartin | 0:75716bd37804 | 264 | } |
fomartin | 0:75716bd37804 | 265 | |
fomartin | 0:75716bd37804 | 266 | void Gameplay::setPoints(int player, int value, uLCD_4DGL &uLCD) |
fomartin | 0:75716bd37804 | 267 | { |
fomartin | 0:75716bd37804 | 268 | points[player - 1] = value; |
fomartin | 0:75716bd37804 | 269 | renderScore(uLCD); |
fomartin | 0:75716bd37804 | 270 | } |
fomartin | 0:75716bd37804 | 271 | |
fomartin | 0:75716bd37804 | 272 | //////////////////////////////////////////////////////////////// |
fomartin | 0:75716bd37804 | 273 | // PROTECTED FUNCTIONS |
fomartin | 0:75716bd37804 | 274 | //////////////////////////////////////////////////////////////// |
fomartin | 0:75716bd37804 | 275 | |
fomartin | 0:75716bd37804 | 276 | void Gameplay::drawGun(uLCD_4DGL &uLCD, int x, int y, bool facingRight) |
fomartin | 0:75716bd37804 | 277 | { |
fomartin | 0:75716bd37804 | 278 | if(facingRight) |
fomartin | 0:75716bd37804 | 279 | { |
fomartin | 0:75716bd37804 | 280 | int colors[] = {12566463, 12566463, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -5023488, -5023488, -5023488, -5023488, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -5023488, -5023488, -5023488, -5023488, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -5023488, -5023488, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, -5023488, -5023488, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -8372224, -8372224, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -8372224, -8372224, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -11382190, -11382190, -11382190, -11382190, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -11382190, -11382190, -11382190, -11382190, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463}; |
fomartin | 0:75716bd37804 | 281 | uLCD.BLIT(x, y, 42, 20, colors); |
fomartin | 0:75716bd37804 | 282 | } |
fomartin | 0:75716bd37804 | 283 | else |
fomartin | 0:75716bd37804 | 284 | { |
fomartin | 0:75716bd37804 | 285 | int colors[] = {12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -11382190, -11382190, -11382190, -11382190, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -11382190, -11382190, -11382190, -11382190, -11382190, -11382190, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -8372224, -8372224, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -8372224, -8372224, -13158601, -13158601, -13158601, -13158601, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -5023488, -5023488, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, -5023488, -5023488, -8372224, -8372224, -8372224, -8372224, -8372224, -8372224, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, 12566463, 12566463, -16777216, -16777216, -5023488, -5023488, -5023488, -5023488, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -5023488, -5023488, -5023488, -5023488, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, -16777216, -16777216, -16777216, -16777216, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463, 12566463}; |
fomartin | 0:75716bd37804 | 286 | uLCD.BLIT(x, y, 42, 20, colors); |
fomartin | 0:75716bd37804 | 287 | } |
fomartin | 0:75716bd37804 | 288 | } |
fomartin | 0:75716bd37804 | 289 | |
fomartin | 0:75716bd37804 | 290 | void Gameplay::displayUpArrow(uLCD_4DGL &uLCD) |
fomartin | 0:75716bd37804 | 291 | { |
fomartin | 0:75716bd37804 | 292 | uLCD.line(64, 64, 64, 30, GREEN); |
fomartin | 0:75716bd37804 | 293 | uLCD.line(54, 40, 64, 30, GREEN); |
fomartin | 0:75716bd37804 | 294 | uLCD.line(74, 40, 64, 30, GREEN); |
fomartin | 0:75716bd37804 | 295 | } |
fomartin | 0:75716bd37804 | 296 | |
fomartin | 0:75716bd37804 | 297 | void Gameplay::displayDownArrow(uLCD_4DGL &uLCD) |
fomartin | 0:75716bd37804 | 298 | { |
fomartin | 0:75716bd37804 | 299 | uLCD.line(64, 64, 64, 98, GREEN); |
fomartin | 0:75716bd37804 | 300 | uLCD.line(54, 88, 64, 98, GREEN); |
fomartin | 0:75716bd37804 | 301 | uLCD.line(74, 88, 64, 98, GREEN); |
fomartin | 0:75716bd37804 | 302 | } |
fomartin | 0:75716bd37804 | 303 | |
fomartin | 0:75716bd37804 | 304 | void Gameplay::displayCircle(uLCD_4DGL &uLCD) |
fomartin | 0:75716bd37804 | 305 | { |
fomartin | 0:75716bd37804 | 306 | uLCD.circle(64, 64, 15, GREEN); |
fomartin | 0:75716bd37804 | 307 | } |
fomartin | 0:75716bd37804 | 308 | |
fomartin | 0:75716bd37804 | 309 | void Gameplay::displayXs(uLCD_4DGL &uLCD) |
fomartin | 0:75716bd37804 | 310 | { |
fomartin | 0:75716bd37804 | 311 | //top X |
fomartin | 0:75716bd37804 | 312 | uLCD.line(54, 40, 74, 20, RED); |
fomartin | 0:75716bd37804 | 313 | uLCD.line(54, 20, 74, 40, RED); |
fomartin | 0:75716bd37804 | 314 | |
fomartin | 0:75716bd37804 | 315 | //bottom X |
fomartin | 0:75716bd37804 | 316 | uLCD.line(54, 88, 74, 108, RED); |
fomartin | 0:75716bd37804 | 317 | uLCD.line(54, 108, 74, 88, RED); |
fomartin | 0:75716bd37804 | 318 | } |
fomartin | 0:75716bd37804 | 319 | |
fomartin | 0:75716bd37804 | 320 | //clears the arrow/circle/x currently on the screen |
fomartin | 0:75716bd37804 | 321 | void Gameplay::clearPrompt(uLCD_4DGL &uLCD) |
fomartin | 0:75716bd37804 | 322 | { |
fomartin | 0:75716bd37804 | 323 | //up arrow |
fomartin | 0:75716bd37804 | 324 | uLCD.line(64, 64, 64, 30, LGREY); |
fomartin | 0:75716bd37804 | 325 | uLCD.line(54, 40, 64, 30, LGREY); |
fomartin | 0:75716bd37804 | 326 | uLCD.line(74, 40, 64, 30, LGREY); |
fomartin | 0:75716bd37804 | 327 | |
fomartin | 0:75716bd37804 | 328 | //down arrow |
fomartin | 0:75716bd37804 | 329 | uLCD.line(64, 64, 64, 98, LGREY); |
fomartin | 0:75716bd37804 | 330 | uLCD.line(54, 88, 64, 98, LGREY); |
fomartin | 0:75716bd37804 | 331 | uLCD.line(74, 88, 64, 98, LGREY); |
fomartin | 0:75716bd37804 | 332 | |
fomartin | 0:75716bd37804 | 333 | //circle |
fomartin | 0:75716bd37804 | 334 | uLCD.circle(64, 64, 15, LGREY); |
fomartin | 0:75716bd37804 | 335 | |
fomartin | 0:75716bd37804 | 336 | //top X |
fomartin | 0:75716bd37804 | 337 | uLCD.line(54, 40, 74, 20, LGREY); |
fomartin | 0:75716bd37804 | 338 | uLCD.line(54, 20, 74, 40, LGREY); |
fomartin | 0:75716bd37804 | 339 | |
fomartin | 0:75716bd37804 | 340 | //bottom X |
fomartin | 0:75716bd37804 | 341 | uLCD.line(54, 88, 74, 108, LGREY); |
fomartin | 0:75716bd37804 | 342 | uLCD.line(54, 108, 74, 88, LGREY); |
fomartin | 0:75716bd37804 | 343 | } |
fomartin | 0:75716bd37804 | 344 | |
fomartin | 0:75716bd37804 | 345 | |
fomartin | 0:75716bd37804 | 346 | void Gameplay::countdown(uLCD_4DGL &uLCD) |
fomartin | 0:75716bd37804 | 347 | { |
fomartin | 0:75716bd37804 | 348 | uLCD.locate(5, 8); |
fomartin | 0:75716bd37804 | 349 | uLCD.printf("3"); |
fomartin | 0:75716bd37804 | 350 | Thread::wait(333); |
fomartin | 0:75716bd37804 | 351 | uLCD.printf("."); |
fomartin | 0:75716bd37804 | 352 | Thread::wait(333); |
fomartin | 0:75716bd37804 | 353 | uLCD.printf("."); |
fomartin | 0:75716bd37804 | 354 | Thread::wait(333); |
fomartin | 0:75716bd37804 | 355 | uLCD.printf("2"); |
fomartin | 0:75716bd37804 | 356 | Thread::wait(333); |
fomartin | 0:75716bd37804 | 357 | uLCD.printf("."); |
fomartin | 0:75716bd37804 | 358 | Thread::wait(333); |
fomartin | 0:75716bd37804 | 359 | uLCD.printf("."); |
fomartin | 0:75716bd37804 | 360 | Thread::wait(333); |
fomartin | 0:75716bd37804 | 361 | uLCD.printf("1"); |
fomartin | 0:75716bd37804 | 362 | Thread::wait(333); |
fomartin | 0:75716bd37804 | 363 | uLCD.printf("."); |
fomartin | 0:75716bd37804 | 364 | Thread::wait(333); |
fomartin | 0:75716bd37804 | 365 | uLCD.printf("."); |
fomartin | 0:75716bd37804 | 366 | Thread::wait(333); |
fomartin | 0:75716bd37804 | 367 | } |
fomartin | 0:75716bd37804 | 368 | |
fomartin | 0:75716bd37804 | 369 | void Gameplay::clearCountdown(uLCD_4DGL &uLCD) |
fomartin | 0:75716bd37804 | 370 | { |
fomartin | 0:75716bd37804 | 371 | uLCD.filled_rectangle(30, 50, 98, 78, LGREY); |
fomartin | 0:75716bd37804 | 372 | } |
fomartin | 0:75716bd37804 | 373 | |
fomartin | 0:75716bd37804 | 374 | void Gameplay::renderScore(uLCD_4DGL &uLCD) |
fomartin | 0:75716bd37804 | 375 | { |
fomartin | 0:75716bd37804 | 376 | uLCD.locate(3, 0); |
fomartin | 0:75716bd37804 | 377 | uLCD.printf("P1: %d", getPoints(1)); |
fomartin | 0:75716bd37804 | 378 | |
fomartin | 0:75716bd37804 | 379 | uLCD.locate(10, 0); |
fomartin | 0:75716bd37804 | 380 | uLCD.printf("P2: %d", getPoints(2)); |
fomartin | 0:75716bd37804 | 381 | } |