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 "States.h"
fomartin 0:75716bd37804 2 #include <algorithm>
fomartin 0:75716bd37804 3
fomartin 0:75716bd37804 4 Rules::Rules(uLCD_4DGL &uLCD, PinDetect &button0, PinDetect &button1, PinDetect &button2, PinDetect &button3)
fomartin 0:75716bd37804 5 {
fomartin 0:75716bd37804 6 uLCD.color(LGREY);
fomartin 0:75716bd37804 7 uLCD.set_font_size(5, 9);
fomartin 0:75716bd37804 8
fomartin 0:75716bd37804 9 int page = 0;
fomartin 0:75716bd37804 10 bool updateText = true;
fomartin 0:75716bd37804 11
fomartin 0:75716bd37804 12
fomartin 0:75716bd37804 13 do
fomartin 0:75716bd37804 14 {
fomartin 0:75716bd37804 15 if(updateText)
fomartin 0:75716bd37804 16 {
fomartin 0:75716bd37804 17 updateText = false;
fomartin 0:75716bd37804 18
fomartin 0:75716bd37804 19 switch(page)
fomartin 0:75716bd37804 20 {
fomartin 0:75716bd37804 21 case 0:
fomartin 0:75716bd37804 22 {
fomartin 0:75716bd37804 23 uLCD.cls();
fomartin 0:75716bd37804 24 uLCD.printf(" Mexican Standoff \n");
fomartin 0:75716bd37804 25 uLCD.printf(" First player to \n");
fomartin 0:75716bd37804 26 uLCD.printf(" fire the correct \n");
fomartin 0:75716bd37804 27 uLCD.printf(" gun wins! \n");
fomartin 0:75716bd37804 28 uLCD.printf("\n");
fomartin 0:75716bd37804 29 uLCD.printf(" Learn the visual \n");
fomartin 0:75716bd37804 30 uLCD.printf(" cues! \n");
fomartin 0:75716bd37804 31 uLCD.printf("\n");
fomartin 0:75716bd37804 32 uLCD.printf("\n");
fomartin 0:75716bd37804 33 uLCD.printf(" (Page 1/2) ");
fomartin 0:75716bd37804 34 } break;
fomartin 0:75716bd37804 35
fomartin 0:75716bd37804 36 case 1:
fomartin 0:75716bd37804 37 {
fomartin 0:75716bd37804 38 uLCD.cls();
fomartin 0:75716bd37804 39 uLCD.printf(" Video: \n");
fomartin 0:75716bd37804 40 uLCD.printf(" Shoot on green. \n");
fomartin 0:75716bd37804 41 uLCD.printf(" Hold fire on red.\n");
fomartin 0:75716bd37804 42 uLCD.printf(" Arrow tells which\n");
fomartin 0:75716bd37804 43 uLCD.printf("gun to use. Circle\n");
fomartin 0:75716bd37804 44 uLCD.printf(" means use either!\n");
fomartin 0:75716bd37804 45 uLCD.printf("\n");
fomartin 0:75716bd37804 46 uLCD.printf("\n");
fomartin 0:75716bd37804 47 uLCD.printf("\n");
fomartin 0:75716bd37804 48 uLCD.printf(" (Page 2/2) ");
fomartin 0:75716bd37804 49 } break;
fomartin 0:75716bd37804 50 }
fomartin 0:75716bd37804 51 }
fomartin 0:75716bd37804 52
fomartin 0:75716bd37804 53 if(!button3)
fomartin 0:75716bd37804 54 {
fomartin 0:75716bd37804 55 if(page != 0)
fomartin 0:75716bd37804 56 updateText = true;
fomartin 0:75716bd37804 57
fomartin 0:75716bd37804 58 page = max(0, page - 1);
fomartin 0:75716bd37804 59 }
fomartin 0:75716bd37804 60 if(!button2)
fomartin 0:75716bd37804 61 {
fomartin 0:75716bd37804 62 if(page != 2)
fomartin 0:75716bd37804 63 updateText = true;
fomartin 0:75716bd37804 64
fomartin 0:75716bd37804 65 page = min(2, page + 1);
fomartin 0:75716bd37804 66 }
fomartin 0:75716bd37804 67
fomartin 0:75716bd37804 68 } while(button0 && button1); //evaluate this after rendering text so it doesn't immediately exit menu if button is down
fomartin 0:75716bd37804 69 }