Programa de MIP

Dependencies:   bloques ball mbed WS2812 PixelArray tsi_sensor TSI bloque MMA8451Q

Revision:
17:0ecf3108f79e
Parent:
16:eab9a8d27969
Child:
18:fe6f0cbd51ce
Child:
19:e57116ff4c59
diff -r eab9a8d27969 -r 0ecf3108f79e main.cpp
--- a/main.cpp	Tue May 25 16:28:33 2021 +0000
+++ b/main.cpp	Tue May 25 16:59:47 2021 +0000
@@ -335,8 +335,9 @@
                 if(barra[i]==predict_Y and old_i==1){
                     found_barra=true;
                     direct_ball=!direct_ball;           
-                }
-                i++;
+                }//else{
+                    i++;
+                //}
             }
             if(found_barra){
                 if(barra[0]==predict_Y){
@@ -381,7 +382,13 @@
             while(!found_blq_j and j<Bloques.getNumBloques() ){
                 bloque temp_blq=Bloques.getBloque(j);
                 int blq_pos_Y=(temp_blq.getCoordY()+temp_blq.getSize());
-                if((blq_pos_Y>predict_Y and predict_Y>=temp_blq.getCoordY()) and temp_blq.getEnabled()){
+                int next_CoordX;
+                if(direct_ball){
+                    next_CoordX=old_i+1;
+                }else if(!direct_ball){
+                    next_CoordX=old_i-1;
+                }
+                if((blq_pos_Y>predict_Y and predict_Y>=temp_blq.getCoordY()) and temp_blq.getEnabled() and temp_blq.getCoordX()==next_CoordX){
                     found_blq_j=true;
                     direct_ball=!direct_ball;
                     angle_rebote();