ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_ll16j23s

Dependencies:   mbed ll16j23s_test_docs

Revision:
13:7b7ec5db56b2
Parent:
10:a2d643b3c782
Child:
14:2dfe04ced21c
--- a/SnakeEngine/SnakeEngine.cpp	Tue May 26 23:57:47 2020 +0000
+++ b/SnakeEngine/SnakeEngine.cpp	Wed May 27 00:59:14 2020 +0000
@@ -42,7 +42,7 @@
 } 
 
 void SnakeEngine::snake_food_collision(Gamepad &pad, N5110 &lcd) {
-    if (_food._x == _body._x_head && _food._y == _body._y_head){ //if coords of food and head match
+    if (_food.x == _body.head_x && _food.y == _body.head_y){ //if coords of food and head match
         //printf("FOOD!");
         pad.led(3,0.9); //turns on green LEDs
         pad.led(6,0.9);
@@ -75,16 +75,16 @@
 }
 
 void SnakeEngine::snake_map2_collision() { //ring map
-    if (_body._x_head < 2 || _body._x_head > 81 || _body._y_head < 2 || _body._y_head > 45){ //if snakehead coords exceed the ring coords
+    if (_body.head_x < 2 || _body.head_x > 81 || _body.head_y < 2 || _body.head_y > 45){ //if snakehead coords exceed the ring coords
         _death = true; 
     }
 }
 
 void SnakeEngine::snake_map3_collision() { //cross map
-    if ((_body._x_head == 40 || _body._x_head == 42) && (_body._y_head < 16 || _body._y_head > 30)){ 
+    if ((_body.head_x == 40 || _body.head_x == 42) && (_body.head_y < 16 || _body.head_y > 30)){ 
     //if head is at the either of the N/S walls' x coords, and above (y=18) or below (y=30), trigger death 
         _death = true; 
-    } else if ((_body._x_head < 16 || _body._x_head > 66) && (_body._y_head == 22 || _body._y_head == 24)){
+    } else if ((_body.head_x < 16 || _body.head_x > 66) && (_body.head_y == 22 || _body.head_y == 24)){
     //if head is at west of x=18 or east of x=66, and at either of the W/E wall's y coords, trigger death 
         _death = true; 
     }
@@ -92,16 +92,16 @@
 
 void SnakeEngine::snake_map4_collision() { //lanes
     _map4_location = 0;
-    if (_body._x_head == 8 || _body._x_head == 10 || _body._x_head == 40 || _body._x_head == 42 || _body._x_head == 72 || _body._x_head == 74){
+    if (_body.head_x == 8 || _body.head_x == 10 || _body.head_x == 40 || _body.head_x == 42 || _body.head_x == 72 || _body.head_x == 74){
          _map4_location += 1; //adjust tracker if x matches upper/lower walls
     } //printf("x matches upper/lower walls");
-    if (_body._y_head < 12 || _body._y_head > 34){
+    if (_body.head_y < 12 || _body.head_y > 34){
          _map4_location += 3; //adjust tracker if y matches upper/lower walls
     } //printf("y matches upper/lower walls");
-    if (_body._x_head == 24 || _body._x_head == 26 || _body._x_head == 56 || _body._x_head == 58){
+    if (_body.head_x == 24 || _body.head_x == 26 || _body.head_x == 56 || _body.head_x == 58){
          _map4_location += 2; //adjust tracker if x matches mid walls
     } //printf("x matches mid walls");
-    if (_body._y_head > 14 && _body._y_head < 32){
+    if (_body.head_y > 14 && _body.head_y < 32){
          _map4_location += 2; //adjust tracker if y matches mid walls
     } //printf("y matches mid walls");
     if (_map4_location == 4){ //tracker will only be 4 if the correct combination of arguments is triggered - ie 1+3 (upper/lower walls) or 2+2 (mid walls)