![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
201199550 Li Boyuan PlaneWar Game on K64f
Dependencies: mbed Gamepad N5110
Diff: life.cpp
- Revision:
- 0:36c99c50e688
diff -r 000000000000 -r 36c99c50e688 life.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/life.cpp Thu May 14 10:14:48 2020 +0000 @@ -0,0 +1,35 @@ +#include "life.h" + +void life::init(){ + _x = 0; + _y = 0; + _num = 4; + _width = 8; + _height = 7; + int d[56] = { + 0,1,1,0,0,1,1,0, + 1,1,1,1,1,1,1,1, + 1,1,0,0,1,1,1,1, + 1,1,0,1,1,1,1,1, + 0,1,1,1,1,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,1,1,0,0,0 + }; + for(int i = 0; i < 56; i++){ + data[i] = d[i]; + } +} +void life::update(){ + _num = _num - 1; +} +void life::display(N5110 &lcd){ + for(int i = 0; i < _num; i++){ + int x = _x + _width*i; + unsigned int width = _width; + unsigned int height = _height; + Bitmap p(data, height, width); + p.render(lcd, x, _y); + } +} + +int life::liferest(){return _num;} \ No newline at end of file