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

Committer:
fomartin
Date:
Mon Mar 14 03:04:08 2016 +0000
Revision:
0:75716bd37804
Child:
1:4976bbb3376f
Mexican Standoff Prototype;

Who changed what in which revision?

UserRevisionLine numberNew 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 0:75716bd37804 8 class Startup
fomartin 0:75716bd37804 9 {
fomartin 0:75716bd37804 10 public:
fomartin 0:75716bd37804 11 //CONSTRUCTOR
fomartin 0:75716bd37804 12 Startup(uLCD_4DGL &uLCD, PinDetect &upButton, PinDetect &downButton, PinDetect &leftButton, PinDetect &rightButton);
fomartin 0:75716bd37804 13
fomartin 0:75716bd37804 14 //MEMBER FUNCTIONS
fomartin 0:75716bd37804 15 int select(uLCD_4DGL &uLCD, PinDetect &upButton, PinDetect &downButton, PinDetect &leftButton, PinDetect &rightButton,
fomartin 0:75716bd37804 16 Music &music);
fomartin 0:75716bd37804 17 void scores(uLCD_4DGL &uLCD, SDFileSystem &sd);
fomartin 0:75716bd37804 18
fomartin 0:75716bd37804 19 private:
fomartin 0:75716bd37804 20 int option;
fomartin 0:75716bd37804 21 };
fomartin 0:75716bd37804 22
fomartin 0:75716bd37804 23 class Rules
fomartin 0:75716bd37804 24 {
fomartin 0:75716bd37804 25 public:
fomartin 0:75716bd37804 26 Rules(uLCD_4DGL &uLCD, PinDetect &upButton, PinDetect &downButton, PinDetect &leftButton, PinDetect &rightButton);
fomartin 0:75716bd37804 27 };
fomartin 0:75716bd37804 28
fomartin 0:75716bd37804 29 enum Prompt{HoldFire, Either, Down, Up};
fomartin 0:75716bd37804 30
fomartin 0:75716bd37804 31 //
fomartin 0:75716bd37804 32 class Gameplay
fomartin 0:75716bd37804 33 {
fomartin 0:75716bd37804 34 public:
fomartin 0:75716bd37804 35 // CONSTRUCTOR
fomartin 0:75716bd37804 36 Gameplay(uLCD_4DGL &uLCD, int numberOfPlayers,
fomartin 0:75716bd37804 37 PinDetect &Button0, PinDetect &Button1,
fomartin 0:75716bd37804 38 PinDetect &Button2, PinDetect &Button3);
fomartin 0:75716bd37804 39
fomartin 0:75716bd37804 40 // GET FUNCTIONS
fomartin 0:75716bd37804 41 int getPoints(int player);
fomartin 0:75716bd37804 42 int getWinningPlayer();
fomartin 0:75716bd37804 43
fomartin 0:75716bd37804 44 // SET FUNCTIONS
fomartin 0:75716bd37804 45 void setPoints(int player, int points, uLCD_4DGL &uLCD);
fomartin 0:75716bd37804 46
fomartin 0:75716bd37804 47 private:
fomartin 0:75716bd37804 48 int *points;
fomartin 0:75716bd37804 49 int numPlayers;
fomartin 0:75716bd37804 50 int winningPlayer;
fomartin 0:75716bd37804 51
fomartin 0:75716bd37804 52 void drawGun(uLCD_4DGL &uLCD, int x, int y, bool facingRight);
fomartin 0:75716bd37804 53 void displayUpArrow(uLCD_4DGL &uLCD);
fomartin 0:75716bd37804 54 void displayDownArrow(uLCD_4DGL &uLCD);
fomartin 0:75716bd37804 55 void displayCircle(uLCD_4DGL &uLCD);
fomartin 0:75716bd37804 56 void displayXs(uLCD_4DGL &uLCD);
fomartin 0:75716bd37804 57 void clearPrompt(uLCD_4DGL &uLCD);
fomartin 0:75716bd37804 58
fomartin 0:75716bd37804 59 void countdown(uLCD_4DGL &uLCD);
fomartin 0:75716bd37804 60 void clearCountdown(uLCD_4DGL &uLCD);
fomartin 0:75716bd37804 61
fomartin 0:75716bd37804 62 void renderScore(uLCD_4DGL &uLCD);
fomartin 0:75716bd37804 63 void resetPoints(uLCD_4DGL &uLCD);
fomartin 0:75716bd37804 64 };
fomartin 0:75716bd37804 65
fomartin 0:75716bd37804 66 class GameOver
fomartin 0:75716bd37804 67 {
fomartin 0:75716bd37804 68 public:
fomartin 0:75716bd37804 69 GameOver(uLCD_4DGL &uLCD, PinDetect &Button0, PinDetect &Button1,
fomartin 0:75716bd37804 70 PinDetect &Button2, PinDetect &Button3,
fomartin 0:75716bd37804 71 int winningPlayer);
fomartin 0:75716bd37804 72 };
fomartin 0:75716bd37804 73
fomartin 0:75716bd37804 74 class CPU
fomartin 0:75716bd37804 75 {
fomartin 0:75716bd37804 76 private:
fomartin 0:75716bd37804 77 int difficulty;
fomartin 0:75716bd37804 78 public:
fomartin 0:75716bd37804 79 CPU();
fomartin 0:75716bd37804 80 CPU(int difficulty);
fomartin 0:75716bd37804 81
fomartin 0:75716bd37804 82 float shootTime();
fomartin 0:75716bd37804 83 bool shootAnswer(Prompt correctAnswer);
fomartin 0:75716bd37804 84 };