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:
- 26:6a1476a0bba9
- Parent:
- 22:c1e1283c6356
- Child:
- 27:eab2cf10554e
diff -r f433f8d8698e -r 6a1476a0bba9 main.cpp
--- a/main.cpp Mon Apr 30 01:14:21 2018 +0000
+++ b/main.cpp Mon Apr 30 19:12:41 2018 +0000
@@ -1,4 +1,4 @@
- #include "mbed.h"
+#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "rect.h"
@@ -11,12 +11,8 @@
DigitalOut gpo(D0);
DigitalOut led(LED_RED);
-
-
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
-
Gamepad pad;
-
engine engine;
help help11;
@@ -24,58 +20,55 @@
void init();
void welcome();
void render();
+void draw(N5110 &lcd);
int main()
{
-init();
-do{
- engine.start(pad,lcd);
- }
- while(pad.check_event(Gamepad::START_PRESSED) == false);
+ init();
+ draw(lcd);
while(1){
- engine.read_input(pad);
- engine.update(pad,lcd);
- render();
- wait(0.1);
- }
+ engine.read_input(pad);
+ engine.update(pad,lcd);
+ render();
+ wait(0.1);
+ }
}
-
+
+void draw(N5110 &lcd)
+{
+ lcd.clear();
+ lcd.printString(" Boom",0,0);
+ lcd.printString(" Start",0,2);
+ lcd.printString(" Help",0,4);
+ help11.draw_arrow(lcd);
+ lcd.refresh();
+ while(pad.check_event(Gamepad::Y_PRESSED) == true);
+
+ //press START to start game
+ do{
+ engine.start(pad,lcd);
+ }
+ while(pad.check_event(Gamepad::START_PRESSED) == false);
+}
+
+
void init()
{
- //initialise LCD and Gamepad
- lcd.init();
- pad.init();
-
-
+ //initialise LCD and Gamepad
+ lcd.init();
+ pad.init();
}
-/*
-void welcome() {
-
- lcd.printString(" Boom",0,0);
- lcd.printString(" Press start",0,2);
- lcd.printString(" help",0,4);
- //lcd.printString(" Press Start ",0,4);
- lcd.refresh();
-
- //LEDs keep flashing until start button is pressed
- while ( pad.check_event(Gamepad::START_PRESSED) == false) {
- pad.leds_on();
- wait(0.1);
- pad.leds_off();
- wait(0.1);
- }
- }
- */
+
void render()
{
- // clear screen, re-draw and refresh
- lcd.clear();
- engine.draw(lcd);
- lcd.refresh();
+ // clear screen, re-draw and refresh
+ lcd.clear();
+ engine.draw(lcd);
+ lcd.refresh();
}