Aiming Wu
/
Flappy_Bird
Implement basic functions
Diff: Wall/Wall.cpp
- Revision:
- 0:64bd9f996099
diff -r 000000000000 -r 64bd9f996099 Wall/Wall.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Wall/Wall.cpp Fri May 03 13:05:24 2019 +0000 @@ -0,0 +1,72 @@ +#include "Wall.h" + +Wall::Wall() +{ + +} + +Wall::~Wall() +{ + +} + +void Wall::init() +{ + _a1 = 84; + _a2 = 28; + _a3 = 56; + _b1 = 0; + _b2 = 15; + _b3 = 18; + _score = 0; + _ab = new int[7]; + _ab[0] = 0; + _ab[1] = 0; + _ab[2] = 0; + _ab[3] = 0; + _ab[4] = 0; + _ab[5] = 0; + _ab[6] = 0; +} + +int* Wall::draw(N5110 &lcd) +{ + if(_a1 == 84){ + _b1 = rand() % 8 + 21; + } + if(_a2 == 84){ + _b2 = rand() % 8 + 21; + } + if(_a3 == 84){ + _b3 = rand() % 8 + 21; + } + _a1 = _a1 - 7; + _a2 = _a2 - 7; + _a3 = _a3 - 7; + lcd.drawRect(_a1,8,7,_b1-7,FILL_BLACK); + lcd.drawRect(_a1,_b1 + 15,7,33-_b1,FILL_BLACK); + lcd.drawRect(_a2,8,7,_b2-7,FILL_BLACK); + lcd.drawRect(_a2,_b2 + 15,7,33-_b2,FILL_BLACK); + lcd.drawRect(_a3,8,7,_b3-7,FILL_BLACK); + lcd.drawRect(_a3,_b3 + 15,7,33-_b3,FILL_BLACK); + _ab[0] = _a1; + _ab[1] = _b1; + _ab[2] = _a2; + _ab[3] = _b2; + _ab[4] = _a3; + _ab[5] = _b3; + _ab[6] = _score; + if(_a1 == 0){ + _a1 = 84; + _score = _score + 10; + } + if(_a2 == 0){ + _a2 = 84; + _score = _score + 10; + } + if(_a3 == 0){ + _a3 = 84; + _score = _score + 10; + } + return _ab; +} \ No newline at end of file