Power Grid Board Game Timer. Acts like a chess timer for 3-6 people. Uses an ADXL accelerometer to pause the timer and change players. Uses an LCD screen to prompt the players for input, read that input, and change between rounds.
Dependencies: DmTouch_UniGraphic UniGraphic-forLdelaney17FinalProject mbed
game.cpp@2:e6788e73de54, 2017-01-25 (annotated)
- Committer:
- ldelaney17
- Date:
- Wed Jan 25 06:50:57 2017 +0000
- Revision:
- 2:e6788e73de54
- Child:
- 3:22c644f16365
start work on game.h and game.cpp; ; initialization of the number of players works
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ldelaney17 | 2:e6788e73de54 | 1 | #include "game.h" |
ldelaney17 | 2:e6788e73de54 | 2 | |
ldelaney17 | 2:e6788e73de54 | 3 | void game_setup(){ |
ldelaney17 | 2:e6788e73de54 | 4 | init_num_players(); |
ldelaney17 | 2:e6788e73de54 | 5 | //set_player_order(); |
ldelaney17 | 2:e6788e73de54 | 6 | } |
ldelaney17 | 2:e6788e73de54 | 7 | |
ldelaney17 | 2:e6788e73de54 | 8 | void init_num_players(){ |
ldelaney17 | 2:e6788e73de54 | 9 | prompt(6, "Select the number of players\r\n"); //sets waiting_for_touch to true |
ldelaney17 | 2:e6788e73de54 | 10 | while(waiting_for_touch == true){ //until a valid input is read, spin our wheels here |
ldelaney17 | 2:e6788e73de54 | 11 | wait(0.1); // can busy wait during setup |
ldelaney17 | 2:e6788e73de54 | 12 | } |
ldelaney17 | 2:e6788e73de54 | 13 | num_players = prompt_input_val; // set based on the circle touched |
ldelaney17 | 2:e6788e73de54 | 14 | stringstream ss; |
ldelaney17 | 2:e6788e73de54 | 15 | ss << "press 1 to confirm that " << num_players << " players is correct. Press 2 to select a different number"; |
ldelaney17 | 2:e6788e73de54 | 16 | prompt(2, ss.str()); |
ldelaney17 | 2:e6788e73de54 | 17 | while(waiting_for_touch == true){ //until a valid input is read |
ldelaney17 | 2:e6788e73de54 | 18 | wait(0.1); // can busy wait during setup |
ldelaney17 | 2:e6788e73de54 | 19 | } |
ldelaney17 | 2:e6788e73de54 | 20 | int choice = prompt_input_val; |
ldelaney17 | 2:e6788e73de54 | 21 | switch(choice){ |
ldelaney17 | 2:e6788e73de54 | 22 | case 1: |
ldelaney17 | 2:e6788e73de54 | 23 | return; |
ldelaney17 | 2:e6788e73de54 | 24 | break; |
ldelaney17 | 2:e6788e73de54 | 25 | case 2: |
ldelaney17 | 2:e6788e73de54 | 26 | init_num_players(); |
ldelaney17 | 2:e6788e73de54 | 27 | return; |
ldelaney17 | 2:e6788e73de54 | 28 | break; |
ldelaney17 | 2:e6788e73de54 | 29 | } |
ldelaney17 | 2:e6788e73de54 | 30 | } |
ldelaney17 | 2:e6788e73de54 | 31 | |
ldelaney17 | 2:e6788e73de54 | 32 | //myLCD.fillrect(160,130,200,240,Blue); |
ldelaney17 | 2:e6788e73de54 | 33 |