![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
201199550 Li Boyuan PlaneWar Game on K64f
Dependencies: mbed Gamepad N5110
life.cpp@0:36c99c50e688, 2020-05-14 (annotated)
- Committer:
- LBY
- Date:
- Thu May 14 10:14:48 2020 +0000
- Revision:
- 0:36c99c50e688
From:201199550 Li Boyuan; Game name: PlaneWar
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LBY | 0:36c99c50e688 | 1 | #include "life.h" |
LBY | 0:36c99c50e688 | 2 | |
LBY | 0:36c99c50e688 | 3 | void life::init(){ |
LBY | 0:36c99c50e688 | 4 | _x = 0; |
LBY | 0:36c99c50e688 | 5 | _y = 0; |
LBY | 0:36c99c50e688 | 6 | _num = 4; |
LBY | 0:36c99c50e688 | 7 | _width = 8; |
LBY | 0:36c99c50e688 | 8 | _height = 7; |
LBY | 0:36c99c50e688 | 9 | int d[56] = { |
LBY | 0:36c99c50e688 | 10 | 0,1,1,0,0,1,1,0, |
LBY | 0:36c99c50e688 | 11 | 1,1,1,1,1,1,1,1, |
LBY | 0:36c99c50e688 | 12 | 1,1,0,0,1,1,1,1, |
LBY | 0:36c99c50e688 | 13 | 1,1,0,1,1,1,1,1, |
LBY | 0:36c99c50e688 | 14 | 0,1,1,1,1,1,1,0, |
LBY | 0:36c99c50e688 | 15 | 0,0,1,1,1,1,0,0, |
LBY | 0:36c99c50e688 | 16 | 0,0,0,1,1,0,0,0 |
LBY | 0:36c99c50e688 | 17 | }; |
LBY | 0:36c99c50e688 | 18 | for(int i = 0; i < 56; i++){ |
LBY | 0:36c99c50e688 | 19 | data[i] = d[i]; |
LBY | 0:36c99c50e688 | 20 | } |
LBY | 0:36c99c50e688 | 21 | } |
LBY | 0:36c99c50e688 | 22 | void life::update(){ |
LBY | 0:36c99c50e688 | 23 | _num = _num - 1; |
LBY | 0:36c99c50e688 | 24 | } |
LBY | 0:36c99c50e688 | 25 | void life::display(N5110 &lcd){ |
LBY | 0:36c99c50e688 | 26 | for(int i = 0; i < _num; i++){ |
LBY | 0:36c99c50e688 | 27 | int x = _x + _width*i; |
LBY | 0:36c99c50e688 | 28 | unsigned int width = _width; |
LBY | 0:36c99c50e688 | 29 | unsigned int height = _height; |
LBY | 0:36c99c50e688 | 30 | Bitmap p(data, height, width); |
LBY | 0:36c99c50e688 | 31 | p.render(lcd, x, _y); |
LBY | 0:36c99c50e688 | 32 | } |
LBY | 0:36c99c50e688 | 33 | } |
LBY | 0:36c99c50e688 | 34 | |
LBY | 0:36c99c50e688 | 35 | int life::liferest(){return _num;} |