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:
- 58:4a826093d9e9
- Parent:
- 56:8c827d1cae3b
- Child:
- 60:3df033345059
--- a/main.cpp Wed Apr 24 20:56:36 2019 +0000
+++ b/main.cpp Tue May 07 00:30:46 2019 +0000
@@ -15,6 +15,9 @@
#include "Gamepad.h"
#include "Gameengine.h"
+#ifdef WITH_TESTING
+# include "tests.h"
+#endif
/////////////// objects ///////////////
Gameengine game;
@@ -26,7 +29,7 @@
///////////// prototypes ///////////////
-/**
+/**
* @brief sets the contrast of lcd screen
* @details contrast is adjust with analog input PTB2
*/
@@ -53,6 +56,10 @@
* @details Screen will display player's final score and display game over or game complete
*/
void restart();
+/** Displays options screen
+ * @details gives player controls and displays credits
+ */
+ void option_screen();
///////////// functions ////////////////
@@ -60,7 +67,8 @@
{
init(); // initialises screen and default game settings
start_screen(); // waits for user to press start to begin
-
+ option_screen(); // displays options screen
+
// game loop, reads input and updates game accordingly
while (1) {
@@ -82,15 +90,16 @@
lcd.setBrightness(1.0);
pad.init();
game.game_init();
- contrast();
+ contrast();
}
// detects which level is being played and draws the level objects with collision settings
void render()
{
- game.draw_l1(lcd, pad); // level 1
+ game.draw_l1(lcd, pad); // level 1
game.draw_l2(lcd, pad); // level 2
game.draw_l3(lcd, pad); // level 3
+ game.draw_l4(lcd, pad); // level 4
leds(); // function to update leds to reflect time and lives left
}
@@ -105,17 +114,25 @@
// displays start screen and waits for user to press start
void start_screen()
-{
+{
lcd.drawSprite(2,20,8,3,(int *)miner_right);
lcd.drawSprite(79,20,8,3,(int *)miner_left);
lcd.drawRect(0,0,84,48, FILL_TRANSPARENT);
lcd.printString("MANIC MILNER",7,1);
- lcd.printString("Press start!",8,4);
+ lcd.printString("Press start!",8,2);
+ lcd.printString("A = Options",10,4);
lcd.refresh();
while ( pad.check_event(Gamepad::START_PRESSED) == false) {
}
}
+void option_screen()
+{
+ if (pad.check_event(Gamepad::A_PRESSED) == true)
+ lcd.printString("A = Options",10,4);
+ lcd.refresh();
+}
+
// displays appropriate screen with final score for game over and game complete
void restart()
{
@@ -139,12 +156,12 @@
// leds indicate how many lives and time left
void leds()
-{
+{
// fsm to display lives left
int l_leds[4] = {0b111,0b110,0b100,0b000};
//fsm to display how much time (oxygen) left
int r_leds[4] = {0b111,0b110,0b100,0b000};
-
+
// function keeps track of time elapsed and changes leds accordingly
oxygen = l_leds[game.oxygen_leds()];
// function keeps track of lives left and changes leds accordingly