test avoid bulled game
Dependencies: C12832_lcd LCD_fonts mbed mbed-rtos
Stage.cpp@15:400760117d9d, 2016-12-09 (annotated)
- Committer:
- th_mbed
- Date:
- Fri Dec 09 13:28:51 2016 +0000
- Revision:
- 15:400760117d9d
- Parent:
- 13:70e31c1d8205
- Child:
- 21:1911f2c4684b
add Stage model.; But skeleton implement
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
th_mbed | 12:c74115744b24 | 1 | #include "point.h" |
th_mbed | 12:c74115744b24 | 2 | #include "models.h" |
th_mbed | 12:c74115744b24 | 3 | |
th_mbed | 12:c74115744b24 | 4 | Stage::Stage(int v){ |
th_mbed | 12:c74115744b24 | 5 | this->v = v; |
th_mbed | 12:c74115744b24 | 6 | length = STEP_NUM; |
th_mbed | 12:c74115744b24 | 7 | for(int i = 0; i < STEP_NUM; i++){ |
th_mbed | 15:400760117d9d | 8 | stage[i].x = i * ONE_STEP_SIZE; |
th_mbed | 15:400760117d9d | 9 | stage[i].y = LCD_Y - 2; //height is 1 |
th_mbed | 15:400760117d9d | 10 | } |
th_mbed | 12:c74115744b24 | 11 | } |
th_mbed | 12:c74115744b24 | 12 | |
th_mbed | 15:400760117d9d | 13 | point* Stage::getStage(){ |
th_mbed | 15:400760117d9d | 14 | point result[STEP_NUM]; |
th_mbed | 15:400760117d9d | 15 | for(int i = 0; i < STEP_NUM; i++){ |
th_mbed | 15:400760117d9d | 16 | int next_x = this->stage[i].x - this->v; |
th_mbed | 15:400760117d9d | 17 | if(next_x < 0){ |
th_mbed | 15:400760117d9d | 18 | //stage fade out |
th_mbed | 15:400760117d9d | 19 | getCircledList(stage); |
th_mbed | 15:400760117d9d | 20 | }else{ |
th_mbed | 15:400760117d9d | 21 | //simly slide stage |
th_mbed | 15:400760117d9d | 22 | stage[i].x = next_x; |
th_mbed | 15:400760117d9d | 23 | } |
th_mbed | 15:400760117d9d | 24 | } |
th_mbed | 15:400760117d9d | 25 | //copy stage |
th_mbed | 15:400760117d9d | 26 | for(int i = 0;i < STEP_NUM;i++){ |
th_mbed | 15:400760117d9d | 27 | result[i] = stage[i]; |
th_mbed | 15:400760117d9d | 28 | } |
th_mbed | 15:400760117d9d | 29 | return result; |
th_mbed | 15:400760117d9d | 30 | } |
th_mbed | 15:400760117d9d | 31 | void Stage::getCircledList(point* s){ |
th_mbed | 15:400760117d9d | 32 | point result[STEP_NUM]; |
th_mbed | 15:400760117d9d | 33 | for(int i = 0; i < STEP_NUM;i++){ |
th_mbed | 15:400760117d9d | 34 | if(i == STEP_NUM - 1){ |
th_mbed | 15:400760117d9d | 35 | s[i].x = LCD_X; |
th_mbed | 15:400760117d9d | 36 | s[i].y = LCD_Y - 2; |
th_mbed | 15:400760117d9d | 37 | }else{ |
th_mbed | 15:400760117d9d | 38 | s[i] = s[i+1]; |
th_mbed | 15:400760117d9d | 39 | } |
th_mbed | 15:400760117d9d | 40 | } |
th_mbed | 12:c74115744b24 | 41 | } |