test avoid bulled game

Dependencies:   C12832_lcd LCD_fonts mbed mbed-rtos

Committer:
th_mbed
Date:
Mon Dec 12 08:58:36 2016 +0000
Revision:
21:1911f2c4684b
Parent:
15:400760117d9d
Child:
22:5a7399899fe6
change Stage.; return int[LCD_X] which represents height each dot

Who changed what in which revision?

UserRevisionLine numberNew 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 21:1911f2c4684b 20 int r = rand() % LCD_Y; //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 }