ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ikenna1
Date:
Thu May 09 14:52:52 2019 +0000
Parent:
52:29772e31a620
Commit message:
Final Submission

Changed in this revision

Health/Health.h Show annotated file Show diff for this revision Revisions of this file
Lore/Lore.cpp Show annotated file Show diff for this revision Revisions of this file
Lore/Lore.h Show annotated file Show diff for this revision Revisions of this file
Menu/Menu.cpp Show annotated file Show diff for this revision Revisions of this file
RosenEngine/RosenEngine.cpp Show annotated file Show diff for this revision Revisions of this file
RosenEngine/RosenEngine.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
--- a/Health/Health.h	Thu May 09 13:22:45 2019 +0000
+++ b/Health/Health.h	Thu May 09 14:52:52 2019 +0000
@@ -75,7 +75,6 @@
     */
     void reset_shooterh(int shno);    
     
-    
 private:
 //_______________Private-Variables__________________________________________
     int _ship_health;   // the ships health
--- a/Lore/Lore.cpp	Thu May 09 13:22:45 2019 +0000
+++ b/Lore/Lore.cpp	Thu May 09 14:52:52 2019 +0000
@@ -63,6 +63,14 @@
 {
 
 }
+void Lore::help(N5110 &lcd)
+{
+    // display help
+    lcd.clear();
+    lcd.refresh();
+    ships1(lcd);
+    lcd.refresh();
+}
 void Lore::display(N5110 &lcd,int rand)
 {
     // set the output to be a random number between 0 and 6
@@ -91,7 +99,7 @@
             break;
     }
     lcd.refresh();
-    wait(10);
+    wait(3);
 
 }
 
@@ -150,6 +158,16 @@
     lcd.printString(" for certain ",2,4);
     lcd.printString("   tasks. ",2,5);
 }
+
+void Lore::ships1(N5110 &lcd)
+{
+    lcd.printString("You have a",2,0);
+    lcd.printString("choice of ",2,1);
+    lcd.printString("three ships,",2,2);
+    lcd.printString(" press a to ",2,3);
+    lcd.printString("fire weapons ",2,4); 
+}
+
 void Lore::intro(N5110 &lcd)
 {
     lcd.clear();
--- a/Lore/Lore.h	Thu May 09 13:22:45 2019 +0000
+++ b/Lore/Lore.h	Thu May 09 14:52:52 2019 +0000
@@ -51,6 +51,14 @@
     *@param &lcd address of the N5110 library used for the lcd display
     */
     void intro(N5110 &lcd);
+    /** Displays game information
+    *@param &lcd address of the N5110 library used for the lcd display
+    */
+    void help(N5110 &lcd);
+    /** Holds the info displayed in intro about game
+    *@param &lcd address of the N5110 library used for the lcd display
+    */
+    void ships1(N5110 &lcd);
 
     private:
     
--- a/Menu/Menu.cpp	Thu May 09 13:22:45 2019 +0000
+++ b/Menu/Menu.cpp	Thu May 09 14:52:52 2019 +0000
@@ -343,7 +343,7 @@
     // menu options
     lcd.printString("Play ",2,2);
     lcd.printString("Ship ",2,3);
-    lcd.printString("Menu",2,4);
+    lcd.printString("Info",2,4);
     // display ship on menu according to the ship selected
     switch (shipUsed) {
         case kestrel:
--- a/RosenEngine/RosenEngine.cpp	Thu May 09 13:22:45 2019 +0000
+++ b/RosenEngine/RosenEngine.cpp	Thu May 09 14:52:52 2019 +0000
@@ -200,6 +200,10 @@
     _menu.update(_d,_joystick);
     _menu.disp_ships(lcd);
 }
+void RosenEngine::help(N5110 &lcd)
+{
+    _lore.help(lcd);
+}
 bool RosenEngine::check_collision(int xpos1, int ypos1,int width1,int height1,int xpos2, int ypos2,int width2,int height2)
 {
     // Create arrays of all positions with appropriate height and length
--- a/RosenEngine/RosenEngine.h	Thu May 09 13:22:45 2019 +0000
+++ b/RosenEngine/RosenEngine.h	Thu May 09 14:52:52 2019 +0000
@@ -77,7 +77,7 @@
     */
     void check_health();
     /** Calulates the amount of time past in seconds 
-    *@param fps, the frames per second.
+    *@param fps the frames per second that is set
     */
     float timer(int fps);
     /** An accessor method that returns true when a player dies
@@ -110,6 +110,10 @@
     *@param width2, the width of the second object
     */
     bool check_collision1(int xpos1,int width1,int xpos2,int width2);
+    /** Displays help option
+    **@param &lcd address of the N5110 library used for the lcd display
+    */
+    void help(N5110 &lcd);
         
 private:
     //_____________________private-Methods________________________________________________________
@@ -228,33 +232,7 @@
     int _no_seekers;            // the amount of seeker
     bool _intro;                // true if intro has been shown else false     
     float _wait_time;           // amount of time before increasing difficulty
-    
 
 };
-/************STUFF TO FIX******************************
-**** add sound effects for sjield braking
-**** add passive shield regeneration
-**** work on score increase
-**** add title screen with name
-**** make it so back asks you if you are sure and ststes that you will lose all progress
-**** think of level system
-**** orion should send out pulses that stun enemy ships and absorb thier shields(use draw line)
-**** scale shields properly
-**** fix the border issue(i.e the ships clip through healthbar)
-**** make it so enemy ship spawning is random use srand
-**** add in options for lcd brightness and contrast
-**** add in cheats
-**** 
-*/
+
 #endif
-/*
-changes not commited
-*Fix game playing in background
-*Change seeker damage to 175
-*make seeker health 5
-* implement a viewing system for enemy ships
-* enemy comes from below very fast
-* if you hold a button shields come up in front but not sides
-* 
-*
-*/
--- a/main.cpp	Thu May 09 13:22:45 2019 +0000
+++ b/main.cpp	Thu May 09 14:52:52 2019 +0000
@@ -10,30 +10,26 @@
 
 #include "main.h"
 /** @file main.cpp
- *  @brief This file is designated to start the program by calling all the necessary functions in a sequential manner.
+ *  @brief Main file used to run the game using the game engine RosenEngine
  */
 
 
 //_______________functions______________________________________________________
 int main()
 {
-    #ifdef WITH_TESTING
+    // adds testing to the main file if it is declared in macros
+#ifdef WITH_TESTING
     int number_of_failures = run_all_tests();
 
     if(number_of_failures > 0) return number_of_failures;
-    #endif
-    
+#endif
+
+    // initialize game objects and engine
     init();
-    printf("Init function completed...\n");
-
     while(1) {
         welcome();
-        printf("welcome()\n");
         rosen.reset();
-        printf("reset()\n");
-        //printf("ycursor = %d",rosen.get_ycursor());
         if(rosen.get_ycursor() == 16) {
-            //  printf("get_ycursor() == 16()\n");
             while ( pad.check_event(Gamepad::BACK_PRESSED) == false && rosen.dead() == false) {
                 rosen.read_input(pad);
                 rosen.update(pad);
@@ -48,7 +44,14 @@
                 rosen.update(pad);
                 ship_select();
                 wait(1.0f/fps);
-                // printf("menu...\n");
+            }
+        }
+        if(rosen.get_ycursor() == 32) {
+            while ( pad.check_event(Gamepad::BACK_PRESSED) == false) {
+                rosen.read_input(pad);
+                rosen.update(pad);
+                display_help();
+                wait(1.0f/fps);
             }
         }
     }
@@ -78,10 +81,17 @@
     rosen.ship_select(lcd);
     rosen.get_pos();
     lcd.refresh();
-    printf("Ship Select...\n");
+    // printf("Ship Select...\n");
+}
+void display_help()
+{
+    lcd.clear();
+    rosen.get_pos();
+    rosen.help(lcd);
+    lcd.refresh();
+    // printf("Ship Select...\n");
 }
 
-// simple splash screen displayed on start-up
 void welcome()
 {
     while( pad.check_event(Gamepad::START_PRESSED) == false) {
@@ -90,5 +100,5 @@
         rosen.read_input(pad);
         lcd.refresh();
     }
-    printf("Welcome Function completed...\n");
+    // printf("Welcome Function completed...\n");
 }
\ No newline at end of file
--- a/main.h	Thu May 09 13:22:45 2019 +0000
+++ b/main.h	Thu May 09 14:52:52 2019 +0000
@@ -27,6 +27,7 @@
 void welcome();
 void render();
 void ship_select();
+void display_help();
 
 //_______________constants______________________________________________________
 int fps = 12; // Frames per second