bird

Dependencies:   mbed

Committer:
1013373474
Date:
Fri May 03 17:51:38 2019 +0000
Revision:
0:3887ebee1b37
Child:
2:fb9c05867677
fly bird

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 0:3887ebee1b37 65
1013373474 0:3887ebee1b37 66
1013373474 0:3887ebee1b37 67 }
1013373474 0:3887ebee1b37 68
1013373474 0:3887ebee1b37 69
1013373474 0:3887ebee1b37 70
1013373474 0:3887ebee1b37 71
1013373474 0:3887ebee1b37 72
1013373474 0:3887ebee1b37 73 Data1 structure::get_data1()
1013373474 0:3887ebee1b37 74 {
1013373474 0:3887ebee1b37 75 _data1.m = _m;
1013373474 0:3887ebee1b37 76 _data1.p = _p;
1013373474 0:3887ebee1b37 77 _data1.e = _e;
1013373474 0:3887ebee1b37 78 _data1.n = _n;
1013373474 0:3887ebee1b37 79 _data1.q = _q;
1013373474 0:3887ebee1b37 80 _data1.o = _o;
1013373474 0:3887ebee1b37 81 _data1.t = _t; // 分数
1013373474 0:3887ebee1b37 82 return _data1;
1013373474 0:3887ebee1b37 83 }
1013373474 0:3887ebee1b37 84
1013373474 0:3887ebee1b37 85
1013373474 0:3887ebee1b37 86
1013373474 0:3887ebee1b37 87
1013373474 0:3887ebee1b37 88
1013373474 0:3887ebee1b37 89
1013373474 0:3887ebee1b37 90