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.
Diff: main.cpp
- Revision:
- 8:d1c04f0e4890
- Parent:
- 7:08f78909dda7
- Child:
- 9:3a0194c87afe
--- a/main.cpp Thu May 09 01:30:57 2019 +0000
+++ b/main.cpp Sat May 11 08:23:54 2019 +0000
@@ -1,5 +1,15 @@
#include "main.h"
+/*
+ELEC2645 Embedded Systems Project
+School of Electronic & Electrical Engineering
+University of Leeds
+Name: Thomas Foster
+Username: el17ttds
+Student ID Number: 201096550
+Date: 11 / 05 / 2019
+*/
+
/////////////// objects ///////////////
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
@@ -17,13 +27,14 @@
}
void init() {
- alive = true;
+ health = 3;
+ score = 0;
// initialise display and peripherals
lcd.init();
pad.init();
// initialise any in game functions (e.g: sprites)
- engine.init(MAP_WIDTH,MAP_HEIGHT,SCREEN_WIDTH,SCREEN_HEIGHT);
+ engine.init(MAP_WIDTH,MAP_HEIGHT,SCREEN_WIDTH,SCREEN_HEIGHT);
}
void welcome() {
@@ -136,32 +147,29 @@
}
void gameLoop() {
- while ( (alive == true) || (pad.check_event(Gamepad::START_PRESSED) == false) ) {
+ while ( (health > 0) && (pad.check_event(Gamepad::START_PRESSED) == false) ) {
lcd.refresh();
engine.read(pad);
- alive = engine.write(MAX_SPEED, pad);
+ engine.write(MAX_SPEED, pad, lcd);
engine.render(lcd);
+ health = engine.get_health();
+ score = engine.get_score();
wait(0.1);
}
- if (alive) {
- while (pad.check_event(Gamepad::START_PRESSED) == false) {
+ wait(0.2);
+ if (health > 0) {
+ while (pad.check_event(Gamepad::A_PRESSED) == false) {
lcd.clear();
lcd.printString(" PAUSED ", 0, 0);
+ //lcd.printString("SCORE = ", 0, 1);
+ //lcd.printString(score, 60, 1);
lcd.refresh();
wait(0.5);
- lcd.printString("Press Start", 0, 3);
- lcd.refresh();
- wait(0.2);
- lcd.printString("Press Start.", 0, 3);
+ lcd.printString("Press A", 0, 3);
lcd.refresh();
- wait(0.2);
- lcd.printString("Press Start .", 0, 3);
- lcd.refresh();
- wait(0.2);
- lcd.printString("Press Start .", 0, 3);
- lcd.refresh();
- wait(0.2);
+ wait(0.5);
}
+ gameLoop();
} else {
lcd.clear();
lcd.printString("YOU HELLA DEAD", 0, 0);