ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Revision:
30:43aace0fdbdf
Parent:
28:d0b0a64a832d
Child:
31:eefa1d23a843
diff -r f7a2d2a755ec -r 43aace0fdbdf Bat/Bat.cpp
--- a/Bat/Bat.cpp	Tue May 07 18:38:54 2019 +0000
+++ b/Bat/Bat.cpp	Wed May 08 01:20:06 2019 +0000
@@ -1,38 +1,53 @@
 #include "Bat.h"
 
-
+//Constructor for the Bat Object
 Bat::Bat()
 {
 
 }
-
+//Deconstructor for the Bat Object
 Bat::~Bat()
 {
 
 }
+//Initialises the UX Object
 void Bat::init(int x,int y)
 {   
-    //batPad.init();
+    //assigns the x and y co-ordinates for the bat to be printed to the LCD
     _bat_x = 42;
     _bat_y = 15;
+    
+    //initialises the Bat class flags to 0
     _hitBall=0;
     _loft_ball=0;
-    
 }
+
+//Resets the bat flags to 0
 void Bat::reset(){
     _hitBall=0;
     _loft_ball=0;
 }
+
+//Draws the bat on the LCD
 void Bat::draw(N5110 &lcd){
     lcd.drawLine(38,36,41,36,1);
     lcd.drawRect(41,35,6,3,FILL_BLACK);
 }
-int Bat::get_hitBall(UX &ux){
+//Checks if the ball has been hit during the game play
+//if true the loft ball variable is 1 and returned to the caller
+/* The bat passes UX as the argument because CHECK_EVENT function of the gamepad did 
+   did not respond when using the Gamepad object declared in the main function*/
+int Bat::get_hitBall(UX &ux){ 
     _hitBall=ux.get_a_pressed();
-    printf("_hitBall %i \n",_hitBall);
-    return _hitBall;
+    //printf("_hitBall %i \n",_hitBall); //used for debugging to get the flag value
+    return _hitBall; 
 }
+//Checks if the ball has been hit during the game play
+//if true the loft ball variable is 1 and returned to the caller
 int Bat::get_loft_ball(UX &ux){
      _loft_ball=ux.get_l_pressed();
+     //printf("_loftBall %i \n",_loftBall);
     return _loft_ball;
-}
\ No newline at end of file
+}
+
+