ELEC2645 (2018/19) / Mbed 2 deprecated EL17MCD

Dependencies:   mbed

Revision:
18:165e3d49daa8
Parent:
17:cb39d9fa08dc
Child:
21:44e87d88afe2
--- a/Tank/Tank.cpp	Sat Apr 27 17:43:46 2019 +0000
+++ b/Tank/Tank.cpp	Tue Apr 30 09:30:40 2019 +0000
@@ -58,9 +58,9 @@
 }
 // Other Methods
 void Tank::move_position(int d)                // Governs how the tank moves in the horizontal
-{                                              // x direction. The speed in which moves is related
-  int slowness = 9 - _speed;                   // to framerate, therefore in order to slow its movement
-  int i = _move_counter % slowness;            // it cannot move on every frame.
+{                                              // x direction. The speed in which it moves is related
+  int slowness = 9 - _speed;                   // to framerate (wait_ms(1000/60), therefore in order to 
+  int i = _move_counter % slowness;            // slow its movement it cannot move on every frame.
   if (d > 0) {
     _move_counter++;                           // Movement counter increases if right button is pressed.
     if (i == 0 && _position_x < _right_lim) {  // i reaches zero every (slowness)number of cycles of the game loop 
@@ -80,12 +80,12 @@
 }
 
 void Tank::generate_hitbox()                                      // Generates a hitbox based on the x and y position of the 
-{
-  int i = 0;
-  for (int i0 = 0; i0 < 4; i0++) {    
-    for (int i1 = 1; i1 < 11; i1++) {
-      _hitbox[i] = (i0 + _position_y) * 84 + _position_x + i1;
-      i++;
-    }
+{                                                                 // tank's bottom left pixel. The screen is a cartesian plane
+  int i = 0;                                                      // with the bottom left of the screen representing the origin.
+  for (int i0 = 0; i0 < 4; i0++) {                                // Every pixel on the screen has a coreesponding integer value
+    for (int i1 = 1; i1 < 11; i1++) {                             // assigned to it: the pixel at (0,0) being 1 and the pixel 
+      _hitbox[i] = (i0 + _position_y) * 84 + _position_x + i1;    // (83,47) being 4032. A tank's hitbox is 10 pixels wide and
+      i++;                                                        // 4 pixels high. The tank's hitbox is described by all the pixels
+    }                                                             // in this 10x4 area inserted into an array.
   }
 }
\ No newline at end of file