bird

Dependencies:   mbed

structure_2/structure_2.cpp

Committer:
1013373474
Date:
2019-05-05
Revision:
2:fb9c05867677
Parent:
0:3887ebee1b37

File content as of revision 2:fb9c05867677:

#include "structure_2.h"

void structure_2::init(){
    _mm = 41;
    _pp = 71;
    _ee = 101;
    _nn = 12;
    _qq = 19;
    _oo = 17;    
    _tt = 0;
    }

void structure_2::draw(N5110 &lcd)
{    
    
   
    _nn = rand() % (20-5+1)+ 5;
    
  
    _qq = rand() % (20-5+1)+ 5;
    

    _oo = rand() % (20-5+1)+ 5;
    
    

    
    lcd.drawRect(_mm,_nn+15,5,33-_nn,FILL_BLACK);//该公式前两个点是坐标,后两个点是涂抹区域的长宽,先长后宽,障碍物中间的间隔是10
    lcd.drawRect(_mm,0,5,_nn,FILL_BLACK);//the higher
    
    lcd.drawRect(_pp,0,5,_qq,FILL_BLACK);
    lcd.drawRect(_pp,_qq+15,5,33-_qq,FILL_BLACK);
    
    lcd.drawRect(_ee,0,5,_oo,FILL_BLACK);
    lcd.drawRect(_ee,_oo+15,5,33-_oo,FILL_BLACK);    
    lcd.refresh();
    
    
    
    _mm -= 2;
    _pp -= 2;
    _ee -= 2;
  
    
    if ( _mm == 1 ){
        _mm = _ee + 30;
        }
    if ( _pp == 1 ){
        _pp = _mm + 30;
        }
    if ( _ee == 1 ){
        _ee = _pp + 30;
        }                    //xun huan
        
        
        
    if ( _mm == 31 ){
        _tt = _tt++;
        }
    if ( _pp == 31 ){
        _tt = _tt++;
        }
    if ( _ee == 31 ){
        _tt = _tt++;
        }
    if ( _mm <= 15 ){
        _nn =0 ;
        }    
        if ( _pp <= 15 ){
        _qq =0 ;
        }    
         if ( _ee <= 15 ){
        _oo =0 ;
        }    
        
        
}





Data2 structure_2::get_data2()
{
    _data2.mm = _mm;
    _data2.pp = _pp;
    _data2.ee = _ee;
    _data2.nn = _nn;
    _data2.qq = _qq;
    _data2.oo = _oo;
    _data2.tt = _tt; // 分数
    return _data2;
}