Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 41:0cf320f73424
- Parent:
- 37:4d525a37d5d2
- Child:
- 42:d81c008b0436
--- a/main.cpp Mon Apr 15 02:01:41 2019 +0000 +++ b/main.cpp Tue Apr 16 02:01:53 2019 +0000 @@ -10,9 +10,13 @@ N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); AnalogIn pot0(PTB2); +BusOut oxygen(PTA1, PTA2, PTC2); +BusOut lives(PTC3, PTC4, PTD3); + void contrast(); void init(); void start_screen(); +void leds(); void render(); void restart(); void button_a(); @@ -22,13 +26,17 @@ init(); start_screen(); + while (1) { - + contrast(); render(); game.update(lcd, pad); restart(); wait(0.1); + + + } } @@ -37,17 +45,19 @@ { lcd.init(); lcd.normalMode(); // normal colour mode - lcd.setBrightness(0.5); // put LED backlight on 50% lcd.refresh(); + lcd.setBrightness(1.0); pad.init(); - pad.leds_off(); + //pad.leds_off(); contrast(); game.game_init(); } void render() { - game.draw(lcd, pad); + game.draw_l1(lcd, pad); + game.draw_l2(lcd, pad); + leds(); } void contrast() @@ -60,14 +70,10 @@ void start_screen() { - lcd.printString("*MANIC MILNER!*",0,1); + lcd.printString("*MANIC MILNER*",0,1); lcd.printString(" Press start! ",0,4); lcd.refresh(); while ( pad.check_event(Gamepad::START_PRESSED) == false) { - pad.leds_on(); - wait(0.1); - pad.leds_off(); - wait(0.1); } } @@ -75,9 +81,20 @@ { if (game.game_over() == true) { lcd.clear(); - lcd.printString("Game Over! ",16,1); - lcd.printString("Press reset to try again! ",0,3); - lcd.printString("try again! ",16,4); + game.get_score(lcd); + lcd.printString("Game Over! ",12,0); + lcd.printString("Score ",4,2); + lcd.printString("Press reset to try again! ",0,4); + lcd.printString("try again! ",16,5); wait(1); } +} + +void leds() +{ + int l_leds[4] = {0b111,0b110,0b100,0b000}; + int r_leds[4] = {0b111,0b110,0b100,0b000}; + + oxygen = l_leds[game.oxygen_leds()]; + lives = r_leds[game.lives_leds()]; } \ No newline at end of file