![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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.h@5:e07903df9510, 2017-01-25 (annotated)
- Committer:
- ldelaney17
- Date:
- Wed Jan 25 16:30:13 2017 +0000
- Revision:
- 5:e07903df9510
- Parent:
- 4:e14c199c2466
publish commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ldelaney17 | 2:e6788e73de54 | 1 | #ifndef GAME_H |
ldelaney17 | 2:e6788e73de54 | 2 | #define GAME_H |
ldelaney17 | 2:e6788e73de54 | 3 | #include "mbed.h" |
ldelaney17 | 2:e6788e73de54 | 4 | #include <vector> |
ldelaney17 | 2:e6788e73de54 | 5 | #include "lcd_prompts.h" |
ldelaney17 | 2:e6788e73de54 | 6 | #include <sstream> |
ldelaney17 | 4:e14c199c2466 | 7 | #include <algorithm> //reverse |
ldelaney17 | 4:e14c199c2466 | 8 | #include "Song.h" |
ldelaney17 | 2:e6788e73de54 | 9 | |
ldelaney17 | 2:e6788e73de54 | 10 | extern int num_players; |
ldelaney17 | 2:e6788e73de54 | 11 | extern int current_player; |
ldelaney17 | 4:e14c199c2466 | 12 | extern int current_player_index; |
ldelaney17 | 2:e6788e73de54 | 13 | extern Timer current_clock; |
ldelaney17 | 4:e14c199c2466 | 14 | extern bool clock_running; |
ldelaney17 | 2:e6788e73de54 | 15 | extern vector<float> player_timers; |
ldelaney17 | 2:e6788e73de54 | 16 | extern vector<int> player_order; |
ldelaney17 | 4:e14c199c2466 | 17 | extern float bonus_time; |
ldelaney17 | 4:e14c199c2466 | 18 | extern int phase_number; |
ldelaney17 | 4:e14c199c2466 | 19 | extern int step_number; //0 = set turn order, 1 = auction power plants, 2 = buy resources, 4 - building, 5 = beauracracy |
ldelaney17 | 4:e14c199c2466 | 20 | const float time_after_warning_sound = 15; //after 15 seconds of a turn, play jeopardy |
ldelaney17 | 4:e14c199c2466 | 21 | extern Timeout time_after_warning; |
ldelaney17 | 4:e14c199c2466 | 22 | const float time_before_warning_sound = 60; //when the timer has 60 seconds left, play a scale |
ldelaney17 | 4:e14c199c2466 | 23 | extern Timeout time_before_warning; |
ldelaney17 | 4:e14c199c2466 | 24 | extern Song * jeopardy, * scale, * beep; |
ldelaney17 | 4:e14c199c2466 | 25 | extern Serial pc; |
ldelaney17 | 4:e14c199c2466 | 26 | |
ldelaney17 | 2:e6788e73de54 | 27 | void game_setup(); |
ldelaney17 | 2:e6788e73de54 | 28 | void init_num_players(); |
ldelaney17 | 3:22c644f16365 | 29 | void set_player_order(); |
ldelaney17 | 4:e14c199c2466 | 30 | void set_start_time(); //right now this has hardcoded options |
ldelaney17 | 4:e14c199c2466 | 31 | void set_bonus_time(); //right now this also has hardcoded options |
ldelaney17 | 4:e14c199c2466 | 32 | |
ldelaney17 | 4:e14c199c2466 | 33 | void next_step(); |
ldelaney17 | 4:e14c199c2466 | 34 | void reverse_player_order(); |
ldelaney17 | 4:e14c199c2466 | 35 | |
ldelaney17 | 4:e14c199c2466 | 36 | void display_timer(); |
ldelaney17 | 4:e14c199c2466 | 37 | void update_clock(); |
ldelaney17 | 4:e14c199c2466 | 38 | void update_timer(); |
ldelaney17 | 4:e14c199c2466 | 39 | void next_player(); |
ldelaney17 | 4:e14c199c2466 | 40 | void start_timer(int player_num); |
ldelaney17 | 4:e14c199c2466 | 41 | void pause_timer(); |
ldelaney17 | 4:e14c199c2466 | 42 | void unpause_timer(); |
ldelaney17 | 4:e14c199c2466 | 43 | void toggle_pause(); |
ldelaney17 | 2:e6788e73de54 | 44 | |
ldelaney17 | 2:e6788e73de54 | 45 | |
ldelaney17 | 2:e6788e73de54 | 46 | |
ldelaney17 | 2:e6788e73de54 | 47 | |
ldelaney17 | 2:e6788e73de54 | 48 | |
ldelaney17 | 2:e6788e73de54 | 49 | |
ldelaney17 | 2:e6788e73de54 | 50 | #endif |