Li Boyuan / Mbed 2 deprecated PlaneWar

Dependencies:   mbed Gamepad N5110

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers life.cpp Source File

life.cpp

00001 #include "life.h"
00002 
00003 void life::init(){
00004     _x = 0;
00005     _y = 0;
00006     _num = 4;
00007     _width = 8;
00008     _height = 7;
00009     int d[56] = {
00010         0,1,1,0,0,1,1,0,
00011         1,1,1,1,1,1,1,1,
00012         1,1,0,0,1,1,1,1,
00013         1,1,0,1,1,1,1,1,
00014         0,1,1,1,1,1,1,0,
00015         0,0,1,1,1,1,0,0,
00016         0,0,0,1,1,0,0,0
00017     };
00018     for(int i = 0; i < 56; i++){
00019         data[i] = d[i];
00020     }
00021 }
00022 void life::update(){
00023     _num = _num - 1;
00024 }
00025 void life::display(N5110 &lcd){
00026     for(int i = 0; i < _num; i++){
00027         int x = _x + _width*i;
00028         unsigned int width = _width;
00029         unsigned int height = _height;
00030         Bitmap p(data, height, width);
00031         p.render(lcd, x, _y);
00032     }
00033 }
00034 
00035 int life::liferest(){return _num;}