Labyrinth of the Minotaur A simple roguelike/RPG using a nokia 5110 screen

Dependencies:   N5110 PowerControl mbed

Files at this revision

API Documentation at this revision

Comitter:
ThomasBGill
Date:
Mon May 11 12:19:13 2015 +0000
Parent:
32:99ca304085e6
Child:
34:e58c8322884d
Commit message:
Commenting started

Changed in this revision

Game.cpp Show annotated file Show diff for this revision Revisions of this file
Game.h Show annotated file Show diff for this revision Revisions of this file
--- a/Game.cpp	Sun May 10 22:25:19 2015 +0000
+++ b/Game.cpp	Mon May 11 12:19:13 2015 +0000
@@ -160,8 +160,9 @@
     wait(1.0);
 }
 
-void MainMenu()
+void Initilize()
 {
+
     score = -100;
 
     level = 0;
@@ -175,6 +176,12 @@
     //Player armour
     pa = 5; //5 to 9
 
+}
+
+void MainMenu()
+{
+    Initilize();
+
     int menu = 0;
 
     while (1) {
@@ -231,11 +238,8 @@
 
     bool bright = 1;
 
+    lcd.clear();
     while(1) {
-
-        lcd.setBrightness(bright);
-        lcd.clear();
-
         if(bright == 1) {
             lcd.printString("Backlight ON", 6, 2);
         } else {
@@ -247,9 +251,15 @@
         if (joystick.direction != Centre) {
 
             bright = !bright;
+            lcd.setBrightness(bright);
+            lcd.clear();
         }
         if (ActFlag) {
             ActFlag = 0;
+
+            bright = !bright;
+            lcd.setBrightness(bright);
+            lcd.clear();
         }
         if(StartFlag) {
 
@@ -925,7 +935,7 @@
     lcd.printString("potion inside", 0, 1);
     lcd.printString("the chest", 0, 2);
     lcd.printString("Drink (Action)", 0, 4);
-    lcd.printString("Leave (Other)", 0, 5);
+    lcd.printString("Leave (Start)", 0, 5);
     lcd.refresh();
     wait(1.0);
     Sleep();
@@ -986,7 +996,8 @@
             wait(1.0);
             Sleep();
         }
-    } else { //Leave the potion
+    }
+    if(StartFlag) { //Leave the potion
         StartFlag = 0;
         lcd.clear();
         lcd.printString("You walk away", 0, 0);
@@ -1056,9 +1067,12 @@
     while(1) {
         Sleep();
 
+        if(StartFlag) {
+            StartFlag = 0;
+            MainMenu();
+        }
         if(ActFlag) {
             ActFlag = 0;
-            MainMenu();
         }
     }
 }
--- a/Game.h	Sun May 10 22:25:19 2015 +0000
+++ b/Game.h	Mon May 11 12:19:13 2015 +0000
@@ -1,10 +1,18 @@
+/**
+@file Game.h
+@brief Header file containing the main game member functions and variables
+@brief Revision 1.0
+@author Thomas Barnaby Gill
+@date   11th May 2015
+*/
+
 #include "N5110.h"
 #include "PowerControl/PowerControl.h"
 #include "PowerControl/EthernetPowerControl.h"
 #include "WorldBuilder.h"
 #include "Graphics.h"
 
-//        vcc sce rst dc  mosi clk  led
+//vcc sce rst dc  mosi clk  led
 N5110 lcd(p7, p8, p9, p10, p11, p13, p26);
 InterruptIn Act(p27);
 InterruptIn Start(p28);
@@ -138,20 +146,80 @@
 bool BossFight = false;
 
 //Voids
+/** Semihost Powerdown
+*
+* Powers down the ethernet
+*
+*/
 int semihost_powerdown();
 
+/** Act Button Pressed
+*
+* Interrupt Service Routine for the act button 
+*
+*/
 void ActPressed();
+
+/** Start Button Pressed
+*
+* Interrupt Service Routine for the act button 
+*
+*/
 void StartPressed();
-//void DirPressed();
+
+/** Write Data to File
+*
+* Writes the highscores to the .txt file
+*
+*/
+void writeDataToFile();
 
-void writeDataToFile();
+/** Write Data to File
+*
+* Reads the highscores from the .txt file and stores the values obtained to the high score integers
+*
+*/
 void readDataFromFile();
+
+/** High Score Check
+*
+* Compares the current score with the saved high scores, arranges the scores in order and then saves the scores to the .txt file
+*
+*/
 void HighScoreCheck();
 
-void FlashScreen();
+/** Flash Screen
+*
+* Inverts and then uninverts the screen's colours
+* @param n- Number of times the screen flashes
+*
+*/
+void FlashScreen(int n);
+
+/** Draw Graphic
+*
+* Draws a 38x38 pixel image from a starting point
+* @param p- Which image to draw (0- Huge Rat, 1- Goblin, 2- Skeleton, 3- Wraith, 4- Ogre, 5- Minotaur)
+* @param x- x co-ordinate of starting position
+* @param y- y co-ordinate of starting position
+*
+*/
 void DrawGraphic(int p, int x, int y);
 
+/** Intro
+*
+* Displays the game title when the system is turned on
+*
+*/
 void Intro();
+
+/** Initilize
+*
+* Initilizes the score, level number and player health and equipment
+* 
+*
+*/
+void Initilize();
 void MainMenu();
 void Options();
 void LevelScreen();
@@ -173,4 +241,4 @@
 void Potion();
 void GameOver();
 void ScoreScreen();
-void HighScoreScreen();
+void HighScoreScreen();
\ No newline at end of file