Adam Baker 201166301

Dependencies:   mbed Gamepad N5110

Revision:
38:51ed5820ffe5
Parent:
36:6f452777b9ce
Child:
42:0dad7c359fa5
--- a/BlockheadEngine/BlockheadEngine.cpp	Sun May 05 17:34:55 2019 +0000
+++ b/BlockheadEngine/BlockheadEngine.cpp	Mon May 06 14:08:31 2019 +0000
@@ -3,6 +3,7 @@
 #include "N5110.h"
 #include "BlockheadEngine.h"
 
+//nothing needed doing in constructor or deconstructor 
 BlockheadEngine::BlockheadEngine()
 {
 
@@ -13,42 +14,42 @@
 
 }
 
-void BlockheadEngine::init()
+void BlockheadEngine::init()                                        //intialise all variables for new game
 {
-    _runner.init();
-    _pos = _lev.init(_pos);
+    _blockhead.init();                                              //intialise variables in blockhead class
+    _pos = _lev.init(_pos);                                         //intialise variables in level class and _pos struct
     
 
 }
 
-void BlockheadEngine::continueInit()
+void BlockheadEngine::continueInit()                                //intialise all variables for continue game 
 {
-    _runner.continue_init();
-    _pos = _lev.init(_pos);
+    _blockhead.continue_init();                                     //level not intialised and x/y cordinate of blockhead differs dpending on what level you are on
+    _pos = _lev.init(_pos);                                         //initialise variables in level class and _pos struct
     
 
 }
 
-int BlockheadEngine::playgame(N5110 &lcd, Gamepad &pad)
+int BlockheadEngine::playgame(N5110 &lcd, Gamepad &pad)             //runs the game 'blockhead'
 {
-    lcd.clear();
+    lcd.clear();                                                    //clear lcd first
     
-    _level = _runner.next_level();
-    _pos = _lev.whatLevel(lcd, _level);
-    _runner.blockhead(_pos, lcd, pad);
-    _gameover = _runner.gameover_flag(pad);
+    _level = _blockhead.next_level();                               //returns what level blockhead is on
+    _pos = _lev.whatLevel(lcd, _level);                             //displays that level on lcd, as well as passes cordinates of moving platforms and spikes to _pos structs
+    _blockhead.blockhead(_pos, lcd, pad);                           //controlls blcokhead depending on position in game,
+    _gameover = _blockhead.gameover_flag(pad);                      //_gameover = 1 once blockhead dies
     
-    lcd.refresh();
+    lcd.refresh();                                                  //updates screen
 
-    return _gameover;
+    return _gameover;                                               //returns _gameover
 }
 
 int BlockheadEngine::highscore()
 {   
-    if (_level >= _highscore) {
-        _highscore = _level;
+    if (_level >= _highscore) {                                     //if level reached is higher than current highscore
+        _highscore = _level;                                        //then _highscore = _level
     }
 
-    return _highscore;
+    return _highscore;                                              //returns _highscore
 }