Game variable is now checked on button press rather than on while loop. This is to allow for removing of points (not implemented yet) after a winner is decided.
This commit is contained in:
16
src/main.cpp
16
src/main.cpp
@@ -86,14 +86,17 @@ void setup() {
|
||||
|
||||
void loop() {
|
||||
|
||||
while (game == true) {
|
||||
while (true) {
|
||||
|
||||
while (digitalRead(B1_IN) == 1 && digitalRead(B2_IN) == 1) {
|
||||
|
||||
|
||||
}
|
||||
if (digitalRead(B1_IN) == 0) {
|
||||
while (digitalRead(B1_IN) == 0) {} // Only execute add point on button release
|
||||
while (digitalRead(B1_IN) == 0) {
|
||||
|
||||
} // Only execute add point on button release. Point removal if other button is pressed during while loop.
|
||||
if (game == true) {
|
||||
scored(score, 0);
|
||||
if (checkWin(score, 0) == 0) {
|
||||
displayOut[2] = servingChar;
|
||||
@@ -105,9 +108,13 @@ void loop() {
|
||||
}
|
||||
setDisplay(score, &matrix, displayOut);
|
||||
}
|
||||
}
|
||||
|
||||
if (digitalRead(B2_IN) == 0) {
|
||||
while (digitalRead(B2_IN) == 0) {} // Only execute add point on button release
|
||||
while (digitalRead(B2_IN) == 0) {
|
||||
|
||||
} // Only execute add point on button release. Point removal if other button is pressed during while loop.
|
||||
if (game == true) {
|
||||
scored(score, 1);
|
||||
if (checkWin(score, 1) == 0) {
|
||||
displayOut[2] = servingChar;
|
||||
@@ -118,10 +125,11 @@ void loop() {
|
||||
delay(500); // to avoid calling twice
|
||||
}
|
||||
setDisplay(score, &matrix, displayOut);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
setup();
|
||||
}
|
||||
|
||||
// put function definitions here:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user