test avoid bulled game

Dependencies:   C12832_lcd LCD_fonts mbed mbed-rtos

Revision:
21:1911f2c4684b
Parent:
15:400760117d9d
Child:
22:5a7399899fe6
diff -r 1dc1560a4902 -r 1911f2c4684b Stage.cpp
--- a/Stage.cpp	Sat Dec 10 13:13:00 2016 +0000
+++ b/Stage.cpp	Mon Dec 12 08:58:36 2016 +0000
@@ -1,41 +1,45 @@
 #include "point.h"
 #include "models.h"
+#include <stdlib.h>
+#include <stdio.h> 
 
-Stage::Stage(int v){
-    this->v = v;
-    length = STEP_NUM;
-    for(int i = 0; i < STEP_NUM; i++){
-        stage[i].x = i * ONE_STEP_SIZE;
-        stage[i].y = LCD_Y - 2; //height is 1
+Stage::Stage(){
+    length = LCD_X;
+    for(int i = 0; i < LCD_X; i++){
+        stage[i] = 1;
     }
+    srand(1);
 }
 
-point* Stage::getStage(){
-    point result[STEP_NUM];
-    for(int i = 0; i < STEP_NUM; i++){
-        int next_x = this->stage[i].x - this->v;
-        if(next_x < 0){
-            //stage fade out
-            getCircledList(stage);
-        }else{
-            //simly slide stage
-            stage[i].x = next_x;
+int* Stage::getStage(){
+    if((length % ONE_STEP_SIZE) == 0){
+        //get new step
+        for(int i = 0; i < LCD_X;i++){
+            if(i == LCD_X - 1){
+                //make random
+                int r = rand() % LCD_Y; //TODO
+                stage[i] = r;
+            }else{
+                //slide
+                stage[i] = stage[i+1];
+            }
+        }
+    }else{
+        //simly slide stage
+        for(int i = 0; i < LCD_X;i++){
+            if(i == LCD_X - 1){
+                //the same height
+                stage[i] = stage[i-1]; 
+            }else{
+                //slide
+                stage[i] = stage[i+1];
+            }
         }
     }
-    //copy stage
-    for(int i = 0;i < STEP_NUM;i++){
-        result[i] = stage[i];
-    }
-    return result;
+    length++;
+    return stage;
 }
-void Stage::getCircledList(point* s){
-    point result[STEP_NUM];
-    for(int i = 0; i < STEP_NUM;i++){
-        if(i == STEP_NUM - 1){
-            s[i].x = LCD_X;
-            s[i].y = LCD_Y - 2;
-        }else{
-            s[i] = s[i+1];
-        }
-    }
+
+int Stage::getLength(){
+    return length;
 }
\ No newline at end of file