QuickClick, a reaction timing game which allows single and multiplayer mode.

Dependencies:   Controller Display N5110 Operator mbed

main.cpp

Committer:
domkay97
Date:
2017-04-14
Revision:
3:e67f9ba37049
Parent:
2:c3d86dd51b69
Child:
5:b6fcee26c5ff

File content as of revision 3:e67f9ba37049:

//Dom

#include "mbed.h"
#include "N5110.h"
#include "Display.h" 
#include "Controller.h" 
#include "Operator.h"

N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); 
Display display; 
Controller pad; 
Operator Opp; 
int button_val;
int instruction_val;
void starter();

int main() {
    button_val=0;
    lcd.init();  
    Opp.init();
    display.init(); 
    pad.init(); 
    starter(); 
        while(1) {
            instruction_val = Opp.random_instruction(display, lcd);
            display.drawCircle(lcd); 
            button_val = Opp.read_input(pad); 
            pad.leds_off();  
            if (button_val == instruction_val) {
                Opp.Correct(pad);
            } else {
                Opp.Game_Over(pad, lcd); 
                display.init();
                pad.init();
                starter(); 
        }
    }
    
}
void starter() {
  
    
    lcd.printString("Quick Click",10,1);  
    lcd.printString("Start >",24,4);
    lcd.refresh();
     
    // wait flashing LEDs until start button is pressed 
    while (pad.check_event(Controller::START_PRESSED) == false) {
        pad.leds_on();
        wait(0.1);
        pad.leds_off();
        wait(0.1);
    }
 
}