![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is the Mexican Standoff prototype made by Francisco Martin and Andrew Smith. Please refer to the following link for instructions on hardware hookup: https://developer.mbed.org/users/fomartin/notebook/mexican-standoff-reaction-game/
Dependencies: SDFileSystem mbed-rtos mbed wave_player 4DGL-uLCD-SE PinDetect
States/States.h@1:4976bbb3376f, 2016-03-14 (annotated)
- Committer:
- fomartin
- Date:
- Mon Mar 14 16:19:47 2016 +0000
- Revision:
- 1:4976bbb3376f
- Parent:
- 0:75716bd37804
added more comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fomartin | 0:75716bd37804 | 1 | #include "uLCD_4DGL.h" |
fomartin | 0:75716bd37804 | 2 | #include "PinDetect.h" |
fomartin | 0:75716bd37804 | 3 | #include <stdlib.h> |
fomartin | 0:75716bd37804 | 4 | #include <time.h> |
fomartin | 0:75716bd37804 | 5 | #include "music.h" |
fomartin | 0:75716bd37804 | 6 | #include "SDFileSystem.h" |
fomartin | 0:75716bd37804 | 7 | |
fomartin | 1:4976bbb3376f | 8 | //this file includes the header data for all of the classes that represent the states that the game can |
fomartin | 1:4976bbb3376f | 9 | //be in: namely the main menu (Startup), the Rules page, Gameplay, and Game Over |
fomartin | 1:4976bbb3376f | 10 | |
fomartin | 0:75716bd37804 | 11 | class Startup |
fomartin | 0:75716bd37804 | 12 | { |
fomartin | 0:75716bd37804 | 13 | public: |
fomartin | 0:75716bd37804 | 14 | //CONSTRUCTOR |
fomartin | 0:75716bd37804 | 15 | Startup(uLCD_4DGL &uLCD, PinDetect &upButton, PinDetect &downButton, PinDetect &leftButton, PinDetect &rightButton); |
fomartin | 0:75716bd37804 | 16 | |
fomartin | 0:75716bd37804 | 17 | int select(uLCD_4DGL &uLCD, PinDetect &upButton, PinDetect &downButton, PinDetect &leftButton, PinDetect &rightButton, |
fomartin | 0:75716bd37804 | 18 | Music &music); |
fomartin | 0:75716bd37804 | 19 | |
fomartin | 0:75716bd37804 | 20 | private: |
fomartin | 0:75716bd37804 | 21 | int option; |
fomartin | 0:75716bd37804 | 22 | }; |
fomartin | 0:75716bd37804 | 23 | |
fomartin | 0:75716bd37804 | 24 | class Rules |
fomartin | 0:75716bd37804 | 25 | { |
fomartin | 0:75716bd37804 | 26 | public: |
fomartin | 0:75716bd37804 | 27 | Rules(uLCD_4DGL &uLCD, PinDetect &upButton, PinDetect &downButton, PinDetect &leftButton, PinDetect &rightButton); |
fomartin | 0:75716bd37804 | 28 | }; |
fomartin | 0:75716bd37804 | 29 | |
fomartin | 0:75716bd37804 | 30 | enum Prompt{HoldFire, Either, Down, Up}; |
fomartin | 0:75716bd37804 | 31 | |
fomartin | 0:75716bd37804 | 32 | // |
fomartin | 0:75716bd37804 | 33 | class Gameplay |
fomartin | 0:75716bd37804 | 34 | { |
fomartin | 0:75716bd37804 | 35 | public: |
fomartin | 0:75716bd37804 | 36 | // CONSTRUCTOR |
fomartin | 0:75716bd37804 | 37 | Gameplay(uLCD_4DGL &uLCD, int numberOfPlayers, |
fomartin | 0:75716bd37804 | 38 | PinDetect &Button0, PinDetect &Button1, |
fomartin | 0:75716bd37804 | 39 | PinDetect &Button2, PinDetect &Button3); |
fomartin | 0:75716bd37804 | 40 | |
fomartin | 0:75716bd37804 | 41 | // GET FUNCTIONS |
fomartin | 0:75716bd37804 | 42 | int getPoints(int player); |
fomartin | 0:75716bd37804 | 43 | int getWinningPlayer(); |
fomartin | 0:75716bd37804 | 44 | |
fomartin | 0:75716bd37804 | 45 | // SET FUNCTIONS |
fomartin | 0:75716bd37804 | 46 | void setPoints(int player, int points, uLCD_4DGL &uLCD); |
fomartin | 0:75716bd37804 | 47 | |
fomartin | 0:75716bd37804 | 48 | private: |
fomartin | 0:75716bd37804 | 49 | int *points; |
fomartin | 0:75716bd37804 | 50 | int numPlayers; |
fomartin | 0:75716bd37804 | 51 | int winningPlayer; |
fomartin | 0:75716bd37804 | 52 | |
fomartin | 0:75716bd37804 | 53 | void drawGun(uLCD_4DGL &uLCD, int x, int y, bool facingRight); |
fomartin | 0:75716bd37804 | 54 | void displayUpArrow(uLCD_4DGL &uLCD); |
fomartin | 0:75716bd37804 | 55 | void displayDownArrow(uLCD_4DGL &uLCD); |
fomartin | 0:75716bd37804 | 56 | void displayCircle(uLCD_4DGL &uLCD); |
fomartin | 0:75716bd37804 | 57 | void displayXs(uLCD_4DGL &uLCD); |
fomartin | 0:75716bd37804 | 58 | void clearPrompt(uLCD_4DGL &uLCD); |
fomartin | 0:75716bd37804 | 59 | |
fomartin | 0:75716bd37804 | 60 | void countdown(uLCD_4DGL &uLCD); |
fomartin | 0:75716bd37804 | 61 | void clearCountdown(uLCD_4DGL &uLCD); |
fomartin | 0:75716bd37804 | 62 | |
fomartin | 0:75716bd37804 | 63 | void renderScore(uLCD_4DGL &uLCD); |
fomartin | 0:75716bd37804 | 64 | void resetPoints(uLCD_4DGL &uLCD); |
fomartin | 0:75716bd37804 | 65 | }; |
fomartin | 0:75716bd37804 | 66 | |
fomartin | 0:75716bd37804 | 67 | class GameOver |
fomartin | 0:75716bd37804 | 68 | { |
fomartin | 0:75716bd37804 | 69 | public: |
fomartin | 0:75716bd37804 | 70 | GameOver(uLCD_4DGL &uLCD, PinDetect &Button0, PinDetect &Button1, |
fomartin | 0:75716bd37804 | 71 | PinDetect &Button2, PinDetect &Button3, |
fomartin | 0:75716bd37804 | 72 | int winningPlayer); |
fomartin | 0:75716bd37804 | 73 | }; |
fomartin | 0:75716bd37804 | 74 | |
fomartin | 0:75716bd37804 | 75 | class CPU |
fomartin | 0:75716bd37804 | 76 | { |
fomartin | 0:75716bd37804 | 77 | private: |
fomartin | 0:75716bd37804 | 78 | int difficulty; |
fomartin | 0:75716bd37804 | 79 | public: |
fomartin | 0:75716bd37804 | 80 | CPU(); |
fomartin | 0:75716bd37804 | 81 | CPU(int difficulty); |
fomartin | 0:75716bd37804 | 82 | |
fomartin | 0:75716bd37804 | 83 | float shootTime(); |
fomartin | 0:75716bd37804 | 84 | bool shootAnswer(Prompt correctAnswer); |
fomartin | 0:75716bd37804 | 85 | }; |