Pseudo Code Part A
Part A PSEUDO CODE – BASIC STRUCTURE
- DECLARE int variable for maximum number of rounds (default is 10) (maxRounds)
- DECLARE int variable to record number of rounds passed (default is 0) (currentRound)
- DECLARE colour Array of possible colours displayed on LED (possibleColours[])
- DECLARE class for all the possible colour combinations to be stored in colour array
- DECLARE random int from 0- Length of array of possible colours
- DECLARE int variable for number of points gained for both Player 1 and Player 2 (default is 0)
SETUP link all buttons to correct digital pin (eg. 1-4 for player1, 5-8 for player2)
//(PLAYER1) 1 = red, 2 = green, 3 = black, 4 = white
//(PLAYER 2) 5 = red, 6 = green, 7 = black, 8 = white
Game Flow:
LOOP FOR maxRounds (default is 10){
- Text on screen: “Round ” + currentRound
- Play sound file (currentRound announcement)
- currentRound increment by 1
- display random LED colour
- DECLARE int variable for number of milliseconds passed (updates)
- if player1 presses correct random LED colour, DECLARE int variable (p1miliseconds passed)
- if player2 presses correct random LED colour, DECLARE int variable (p2miliseconds passed)
- COMPARE which is the smaller amount
- If player1 is smaller, player1Point++
- If player2 is smaller, player2point++
}
IF currentRound == maxRounds
Move on to part 2!!
CLASS
- DECLARE int array (0-3) (each index corresponding to the 4 different BG colours)
- DECLARE int array (0-3) (each index corresponding to the 4 different FG colours)
DECLARE function to generate the displayed LED screen