bird

Dependencies:   mbed

Committer:
1013373474
Date:
Mon May 06 05:02:25 2019 +0000
Revision:
6:9bf0273ee25f
Parent:
2:fb9c05867677
change the class name of structure_2.h file

Who changed what in which revision?

UserRevisionLine numberNew contents of line
1013373474 0:3887ebee1b37 1 #include "structure.h"
1013373474 0:3887ebee1b37 2
1013373474 0:3887ebee1b37 3 void structure::init(){
1013373474 0:3887ebee1b37 4 _m = 40;
1013373474 0:3887ebee1b37 5 _p = 70;
1013373474 0:3887ebee1b37 6 _e = 100;
1013373474 0:3887ebee1b37 7 _n = 11;
1013373474 0:3887ebee1b37 8 _q = 18;
1013373474 0:3887ebee1b37 9 _o = 16;
1013373474 0:3887ebee1b37 10 _t = 0;
1013373474 0:3887ebee1b37 11 }
1013373474 0:3887ebee1b37 12
1013373474 0:3887ebee1b37 13 void structure::draw(N5110 &lcd)
1013373474 0:3887ebee1b37 14 {
1013373474 0:3887ebee1b37 15
1013373474 0:3887ebee1b37 16 if ( _m == 90 ){
1013373474 0:3887ebee1b37 17 _n = rand() % (20-5+1)+ 5;
1013373474 0:3887ebee1b37 18 }
1013373474 0:3887ebee1b37 19 if ( _p == 90 ){
1013373474 0:3887ebee1b37 20 _q = rand() % (20-5+1)+ 5;
1013373474 0:3887ebee1b37 21 }
1013373474 0:3887ebee1b37 22 if ( _e == 90 ){
1013373474 0:3887ebee1b37 23 _o = rand() % (20-5+1)+ 5;
1013373474 0:3887ebee1b37 24 }
1013373474 0:3887ebee1b37 25
1013373474 0:3887ebee1b37 26
1013373474 0:3887ebee1b37 27 lcd.drawRect(_m,_n+15,5,40-_n,FILL_BLACK);//该公式前两个点是坐标,后两个点是涂抹区域的长宽,先长后宽,障碍物中间的间隔是10
1013373474 0:3887ebee1b37 28 lcd.drawRect(_m,0,5,_n,FILL_BLACK);//the higher
1013373474 0:3887ebee1b37 29
1013373474 0:3887ebee1b37 30 lcd.drawRect(_p,0,5,_q,FILL_BLACK);
1013373474 0:3887ebee1b37 31 lcd.drawRect(_p,_q+15,5,40-_q,FILL_BLACK);
1013373474 0:3887ebee1b37 32
1013373474 0:3887ebee1b37 33 lcd.drawRect(_e,0,5,_o,FILL_BLACK);
1013373474 0:3887ebee1b37 34 lcd.drawRect(_e,_o+15,5,40-_o,FILL_BLACK);
1013373474 0:3887ebee1b37 35 lcd.refresh();
1013373474 0:3887ebee1b37 36
1013373474 0:3887ebee1b37 37
1013373474 0:3887ebee1b37 38
1013373474 0:3887ebee1b37 39 _m -= 2;
1013373474 0:3887ebee1b37 40 _p -= 2;
1013373474 0:3887ebee1b37 41 _e -= 2;
1013373474 0:3887ebee1b37 42
1013373474 0:3887ebee1b37 43
1013373474 0:3887ebee1b37 44 if ( _m == 0 ){
1013373474 0:3887ebee1b37 45 _m = _e + 30;
1013373474 0:3887ebee1b37 46 }
1013373474 0:3887ebee1b37 47 if ( _p == 0 ){
1013373474 0:3887ebee1b37 48 _p = _m + 30;
1013373474 0:3887ebee1b37 49 }
1013373474 0:3887ebee1b37 50 if ( _e == 0 ){
1013373474 0:3887ebee1b37 51 _e = _p + 30;
1013373474 0:3887ebee1b37 52 } //xun huan
1013373474 0:3887ebee1b37 53
1013373474 0:3887ebee1b37 54
1013373474 0:3887ebee1b37 55
1013373474 0:3887ebee1b37 56 if ( _m == 30 ){
1013373474 0:3887ebee1b37 57 _t = _t++;
1013373474 0:3887ebee1b37 58 }
1013373474 0:3887ebee1b37 59 if ( _p == 30 ){
1013373474 0:3887ebee1b37 60 _t = _t++;
1013373474 0:3887ebee1b37 61 }
1013373474 0:3887ebee1b37 62 if ( _e == 30 ){
1013373474 0:3887ebee1b37 63 _t = _t++;
1013373474 0:3887ebee1b37 64 }
1013373474 2:fb9c05867677 65
1013373474 2:fb9c05867677 66 if ( _m <= 15 ){
1013373474 2:fb9c05867677 67 _n =0 ;
1013373474 2:fb9c05867677 68 }
1013373474 2:fb9c05867677 69 if ( _p <= 15 ){
1013373474 2:fb9c05867677 70 _q =0 ;
1013373474 2:fb9c05867677 71 }
1013373474 2:fb9c05867677 72 if ( _e <= 15 ){
1013373474 2:fb9c05867677 73 _o =0 ;
1013373474 2:fb9c05867677 74 }
1013373474 2:fb9c05867677 75
1013373474 2:fb9c05867677 76
1013373474 0:3887ebee1b37 77
1013373474 0:3887ebee1b37 78 }
1013373474 0:3887ebee1b37 79
1013373474 0:3887ebee1b37 80
1013373474 0:3887ebee1b37 81
1013373474 0:3887ebee1b37 82
1013373474 0:3887ebee1b37 83
1013373474 0:3887ebee1b37 84 Data1 structure::get_data1()
1013373474 0:3887ebee1b37 85 {
1013373474 0:3887ebee1b37 86 _data1.m = _m;
1013373474 0:3887ebee1b37 87 _data1.p = _p;
1013373474 0:3887ebee1b37 88 _data1.e = _e;
1013373474 0:3887ebee1b37 89 _data1.n = _n;
1013373474 0:3887ebee1b37 90 _data1.q = _q;
1013373474 0:3887ebee1b37 91 _data1.o = _o;
1013373474 0:3887ebee1b37 92 _data1.t = _t; // 分数
1013373474 0:3887ebee1b37 93 return _data1;
1013373474 0:3887ebee1b37 94 }
1013373474 0:3887ebee1b37 95
1013373474 0:3887ebee1b37 96
1013373474 0:3887ebee1b37 97
1013373474 0:3887ebee1b37 98
1013373474 0:3887ebee1b37 99
1013373474 0:3887ebee1b37 100
1013373474 0:3887ebee1b37 101