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:
- 14:d0650d0de063
- Parent:
- 10:7ba63530dc04
- Child:
- 15:a080c64cf301
--- a/main.cpp Sat May 04 19:33:08 2019 +0000
+++ b/main.cpp Mon May 06 14:13:09 2019 +0000
@@ -2,8 +2,7 @@
#include "Gamepad.h"
#include "N5110.h"
#include "Game.h"
-#include "mC.h"
-
+#include "Menu.h"
struct joystick_val {
Direction dir;
@@ -13,28 +12,33 @@
Game game;
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
-mC col;
+Smiley smiley;
+Coin coin;
void init();
-void inputs(joystick_val input);
void render();
void start_screen();
+void pause_screen();
int main(){
-
+
int fps = 30;
init();
- start_screen();
+ start_screen();
render();
wait(1.0f/fps);
-
+
while (1) {
- render();
- game.dirmag(pad);
- game.movement(pad, lcd, col);
- wait(1.0f/fps);
- }
-
+ if (pad.check_event(Gamepad::BACK_PRESSED) == true){
+ pause_screen();
+ wait(1);
+ } else {
+ render();
+ game.dirmag(pad);
+ game.movement(pad,lcd);
+ wait(1.0f/fps);
+ }
+ }
}
void init(){
@@ -46,10 +50,34 @@
void render(){
lcd.clear();
game.drawSprite(lcd);
+ game.collect(smiley,coin,lcd);
lcd.refresh();
}
void start_screen(){
- lcd.printString(" | Life | ",0,0);
- lcd.printString(" Press Start to be Born ",0,0);
-}
\ No newline at end of file
+ lcd.printString("PAUSED",42,24);
+ lcd.refresh();
+
+ while ( pad.check_event(Gamepad::START_PRESSED) == false) {
+ lcd.clear();
+ lcd.drawSprite(0,0,48,84,(int *)start_01);
+ wait(1);
+ lcd.drawSprite(0,0,48,84,(int *)start_02);
+ wait(1);
+ lcd.drawSprite(0,0,48,84,(int *)start_03);
+ wait(1);
+ lcd.refresh();
+ }
+}
+
+void pause_screen(){
+ lcd.printString("PAUSED",42,24);
+ lcd.refresh();
+
+ while (pad.check_event(Gamepad::BACK_PRESSED) == true) {
+ pad.leds_on();
+ wait(0.1);
+ pad.leds_off();
+ wait(0.1);
+ }
+}