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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Gameplay.cpp Source File

Gameplay.cpp

00001 #include "States.h"
00002 #include "mbed.h"
00003 
00004 ////////////////////////////////////////////////////////////////
00005 // CONSTRUCTOR
00006 ////////////////////////////////////////////////////////////////
00007 Gameplay::Gameplay(uLCD_4DGL &uLCD, int numberOfPlayers, PinDetect &P1_Left, PinDetect &P1_Right, PinDetect &P2_Left, PinDetect &P2_Right)
00008 {   
00009     uLCD.background_color(LGREY);
00010     uLCD.cls();
00011     //random seed setup
00012     srand(time(NULL));
00013     
00014     numPlayers = numberOfPlayers;
00015     points = new int[2];
00016     CPU cpu;
00017     
00018     //LED's used to indicate which player wins each round
00019     DigitalOut led1(LED1);
00020     DigitalOut led4(LED4);
00021 
00022     //LCD setup
00023     uLCD.color(BLACK);
00024     uLCD.textbackground_color(LGREY);
00025     uLCD.set_font(FONT_7X8);
00026 
00027     //points setup
00028     resetPoints(uLCD);
00029     
00030     //it takes 5-6 seconds for guns to get drawn, but we only draw
00031     //them once at the beginning of the game-- so that's okay
00032     drawGun(uLCD, 10, 30, true);
00033     drawGun(uLCD, 10, 92, true);
00034     
00035     drawGun(uLCD, 127 - 10 - 42, 30, false);
00036     drawGun(uLCD, 127 - 10 - 42, 92, false);
00037     
00038     //loop until someone runs out of points
00039     while(getPoints(1) != 0 && getPoints(2) != 0)
00040     {
00041         //gameplay here
00042         
00043         //generate which prompt will be given
00044         Prompt prompt = (Prompt)(rand() % 4);
00045         
00046         //display countdown
00047         countdown(uLCD);   
00048         
00049         //clear the countdown     
00050         clearCountdown(uLCD);
00051         
00052         //show the prompt, and listen for inputs
00053         if(prompt == HoldFire)
00054         {
00055             //hold fire
00056             displayXs(uLCD);
00057             
00058             Timer timer;
00059             timer.start();
00060             
00061             //hold fire lasts for 2 seconds
00062             //if a player fires during this 2 seconds
00063             //they lose a point
00064             while(timer.read_ms() < 2000)
00065             {
00066                 if(!P1_Left || !P1_Right)
00067                 {
00068                     setPoints(1, getPoints(1) - 1, uLCD);
00069                     led4 = 1;
00070                     break;
00071                 }
00072                 
00073                 //AI will never mis-fire on hold-fire... just for simplicity's sake
00074                 if(numPlayers == 2 && (!P2_Left || !P2_Right))
00075                 {
00076                     setPoints(2, getPoints(2) - 1, uLCD);
00077                     led1 = 1;
00078                     break;
00079                 }
00080             }
00081         }
00082         else
00083         {
00084             if(prompt == Either)
00085             {
00086                 displayCircle(uLCD);
00087             }
00088             else if(prompt == Down)
00089             {
00090                 displayDownArrow(uLCD);
00091             }
00092             else if(prompt == Up)
00093             {
00094                 displayUpArrow(uLCD);
00095             }
00096             
00097             int aiShootTime = 0;
00098             
00099             if(numPlayers == 1)
00100                 aiShootTime = (int)(cpu.shootTime() * 1000);
00101                 
00102             Timer timer;
00103             timer.start();
00104             
00105             //these variables act as a layer of indirection between the button being pressed
00106             //and the value being read by the program. This allows us to "inject" fake
00107             //button presses for the AI without having to actually have a button signal
00108             //be sent by the hardware
00109             bool p1l = false, p1r = false, p2l = false, p2r = false;
00110             
00111             //wait for button to be pressed
00112             while(true)
00113             {
00114                 //if the predetermined ai wait time has elapsed, input the AI's button press
00115                 if(numPlayers == 1 && timer.read_ms() > aiShootTime)
00116                 {
00117                     bool aiCorrect = cpu.shootAnswer(prompt);
00118                     
00119                     if(prompt == Up)
00120                     {
00121                         if(aiCorrect)
00122                         {
00123                             p2r = true;
00124                             p2l = false;
00125                         }
00126                         else
00127                         {
00128                             p2l = true;
00129                             p2r = false;
00130                         }
00131                     }
00132                     else if (prompt == Down)
00133                     {
00134                         if(aiCorrect)
00135                         {
00136                             p2l = true;
00137                             p2r = false;
00138                         }
00139                         else
00140                         {
00141                             p2r = true;
00142                             p2l = false;
00143                         }
00144                     }
00145                     else
00146                     {
00147                         //prompt = either, just press left since either one works for this prompt
00148                         p2l = true;
00149                         p2r = false;
00150                     }
00151                     
00152                     break;
00153                 }
00154                 
00155                 if(!P1_Left)
00156                 {
00157                     p1l = true;
00158                     p1r = false;
00159                     p2l = false;
00160                     p2r = false;
00161                     break;
00162                 }
00163                 
00164                 if(!P1_Right)
00165                 {
00166                     p1l = false;
00167                     p1r = true;
00168                     p2l = false;
00169                     p2r = false;
00170                     break;
00171                 }
00172                 
00173                 //only read p2 buttons if its a 2 player game
00174                 if(numPlayers == 2 && !P2_Left)
00175                 {
00176                     p1l = false;
00177                     p1r = false;
00178                     p2l = true;
00179                     p2r = false;
00180                     break;
00181                 }
00182                 
00183                 if(numPlayers == 2 && !P2_Right)
00184                 {
00185                     p1l = false;
00186                     p1r = false;
00187                     p2l = false;
00188                     p2r = true;
00189                     break;
00190                 }
00191             }
00192             
00193             
00194             //check the button presses against the prompt given. decrement points accordingly
00195             if(p1l)
00196             {
00197                 if(prompt == Either || prompt == Up)
00198                 {
00199                     setPoints(2, getPoints(2) - 1, uLCD);
00200                     led1 = 1;
00201                 }
00202                 else
00203                 {
00204                     setPoints(1, getPoints(1) - 1, uLCD);
00205                     led4 = 1;
00206                 }
00207             }
00208             else if(p1r)
00209             {
00210                 if(prompt == Either || prompt == Down)
00211                 {
00212                     setPoints(2, getPoints(2) - 1, uLCD);
00213                     led1 = 1;
00214                 }
00215                 else
00216                 {
00217                     setPoints(1, getPoints(1) - 1, uLCD);
00218                     led4 = 1;
00219                 }
00220             }
00221             else if(p2l)
00222             {
00223                 if(prompt == Either || prompt == Down)
00224                 {
00225                     setPoints(1, getPoints(1) - 1, uLCD);
00226                     led4 = 1;
00227                 }
00228                 else
00229                 {
00230                     setPoints(2, getPoints(2) - 1, uLCD);
00231                     led1 = 1;
00232                 }
00233             }
00234             else if(p2r)
00235             {
00236                 if(prompt == Either || prompt == Up)
00237                 {
00238                     setPoints(1, getPoints(1) - 1, uLCD);
00239                     led4 = 1;
00240                 }
00241                 else
00242                 {
00243                     setPoints(2, getPoints(2) - 1, uLCD);
00244                     led1 = 1;
00245                 }
00246             }
00247         }
00248         
00249         //remove the displayed prompt. Wait 2 seconds to give the players some
00250         //amount of rest time between rounds
00251         clearPrompt(uLCD);
00252         Thread::wait(2000);
00253         led1 = 0;
00254         led4 = 0;
00255     }
00256     
00257     //store the winning player in a variable so the main method can create the correct GameOver screen
00258     if(getPoints(1) == 0)
00259         winningPlayer = 2;
00260     else
00261         winningPlayer = 1;
00262 }
00263 
00264 ////////////////////////////////////////////////////////////////
00265 // GET FUNCTIONS
00266 ////////////////////////////////////////////////////////////////
00267 int Gameplay::getPoints(int player)
00268 {
00269     return points[player - 1];
00270 }
00271 
00272 int Gameplay::getWinningPlayer()
00273 {
00274     return winningPlayer;
00275 }
00276 
00277 ////////////////////////////////////////////////////////////////
00278 // SET FUNCTIONS
00279 ////////////////////////////////////////////////////////////////
00280 void Gameplay::resetPoints(uLCD_4DGL &uLCD)
00281 {
00282     points[0] = 5;
00283     points[1] = 5;
00284     renderScore(uLCD);
00285 }
00286 
00287 void Gameplay::setPoints(int player, int value, uLCD_4DGL &uLCD)
00288 {
00289     points[player - 1] = value;
00290     renderScore(uLCD);
00291 }
00292 
00293 ////////////////////////////////////////////////////////////////
00294 // PROTECTED FUNCTIONS
00295 ////////////////////////////////////////////////////////////////
00296 
00297 void Gameplay::drawGun(uLCD_4DGL &uLCD, int x, int y, bool facingRight)
00298 {
00299     //image arrays generated using a separate Java program (for ease of operating with images)
00300     if(facingRight)
00301     {
00302         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};
00303         uLCD.BLIT(x, y, 42, 20, colors);
00304     }
00305     else
00306     {
00307         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};
00308         uLCD.BLIT(x, y, 42, 20, colors);
00309     }
00310 }
00311 
00312 void Gameplay::displayUpArrow(uLCD_4DGL &uLCD)
00313 {
00314     uLCD.line(64, 64, 64, 30, GREEN);
00315     uLCD.line(54, 40, 64, 30, GREEN);
00316     uLCD.line(74, 40, 64, 30, GREEN);
00317 }
00318 
00319 void Gameplay::displayDownArrow(uLCD_4DGL &uLCD)
00320 {
00321     uLCD.line(64, 64, 64, 98, GREEN);
00322     uLCD.line(54, 88, 64, 98, GREEN);
00323     uLCD.line(74, 88, 64, 98, GREEN);
00324 }
00325 
00326 void Gameplay::displayCircle(uLCD_4DGL &uLCD)
00327 {
00328     uLCD.circle(64, 64, 15, GREEN);   
00329 }
00330 
00331 void Gameplay::displayXs(uLCD_4DGL &uLCD)
00332 {
00333     //top X
00334     uLCD.line(54, 40, 74, 20, RED);
00335     uLCD.line(54, 20, 74, 40, RED);
00336     
00337     //bottom X
00338     uLCD.line(54, 88, 74, 108, RED);
00339     uLCD.line(54, 108, 74, 88, RED);
00340 }
00341 
00342 //clears the arrow/circle/x currently on the screen
00343 void Gameplay::clearPrompt(uLCD_4DGL &uLCD)
00344 {
00345     //up arrow
00346     uLCD.line(64, 64, 64, 30, LGREY);
00347     uLCD.line(54, 40, 64, 30, LGREY);
00348     uLCD.line(74, 40, 64, 30, LGREY);
00349     
00350     //down arrow
00351     uLCD.line(64, 64, 64, 98, LGREY);
00352     uLCD.line(54, 88, 64, 98, LGREY);
00353     uLCD.line(74, 88, 64, 98, LGREY);
00354     
00355     //circle
00356     uLCD.circle(64, 64, 15, LGREY);
00357     
00358     //top X
00359     uLCD.line(54, 40, 74, 20, LGREY);
00360     uLCD.line(54, 20, 74, 40, LGREY);
00361     
00362     //bottom X
00363     uLCD.line(54, 88, 74, 108, LGREY);
00364     uLCD.line(54, 108, 74, 88, LGREY);
00365 }
00366 
00367 //Displays 3..2..1.. on screen
00368 void Gameplay::countdown(uLCD_4DGL &uLCD)
00369 {
00370     uLCD.locate(5, 8);
00371     uLCD.printf("3");
00372     Thread::wait(333);
00373     uLCD.printf(".");
00374     Thread::wait(333);
00375     uLCD.printf(".");
00376     Thread::wait(333);
00377     uLCD.printf("2");
00378     Thread::wait(333);
00379     uLCD.printf(".");
00380     Thread::wait(333);
00381     uLCD.printf(".");
00382     Thread::wait(333);
00383     uLCD.printf("1");
00384     Thread::wait(333);
00385     uLCD.printf(".");
00386     Thread::wait(333);
00387     uLCD.printf(".");
00388     Thread::wait(333);
00389 }
00390 
00391 //clears the 3..2..1.. display
00392 void Gameplay::clearCountdown(uLCD_4DGL &uLCD)
00393 {
00394     uLCD.filled_rectangle(30, 50, 98, 78, LGREY);
00395 }
00396 
00397 //re-draws the score on the screen
00398 void Gameplay::renderScore(uLCD_4DGL &uLCD)
00399 {    
00400     uLCD.locate(3, 0);
00401     uLCD.printf("P1: %d", getPoints(1));
00402     
00403     uLCD.locate(10, 0);
00404     uLCD.printf("P2: %d", getPoints(2));
00405 }