Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: life.cpp
- Revision:
- 1:48b0bf0bcda8
- Child:
- 2:cc9d8ec2e1f4
diff -r 03d005063b30 -r 48b0bf0bcda8 life.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/life.cpp Fri May 15 12:32:47 2020 +0000
@@ -0,0 +1,36 @@
+#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;}
+