ELEC2645 (2018/19) / Mbed 2 deprecated 2645_Project_SiutingWong201186503

Dependencies:   mbed

Revision:
14:13e82f720bea
Parent:
8:97576c8761a8
--- a/Wall/Wall.cpp	Thu May 09 05:25:04 2019 +0000
+++ b/Wall/Wall.cpp	Thu May 09 06:19:58 2019 +0000
@@ -12,12 +12,12 @@
 
 void Wall::init(int x,int gap,int width,int speed) {
     
-    _x = x;  // x value on screen is fixed
-    _gap = gap;
+    _x = x; // wall x starting postion and updating position
+    _gap = gap; // gap represents the distance between the wall
     int uncertainty = rand() % (47 - _gap);
-    _height = uncertainty;  // y depends on height of screen and height of paddle
-    _width = width;
-    _speed = speed;
+    _height = uncertainty; // get random height for the wall
+    _width = width; // fixed width
+    _speed = speed; // adjuctable speed
 }
 
 void Wall::draw1(N5110 &lcd) {
@@ -26,21 +26,20 @@
 }
 
 void Wall::draw2(N5110 &lcd) {
-    lcd.drawRect(_x,(_gap + _height),_width,(HEIGHT - (_gap + _height)),FILL_BLACK);
+    lcd.drawRect(_x,(_gap + _height),_width,(HEIGHT - (_gap + _height)),FILL_BLACK); // draw the wall near the bottom
 }
 
 void Wall::update() {
-     // scale is arbitrary, could be changed in the future
-    _x -= _speed;
+    _x -= _speed; // speed is arbitrary, could be changed in the future, and the wall is shifting to left
 }
 
-void Wall::reset() {
+void Wall::reset() { // when the wall is off from the left screen, replace it back to the right side and continue the game
     _x = 149;
     int uncertainty = rand() % (47 - _gap);
     _height = uncertainty;
 }
 
-int Wall::get_x() {
+int Wall::get_x() { // get x position and wall height for collision logic function
     return _x;
 }
 int Wall::get_height() {