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.h
00001 #include "uLCD_4DGL.h" 00002 #include "PinDetect.h" 00003 #include <stdlib.h> 00004 #include <time.h> 00005 #include "music.h" 00006 #include "SDFileSystem.h" 00007 00008 //this file includes the header data for all of the classes that represent the states that the game can 00009 //be in: namely the main menu (Startup), the Rules page, Gameplay, and Game Over 00010 00011 class Startup 00012 { 00013 public: 00014 //CONSTRUCTOR 00015 Startup(uLCD_4DGL &uLCD, PinDetect &upButton, PinDetect &downButton, PinDetect &leftButton, PinDetect &rightButton); 00016 00017 int select(uLCD_4DGL &uLCD, PinDetect &upButton, PinDetect &downButton, PinDetect &leftButton, PinDetect &rightButton, 00018 Music &music); 00019 00020 private: 00021 int option; 00022 }; 00023 00024 class Rules 00025 { 00026 public: 00027 Rules(uLCD_4DGL &uLCD, PinDetect &upButton, PinDetect &downButton, PinDetect &leftButton, PinDetect &rightButton); 00028 }; 00029 00030 enum Prompt{HoldFire, Either, Down, Up}; 00031 00032 // 00033 class Gameplay 00034 { 00035 public: 00036 // CONSTRUCTOR 00037 Gameplay(uLCD_4DGL &uLCD, int numberOfPlayers, 00038 PinDetect &Button0, PinDetect &Button1, 00039 PinDetect &Button2, PinDetect &Button3); 00040 00041 // GET FUNCTIONS 00042 int getPoints(int player); 00043 int getWinningPlayer(); 00044 00045 // SET FUNCTIONS 00046 void setPoints(int player, int points, uLCD_4DGL &uLCD); 00047 00048 private: 00049 int *points; 00050 int numPlayers; 00051 int winningPlayer; 00052 00053 void drawGun(uLCD_4DGL &uLCD, int x, int y, bool facingRight); 00054 void displayUpArrow(uLCD_4DGL &uLCD); 00055 void displayDownArrow(uLCD_4DGL &uLCD); 00056 void displayCircle(uLCD_4DGL &uLCD); 00057 void displayXs(uLCD_4DGL &uLCD); 00058 void clearPrompt(uLCD_4DGL &uLCD); 00059 00060 void countdown(uLCD_4DGL &uLCD); 00061 void clearCountdown(uLCD_4DGL &uLCD); 00062 00063 void renderScore(uLCD_4DGL &uLCD); 00064 void resetPoints(uLCD_4DGL &uLCD); 00065 }; 00066 00067 class GameOver 00068 { 00069 public: 00070 GameOver(uLCD_4DGL &uLCD, PinDetect &Button0, PinDetect &Button1, 00071 PinDetect &Button2, PinDetect &Button3, 00072 int winningPlayer); 00073 }; 00074 00075 class CPU 00076 { 00077 private: 00078 int difficulty; 00079 public: 00080 CPU(); 00081 CPU(int difficulty); 00082 00083 float shootTime(); 00084 bool shootAnswer(Prompt correctAnswer); 00085 };
Generated on Fri Jul 22 2022 05:53:26 by 1.7.2