Arturs Kozlovskis / Mbed 2 deprecated ELEC2645_Project_el18ak

Dependencies:   mbed

Revision:
10:f5b920a6a71a
Parent:
9:4b11ee1155ad
Child:
11:4722bf70b2be
--- a/My_game_clases/Objects.cpp	Fri Apr 10 08:24:48 2020 +0000
+++ b/My_game_clases/Objects.cpp	Sat Apr 18 11:50:00 2020 +0000
@@ -15,12 +15,12 @@
 
 Objects::Objects()
 {
-    _cannon_pos = 0; //sets the speed counter to 0
+    _cannon_pos = 0; //sets the cannon postion to 0
     _initial_shot_pos = 37;// sets the vertical position of the shot which is one above the cannon
-    _shot_incrementer = 1;
-    _shot_y_pos.push_back(_initial_shot_pos);
+    _shot_incrementer = 1; // default shot incrementer in y direction
+    _shot_y_pos.push_back(_initial_shot_pos); // creates the first shot(was needed here for shot function)
     _shot_x_pos.push_back(_cannon_pos + 2);
-    _radiuss = 2;
+    _radiuss = 2; // sets the initial ball radiuss
 };
 
 void Objects::draw_base(N5110 &lcd)
@@ -29,9 +29,10 @@
 };
 void Objects::cannon_position(Gamepad &pad)
 {
+    //reads the sensor
     float joy_mag = pad.get_mag();
     float joy_angle = pad.get_angle();
-
+    // checks the joystics position and determines the speed of cannon movement
     if(joy_mag < 0.5 && _cannon_pos > 1 && joy_angle > 180.0) {
         _cannon_pos += -1;
     } else if(joy_mag < 1.01 && _cannon_pos > 0 && joy_angle > 180.0) {
@@ -75,7 +76,7 @@
 void Objects::draw_ball(N5110 &lcd,int ball_x, int ball_y, int delta_r)
 {   
     lcd.drawCircle(ball_x,ball_y,_radiuss + delta_r,FILL_BLACK);
-    lcd.setPixel( ball_x,  ball_y,0);
+    //lcd.setPixel( ball_x,  ball_y,0);
 }
 
 int Objects::get_size(){
@@ -92,4 +93,7 @@
 void Objects::erase_shot(int i){
      _shot_y_pos.erase(_shot_y_pos.begin() + i);
      _shot_x_pos.erase(_shot_x_pos.begin() + i);
+}
+int Objects::get_x_cannon(){
+    return _cannon_pos;
 }
\ No newline at end of file