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
Revision 1:4976bbb3376f, committed 2016-03-14
- Comitter:
- fomartin
- Date:
- Mon Mar 14 16:19:47 2016 +0000
- Parent:
- 0:75716bd37804
- Child:
- 2:3c1a5079243d
- Commit message:
- added more comments
Changed in this revision
--- a/States/GameOver.cpp Mon Mar 14 03:04:08 2016 +0000
+++ b/States/GameOver.cpp Mon Mar 14 16:19:47 2016 +0000
@@ -13,6 +13,7 @@
uLCD.color(WHITE);
uLCD.printf("\n Game Over \n");
+ //display the game over screen with the winning player
if(winningPlayer == 1)
{
uLCD.locate(0, 5);
@@ -29,5 +30,6 @@
uLCD.printf(" PLAYER 1 SUCKS... \n");
}
+ //return after any button press
while(Button0 && Button1 && Button2 && Button3) {}
}
--- a/States/Gameplay.cpp Mon Mar 14 03:04:08 2016 +0000
+++ b/States/Gameplay.cpp Mon Mar 14 16:19:47 2016 +0000
@@ -2,7 +2,7 @@
#include "mbed.h"
////////////////////////////////////////////////////////////////
-// CONSTRUCTORS
+// CONSTRUCTOR
////////////////////////////////////////////////////////////////
Gameplay::Gameplay(uLCD_4DGL &uLCD, int numberOfPlayers, PinDetect &P1_Left, PinDetect &P1_Right, PinDetect &P2_Left, PinDetect &P2_Right)
{
@@ -15,6 +15,7 @@
points = new int[2];
CPU cpu;
+ //LED's used to indicate which player wins each round
DigitalOut led1(LED1);
DigitalOut led4(LED4);
@@ -27,22 +28,28 @@
resetPoints(uLCD);
//it takes 5-6 seconds for guns to get drawn, but we only draw
- //them once at the beginning of the game
+ //them once at the beginning of the game-- so that's okay
drawGun(uLCD, 10, 30, true);
drawGun(uLCD, 10, 92, true);
drawGun(uLCD, 127 - 10 - 42, 30, false);
drawGun(uLCD, 127 - 10 - 42, 92, false);
+ //loop until someone runs out of points
while(getPoints(1) != 0 && getPoints(2) != 0)
{
//gameplay here
- //basic structure should be this:
+
+ //generate which prompt will be given
Prompt prompt = (Prompt)(rand() % 4);
- countdown(uLCD);
+ //display countdown
+ countdown(uLCD);
+
+ //clear the countdown
clearCountdown(uLCD);
+ //show the prompt, and listen for inputs
if(prompt == HoldFire)
{
//hold fire
@@ -51,7 +58,9 @@
Timer timer;
timer.start();
- //hold fire for 2 seconds
+ //hold fire lasts for 2 seconds
+ //if a player fires during this 2 seconds
+ //they lose a point
while(timer.read_ms() < 2000)
{
if(!P1_Left || !P1_Right)
@@ -61,7 +70,7 @@
break;
}
- //AI will never mis-fire
+ //AI will never mis-fire on hold-fire... just for simplicity's sake
if(numPlayers == 1 && (!P2_Left || !P2_Right))
{
setPoints(2, getPoints(2) - 1, uLCD);
@@ -92,11 +101,17 @@
Timer timer;
timer.start();
+
+ //these variables act as a layer of indirection between the button being pressed
+ //and the value being read by the program. This allows us to "inject" fake
+ //button presses for the AI without having to actually have a button signal
+ //be sent by the hardware
bool p1l = false, p1r = false, p2l = false, p2r = false;
//wait for button to be pressed
while(true)
{
+ //if the predetermined ai wait time has elapsed, input the AI's button press
if(numPlayers == 1 && timer.read_ms() > aiShootTime)
{
bool aiCorrect = cpu.shootAnswer(prompt);
@@ -129,7 +144,7 @@
}
else
{
- //prompt = either, just press left
+ //prompt = either, just press left since either one works for this prompt
p2l = true;
p2r = false;
}
@@ -155,6 +170,7 @@
break;
}
+ //only read p2 buttons if its a 2 player game
if(numPlayers == 2 && !P2_Left)
{
p1l = false;
@@ -174,6 +190,8 @@
}
}
+
+ //check the button presses against the prompt given. decrement points accordingly
if(p1l)
{
if(prompt == Either || prompt == Up)
@@ -228,12 +246,15 @@
}
}
+ //remove the displayed prompt. Wait 2 seconds to give the players some
+ //amount of rest time between rounds
clearPrompt(uLCD);
Thread::wait(2000);
led1 = 0;
led4 = 0;
}
+ //store the winning player in a variable so the main method can create the correct GameOver screen
if(getPoints(1) == 0)
winningPlayer = 2;
else
@@ -275,6 +296,7 @@
void Gameplay::drawGun(uLCD_4DGL &uLCD, int x, int y, bool facingRight)
{
+ //image arrays generated using a separate Java program (for ease of operating with images)
if(facingRight)
{
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};
@@ -342,7 +364,7 @@
uLCD.line(54, 108, 74, 88, LGREY);
}
-
+//Displays 3..2..1.. on screen
void Gameplay::countdown(uLCD_4DGL &uLCD)
{
uLCD.locate(5, 8);
@@ -366,11 +388,13 @@
Thread::wait(333);
}
+//clears the 3..2..1.. display
void Gameplay::clearCountdown(uLCD_4DGL &uLCD)
{
uLCD.filled_rectangle(30, 50, 98, 78, LGREY);
}
+//re-draws the score on the screen
void Gameplay::renderScore(uLCD_4DGL &uLCD)
{
uLCD.locate(3, 0);
--- a/States/Rules.cpp Mon Mar 14 03:04:08 2016 +0000
+++ b/States/Rules.cpp Mon Mar 14 16:19:47 2016 +0000
@@ -1,6 +1,11 @@
#include "States.h"
#include <algorithm>
+
+/**
+ * Displays the rules of the game to the player. The right buttons are used to scroll between instruction pages.
+ * Either of the left buttons will return back to the Startup screen.
+ */
Rules::Rules(uLCD_4DGL &uLCD, PinDetect &button0, PinDetect &button1, PinDetect &button2, PinDetect &button3)
{
uLCD.color(LGREY);
@@ -50,6 +55,7 @@
}
}
+ //check to see if user has pressed button to scroll to next page
if(!button3)
{
if(page != 0)
@@ -62,7 +68,7 @@
if(page != 2)
updateText = true;
- page = min(2, page + 1);
+ page = min(1, page + 1);
}
} while(button0 && button1); //evaluate this after rendering text so it doesn't immediately exit menu if button is down
--- a/States/Startup.cpp Mon Mar 14 03:04:08 2016 +0000
+++ b/States/Startup.cpp Mon Mar 14 16:19:47 2016 +0000
@@ -4,6 +4,8 @@
{
uLCD.cls();
+ //color array for the bird on the Mexican flag. Array generated using an external program written in Java
+ //(since C++ doesn't have built in libraries for easily reading images that I know of)
int image[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -3101112, -6512280, -9341134, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -6512280, -1, -7762349, -7038369, -4407394, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -527127, -6578073, -9341134, -7630766, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2368312, -2705590, -1, -5131122, -1, -1, -1, -1, -1, -11720171, -12704232, -11844801, -1, -1, -1, -1, -1, -1, -1, -1, -1, -6709403, -7433129, -1, -1, -1, -131589, -1, -1, -1, -1, -1, -10997993, -11720171, -7387616, -9615565, -1, -1, -1, -1, -1, -1, -1, -6512280, -9341134, -1, -3092529, -957317, -1497033, -11720171, -2565928, -11982570, -14343648, -5460820, -7387616, -11720171, -6530769, -11720171, -6135757, -1, -1, -1, -1, -1, -1721791, -1, -1, -1, -15956855, -15956855, -1, -11720171, -1, -1, -657931, -12244970, -7387616, -11720171, -7321567, -12507368, -7387616, -2972313, -1, -1, -1, -6512280, -9275340, -1, -1, -1, -12497842, -14127767, -4605511, -11720171, -7842271, -1, -6974059, -1, -6333403, -12769767, -3103898, -11456224, -11851242, -7387616, -2972313, -1, -1, -6775454, -6512280, -10049336, -1, -65794, -7685188, -14671328, -1, -9357029, -8437987, -11720171, -1, -1, -4554175, -6069707, -3762853, -11457514, -14277855, -5995691, -6267085, -9027033, -1, -6709403, -9341134, -10902329, -13581604, -1, -15956855, -7684674, -2969262, -723724, -11654634, -12572904, -13360101, -657931, -7387359, -10800096, -6069707, -12900838, -14671840, -14671840, -13360101, -4092844, -1, -8683456, -1, -5353428, -415151, -5022658, -14259346, -8013639, -473028, -12502989, -7650273, -11720171, -14671840, -3829159, -13883870, -7387616, -13884385, -7387616, -7387616, -7387616, -7387616, -7387616, -1, -6512280, -1, -415151, -1271222, -14323345, -7553345, -6783441, -3163517, -14671840, -8437729, -14671840, -2972313, -7452895, -11720171, -11194089, -14540255, -9091298, -5542615, -5542615, -9683173, -2972313, -16684984, -1, -1, -415151, -415151, -7242934, -10119532, -7553345, -1, -1, -10855846, -14671840, -10144487, -11720171, -10275040, -14606048, -7845593, -13359844, -7387616, -10733534, -7119061, -7387616, -1, -7236004, -1, -415151, -415151, -1468855, -15956855, -15956855, -14475488, -1, -7058143, -6069456, -11720171, -11720171, -2972313, -5938121, -7387616, -3629983, -2380436, -5542615, -1, -2972313, -1, -2697022, -1, -2851521, -415151, -415151, -16023163, -15956855, -11432050, -1, -6926300, -197638, -7781601, -7387616, -2972313, -7057883, -2380436, -2378882, -8699108, -11391465, -6596301, -1, -1, -6512280, -6183561, -14315334, -13581604, -1248008, -1, -15628661, -1052946, -1, -2834776, -9413339, -210371, -1, -9154260, -5542615, -1, -1, -407494, -13028309, -1, -1, -1, -1315616, -7104413, -202059, -1, -13581604, -16223577, -15956855, -685156, -535033, -1, -473028, -4280704, -723986, -1, -1, -8883410, -210371, -341179, -2380436, -1, -1, -1, -591886, -8617663, -1, -1, -13581604, -1, -15956855, -10058362, -1, -8817874, -473028, -6127546, -197638, -1, -5723023, -1, -199720, -2644400, -1, -1, -1, -1, -1, -604610, -1384775, -1, -1, -998080, -3418154, -14192789, -9928577, -6646174, -8883410, -1, -4867962, -5723023, -66052, -1, -5263998, -1, -2828616, -1, -1, -1, -1, -1120824, -8157112, -9341134, -1, -269412, -1, -15697799, -15956855, -13480372, -1, -131588, -5921678, -5723023, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -6512280, -6512280, -1, -1, -1, -1, -15956855, -683358, -543558, -1, -1, -1, -473028, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -7564715, -2307436, -1, -1, -1, -1, -1361079, -210370, -1, -1, -131588, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -210370, -8025524, -9078218, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -7038626, -5393789, -723474, -6512280, -9341134, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2771881, -460299, -9209548, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
//title
@@ -20,6 +22,10 @@
uLCD.text_string("How To Play", 4, 14, FONT_12X16, WHITE);
}
+/*
+ * Blocking method that handles all of the main menu navigation. Returns when a user selects an option.
+ * Returns the # of the option selected.
+ */
int Startup::select(uLCD_4DGL &uLCD, PinDetect &Button0, PinDetect &Button1, PinDetect &Button2, PinDetect &Button3, Music &music)
{
DigitalOut led2(LED2);
@@ -35,8 +41,11 @@
if(!Button3)
option -= 1;
- option = (option + 3) % 3; //wrap around... add 4 to avoid negative modulus
+ option = (option + 3) % 3; //wrap around... add 3 first to avoid negative modulus
+
+ //the wait(0.2) makes the buttons polled once every .2 seconds. This makes us not have to worry about
+ //debouncing, or a single button press firing multiple times, etc.
if(option == 0)
{
uLCD.filled_circle(15, 83, 5, WHITE);
@@ -61,43 +70,4 @@
} while(Button0 && Button1);
return option;
-}
-
-void Startup::scores(uLCD_4DGL &uLCD, SDFileSystem &sd)
-{
- mkdir("/sd/mydir", 0777);
- FILE *fp = fopen("/sd/mydir/highscores.txt", "r");
- if(fp == NULL) {
- error("Could not open file for read.\n");
- }
- uLCD.set_font(FONT_5X7);
- uLCD.locate(0, 3);
- uLCD.color(BLUE);
- uLCD.printf("One Player");
- uLCD.color(RED);
- uLCD.printf(" Two Player \n");
-
- int currentScore;
-
- uLCD.color(BLUE);
- for(int i = 0; i < 5; ++i)
- {
- fscanf(fp,"%d", ¤tScore);
- fgetc(fp);
- uLCD.locate(0, i+4);
- uLCD.printf(" %d: %d", i+1, currentScore);
- }
-
- uLCD.color(RED);
- for(int i = 5; i < 10; ++i)
- {
- fscanf(fp,"%d", ¤tScore);
- fgetc(fp);
- uLCD.locate(11, i-1);
- uLCD.printf(" %d: %d", i-4, currentScore);
- }
-
- uLCD.filled_rectangle(52, 24, 72, 71, WHITE);
-
- fclose(fp);
}
\ No newline at end of file
--- a/States/States.h Mon Mar 14 03:04:08 2016 +0000
+++ b/States/States.h Mon Mar 14 16:19:47 2016 +0000
@@ -5,16 +5,17 @@
#include "music.h"
#include "SDFileSystem.h"
+//this file includes the header data for all of the classes that represent the states that the game can
+//be in: namely the main menu (Startup), the Rules page, Gameplay, and Game Over
+
class Startup
{
public:
//CONSTRUCTOR
Startup(uLCD_4DGL &uLCD, PinDetect &upButton, PinDetect &downButton, PinDetect &leftButton, PinDetect &rightButton);
- //MEMBER FUNCTIONS
int select(uLCD_4DGL &uLCD, PinDetect &upButton, PinDetect &downButton, PinDetect &leftButton, PinDetect &rightButton,
Music &music);
- void scores(uLCD_4DGL &uLCD, SDFileSystem &sd);
private:
int option;
--- a/main.cpp Mon Mar 14 03:04:08 2016 +0000
+++ b/main.cpp Mon Mar 14 16:19:47 2016 +0000
@@ -67,6 +67,8 @@
}
case(SinglePlayerGame):
{
+ //after gameplay returns, we can use gameplay.getWinningPlayer() to find out who won.
+ //this gets passed to the GameOver to display the correct winner on the screen
Gameplay gameplay(uLCD, 1, P1_LeftButton, P1_RightButton, P2_LeftButton, P2_RightButton);
GameOver gameover(uLCD, P1_LeftButton, P1_RightButton, P2_LeftButton, P2_RightButton, gameplay.getWinningPlayer());
state = MainMenu;