bird

Dependencies:   mbed

structure/structure.cpp

Committer:
1013373474
Date:
2019-05-06
Revision:
6:9bf0273ee25f
Parent:
2:fb9c05867677

File content as of revision 6:9bf0273ee25f:

#include "structure.h"

void structure::init(){
    _m = 40;
    _p = 70;
    _e = 100;
    _n = 11;
    _q = 18;
    _o = 16;    
    _t = 0;
    }

void structure::draw(N5110 &lcd)
{    
    
    if ( _m == 90 ){
    _n = rand() % (20-5+1)+ 5;
    }
    if ( _p == 90 ){
    _q = rand() % (20-5+1)+ 5;
    }
    if ( _e == 90 ){
    _o = rand() % (20-5+1)+ 5;
    }

    
    lcd.drawRect(_m,_n+15,5,40-_n,FILL_BLACK);//该公式前两个点是坐标,后两个点是涂抹区域的长宽,先长后宽,障碍物中间的间隔是10
    lcd.drawRect(_m,0,5,_n,FILL_BLACK);//the higher
    
    lcd.drawRect(_p,0,5,_q,FILL_BLACK);
    lcd.drawRect(_p,_q+15,5,40-_q,FILL_BLACK);
    
    lcd.drawRect(_e,0,5,_o,FILL_BLACK);
    lcd.drawRect(_e,_o+15,5,40-_o,FILL_BLACK);    
    lcd.refresh();
    
    
    
    _m -= 2;
    _p -= 2;
    _e -= 2;
  
    
    if ( _m == 0 ){
        _m = _e + 30;
        }
    if ( _p == 0 ){
        _p = _m + 30;
        }
    if ( _e == 0 ){
        _e = _p + 30;
        }                    //xun huan
        
        
        
    if ( _m == 30 ){
        _t = _t++;
        }
    if ( _p == 30 ){
        _t = _t++;
        }
    if ( _e == 30 ){
        _t = _t++;
        }
        
    if ( _m <= 15 ){
        _n =0 ;
        }    
        if ( _p <= 15 ){
        _q =0 ;
        }    
         if ( _e <= 15 ){
        _o =0 ;
        }    
        
       
        
}





Data1 structure::get_data1()
{
    _data1.m = _m;
    _data1.p = _p;
    _data1.e = _e;
    _data1.n = _n;
    _data1.q = _q;
    _data1.o = _o;
    _data1.t = _t; // 分数
    return _data1;
}