test avoid bulled game
Dependencies: C12832_lcd LCD_fonts mbed mbed-rtos
Stage.cpp@22:5a7399899fe6, 2016-12-12 (annotated)
- Committer:
- th_mbed
- Date:
- Mon Dec 12 09:48:23 2016 +0000
- Revision:
- 22:5a7399899fe6
- Parent:
- 21:1911f2c4684b
- Child:
- 24:88968d1fc9cb
a
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 | 21:1911f2c4684b | 3 | #include <stdlib.h> |
th_mbed | 21:1911f2c4684b | 4 | #include <stdio.h> |
th_mbed | 12:c74115744b24 | 5 | |
th_mbed | 21:1911f2c4684b | 6 | Stage::Stage(){ |
th_mbed | 21:1911f2c4684b | 7 | length = LCD_X; |
th_mbed | 21:1911f2c4684b | 8 | for(int i = 0; i < LCD_X; i++){ |
th_mbed | 21:1911f2c4684b | 9 | stage[i] = 1; |
th_mbed | 15:400760117d9d | 10 | } |
th_mbed | 21:1911f2c4684b | 11 | srand(1); |
th_mbed | 12:c74115744b24 | 12 | } |
th_mbed | 12:c74115744b24 | 13 | |
th_mbed | 21:1911f2c4684b | 14 | int* Stage::getStage(){ |
th_mbed | 21:1911f2c4684b | 15 | if((length % ONE_STEP_SIZE) == 0){ |
th_mbed | 21:1911f2c4684b | 16 | //get new step |
th_mbed | 21:1911f2c4684b | 17 | for(int i = 0; i < LCD_X;i++){ |
th_mbed | 21:1911f2c4684b | 18 | if(i == LCD_X - 1){ |
th_mbed | 21:1911f2c4684b | 19 | //make random |
th_mbed | 22:5a7399899fe6 | 20 | int r = rand() % (LCD_Y - 5); //TODO |
th_mbed | 21:1911f2c4684b | 21 | stage[i] = r; |
th_mbed | 21:1911f2c4684b | 22 | }else{ |
th_mbed | 21:1911f2c4684b | 23 | //slide |
th_mbed | 21:1911f2c4684b | 24 | stage[i] = stage[i+1]; |
th_mbed | 21:1911f2c4684b | 25 | } |
th_mbed | 21:1911f2c4684b | 26 | } |
th_mbed | 21:1911f2c4684b | 27 | }else{ |
th_mbed | 21:1911f2c4684b | 28 | //simly slide stage |
th_mbed | 21:1911f2c4684b | 29 | for(int i = 0; i < LCD_X;i++){ |
th_mbed | 21:1911f2c4684b | 30 | if(i == LCD_X - 1){ |
th_mbed | 21:1911f2c4684b | 31 | //the same height |
th_mbed | 21:1911f2c4684b | 32 | stage[i] = stage[i-1]; |
th_mbed | 21:1911f2c4684b | 33 | }else{ |
th_mbed | 21:1911f2c4684b | 34 | //slide |
th_mbed | 21:1911f2c4684b | 35 | stage[i] = stage[i+1]; |
th_mbed | 21:1911f2c4684b | 36 | } |
th_mbed | 15:400760117d9d | 37 | } |
th_mbed | 15:400760117d9d | 38 | } |
th_mbed | 21:1911f2c4684b | 39 | length++; |
th_mbed | 21:1911f2c4684b | 40 | return stage; |
th_mbed | 15:400760117d9d | 41 | } |
th_mbed | 21:1911f2c4684b | 42 | |
th_mbed | 21:1911f2c4684b | 43 | int Stage::getLength(){ |
th_mbed | 21:1911f2c4684b | 44 | return length; |
th_mbed | 12:c74115744b24 | 45 | } |