EndGameCeremonyFor(2);
}
}
void Reset(int playerCurrentlyScored)
{
if (playerCurrentlyScored == 1)
{
digitalWrite(playerOne, 1);
currentPosition = playerOne;
willTheBallGoTowardsPlayerTwo = true;
}
else if (playerCurrentlyScored == 2)
{
digitalWrite(playerTwo, 1);
currentPosition = playerTwo;
willTheBallGoTowardsPlayerTwo = false;
}
delay(1000); //Are three seconds enough for players to process the score? ////////////
millisecondsPerLED = initialMillisecondsPerLED; //Sets speed to initial value at the beginning of each round.
deltaMillisecondsPerLED = initialDeltaMillisecondsPerLED;
}
void EndGameCeremonyFor(int winner)
{
FlashAllLEDs(50, winner);
TurnOffAllLEDsForPlayer(0);
scoreOfPlayerOne = 0;
scoreOfPlayerTwo = 0;
}
void TurnOnAllLEDsForPlayer(int player)
{
if (player != 1) //When this method is called with (2), only these pins(player two's) will turn on
{
digitalWrite(4, 1);
digitalWrite(5, 1);
digitalWrite(6, 1);
digitalWrite(7, 1);
digitalWrite(8, 1);
}
if (player != 2) //When this method is called with (1), only these pins(player one's) will turn on
{
digitalWrite(9, 1);
digitalWrite(10, 1);
digitalWrite(11, 1);
digitalWrite(12, 1);
digitalWrite(13, 1);
}
}
void TurnOffAllLEDsForPlayer(int player)
{
if (player != 1) //When this method is called with (2), only these pins(player two's) will turn off
{
digitalWrite(4, 0);
digitalWrite(5, 0);
digitalWrite(6, 0);
digitalWrite(7, 0);
digitalWrite(8, 0);
}
if (player != 2) //When this method is called with (1), only these pins(player one's) will turn off
{
digitalWrite(9, 0);
digitalWrite(10, 0);
digitalWrite(11, 0);
digitalWrite(12, 0);
digitalWrite(13, 0);
}
}
void FlashAllLEDs(int blinkCount, int player) //Second parameter(int player) is for when you want to flash only one player's LEDs. Use 1 for player one, use 2 for player two.
{
for (int i = 0; i < blinkCount; i++)
{
TurnOnAllLEDsForPlayer(player);
delay(35);
TurnOffAllLEDsForPlayer(player);
delay(35);
}
}
64