ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Committer:
shahidsajid
Date:
Wed May 08 13:30:12 2019 +0000
Revision:
33:9d34ef219fff
Parent:
31:eefa1d23a843
Parent:
8:7b7e1a5b8200
Child:
34:d9099874bbc3
Fixed Documentation Errors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shahidsajid 4:55a0509c4874 1 #include "Bat.h"
shahidsajid 4:55a0509c4874 2
shahidsajid 30:43aace0fdbdf 3 //Constructor for the Bat Object
shahidsajid 4:55a0509c4874 4 Bat::Bat()
shahidsajid 4:55a0509c4874 5 {
shahidsajid 4:55a0509c4874 6
shahidsajid 4:55a0509c4874 7 }
shahidsajid 30:43aace0fdbdf 8 //Deconstructor for the Bat Object
shahidsajid 4:55a0509c4874 9 Bat::~Bat()
shahidsajid 4:55a0509c4874 10 {
shahidsajid 4:55a0509c4874 11
shahidsajid 4:55a0509c4874 12 }
shahidsajid 30:43aace0fdbdf 13 //Initialises the UX Object
shahidsajid 31:eefa1d23a843 14 void Bat::init(int width,int height)
shahidsajid 6:3e50f2cf4366 15 {
shahidsajid 30:43aace0fdbdf 16 //assigns the x and y co-ordinates for the bat to be printed to the LCD
shahidsajid 31:eefa1d23a843 17 _bat_width = width;
shahidsajid 31:eefa1d23a843 18 _bat_height = height;
shahidsajid 30:43aace0fdbdf 19
shahidsajid 30:43aace0fdbdf 20 //initialises the Bat class flags to 0
shahidsajid 31:eefa1d23a843 21 _hit_ball=0;
shahidsajid 28:d0b0a64a832d 22 _loft_ball=0;
shahidsajid 4:55a0509c4874 23 }
shahidsajid 30:43aace0fdbdf 24
shahidsajid 30:43aace0fdbdf 25 //Resets the bat flags to 0
shahidsajid 13:924891519a95 26 void Bat::reset(){
shahidsajid 31:eefa1d23a843 27 _hit_ball=0;
shahidsajid 13:924891519a95 28 _loft_ball=0;
shahidsajid 13:924891519a95 29 }
shahidsajid 30:43aace0fdbdf 30
shahidsajid 30:43aace0fdbdf 31 //Draws the bat on the LCD
shahidsajid 4:55a0509c4874 32 void Bat::draw(N5110 &lcd){
shahidsajid 4:55a0509c4874 33 lcd.drawLine(38,36,41,36,1);
shahidsajid 31:eefa1d23a843 34 lcd.drawRect(41,35,_bat_width,_bat_height,FILL_BLACK);
shahidsajid 4:55a0509c4874 35 }
shahidsajid 31:eefa1d23a843 36
shahidsajid 30:43aace0fdbdf 37 //Checks if the ball has been hit during the game play
shahidsajid 31:eefa1d23a843 38 //if true the hit ball variable is set to 1 and returned to the caller
shahidsajid 30:43aace0fdbdf 39 /* The bat passes UX as the argument because CHECK_EVENT function of the gamepad did
shahidsajid 30:43aace0fdbdf 40 did not respond when using the Gamepad object declared in the main function*/
shahidsajid 31:eefa1d23a843 41 int Bat::get_hit_ball(UX &ux){
shahidsajid 31:eefa1d23a843 42 _hit_ball=ux.get_a_pressed();
shahidsajid 30:43aace0fdbdf 43 //printf("_hitBall %i \n",_hitBall); //used for debugging to get the flag value
shahidsajid 31:eefa1d23a843 44 return _hit_ball;
shahidsajid 6:3e50f2cf4366 45 }
shahidsajid 31:eefa1d23a843 46
shahidsajid 30:43aace0fdbdf 47 //Checks if the ball has been hit during the game play
shahidsajid 30:43aace0fdbdf 48 //if true the loft ball variable is 1 and returned to the caller
shahidsajid 21:a0904159e183 49 int Bat::get_loft_ball(UX &ux){
shahidsajid 24:23fd6b451db7 50 _loft_ball=ux.get_l_pressed();
shahidsajid 31:eefa1d23a843 51 //printf("_loftBall %i \n",_loftBall); //used for debugging to
shahidsajid 13:924891519a95 52 return _loft_ball;
shahidsajid 6:3e50f2cf4366 53 }
shahidsajid 8:7b7e1a5b8200 54
shahidsajid 8:7b7e1a5b8200 55