ccc

Dependencies:   mbed FXOS8700Q

Revision:
1:b34f1b9b2b62
Parent:
0:bc1d36f5f772
Child:
14:f898d37428b1
--- a/Snake/Snake.cpp	Sun May 05 14:06:00 2019 +0000
+++ b/Snake/Snake.cpp	Sun May 05 14:14:58 2019 +0000
@@ -46,7 +46,7 @@
 
 }
 
-void Snake::draw(N5110 &lcd){
+void Snake::draw(N5110 &lcd){//condition of the collasion function
         
         checkWallCollision(lcd);
         checkTailCollision(lcd);
@@ -84,13 +84,13 @@
      if (ifcondition){
     
             d=pad.get_direction();
-            printf("x+1 is %d", snek._x[_length+1]);
-            printf("y+1 is %d", snek._y[_length+1]);
-            printf("dir+1 is %d", snek._dir[_length+1]);
+            printf("x+1 is %d", snek._x[_length+2]);
+            printf("y+1 is %d", snek._y[_length+2]);
+            printf("dir+1 is %d", snek._dir[_length+2]);
             printf("length is %d", _length);
     
             bool ifcondition(snek._dir[_length-1]==1);
-            if (ifcondition)
+            if (ifcondition)//check thecconditions that snake eat the food
                 {
                     snek._x[_length]++;                    
                 }
@@ -176,7 +176,7 @@
         }
 }
 
-void Snake::deadSnake(N5110 &lcd){
+void Snake::deadSnake(N5110 &lcd){//check the condition that the life reduces
         
        
         live--; 
@@ -210,7 +210,7 @@
 
 void Snake::checkTailCollision(N5110 &lcd){
     int upperBound=_length;
-    for (int i=0 ;upperBound<i ;i++){
+    for (int i=0 ;upperBound<i ;i++){//check the snake crushes its nail
                     
                     bool ifcondition=(snek._x[_length-1]==snek._x[i] && snek._y[_length-1]==snek._y[i]);                      
                     if (ifcondition)