test avoid bulled game

Dependencies:   C12832_lcd LCD_fonts mbed mbed-rtos

Files at this revision

API Documentation at this revision

Comitter:
th_mbed
Date:
Mon Dec 05 12:01:14 2016 +0000
Parent:
11:cf3cf60589f4
Child:
13:70e31c1d8205
Commit message:
modify Person and add Stage.; But Stage always returns all 1 height stage.

Changed in this revision

Person.cpp Show annotated file Show diff for this revision Revisions of this file
Stage.cpp Show annotated file Show diff for this revision Revisions of this file
models.h Show annotated file Show diff for this revision Revisions of this file
--- a/Person.cpp	Mon Dec 05 08:15:53 2016 +0000
+++ b/Person.cpp	Mon Dec 05 12:01:14 2016 +0000
@@ -8,7 +8,8 @@
     jump_time = 0;
 }
 
-point Person::update(int height){
+point Person::update(int h){
+    int height = LCD_Y - h - 1;
     if(jump_time > 0){
         //while jumpping
         p.y -= JUMP_SIZE;
@@ -20,7 +21,7 @@
             jump_count = 0;
         }else{
             //while down
-            p.y += JUMP_SIZE
+            p.y += JUMP_SIZE;
         }
     }
     return p;
@@ -37,5 +38,5 @@
 }
 
 bool Person::isGround(int height){
-    return height == p.y;
+    return height == (p.y + HERSON_SIZE - 1);
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Stage.cpp	Mon Dec 05 12:01:14 2016 +0000
@@ -0,0 +1,16 @@
+#include "point.h"
+#include "models.h"
+
+Stage::Stage(int v){
+    this->v = v;
+    length = STEP_NUM;
+    for(int i = 0; i < STEP_NUM; i++){
+        stage[i].x = LCD_X - i * STEP_SIZE - 1;
+        stage[i].y = 1;    
+    }    
+}
+
+Stage::getStage(point* stage){
+    stage = this->stage;
+    return stage;
+}
\ No newline at end of file
--- a/models.h	Mon Dec 05 08:15:53 2016 +0000
+++ b/models.h	Mon Dec 05 12:01:14 2016 +0000
@@ -2,7 +2,18 @@
 #ifndef models_h
 #define models_h
 
+//LCD params
+#define LCD_X 128
+#define LCD_Y 32
+
+//Stage params
+#define ONE_STEP_SIZE 15
+#define STEP_NUM LCD_X/ONE_STSGE_SIZE+1
+#define ALL_LENGTH 1000
+#define STAGE_V 1
+
 //Person params
+#define PERSON_SIZE 6 //person is 6 * 6 dots
 #define DEFAULT_X  2
 #define DEFAULT_Y  25  //31-7+1
 #define MAX_JUMP_TIME 7
@@ -39,4 +50,16 @@
     point update();
 };
 
+class Stage
+{
+private:
+    int v;
+    int length;
+    point[STEP_NUM] stage;
+public:
+    Stage(int v);
+    point* getStage(point* stage);
+};
+    
+
 #endif
\ No newline at end of file