// objects.h
// these are objects that can be displayed on the Arduino life screen
// to add an object, create and initialise a structure following the examples here
// add a refernece to your structure to the object table, name your object by adding to the enum list
// structure template for generic objects
typedef struct {
byte height ;
byte length ;
byte bitfield[];
} object_t, *object_ptr_t;
// definitions and initialisations for all defined objects here
struct {
byte height ;
byte length ;
byte bitfield[2];
} table = {2,4, { 0b10010000 ,
0b11110000 } };
struct {
byte height ;
byte length ;
byte bitfield[3];
} glider = {3,3, { 0b00100000 ,
0b10100000 ,
0b01100000 } };
struct {
byte height ;
byte length ;
byte bitfield[3];
} glider2 = {3,3, { 0b10100000 ,
0b11000000 ,
0b11110000 } };
struct {
byte height ;
byte length ;
byte bitfield[4];
} loaf = {4,4, { 0b01100000 ,
0b10010000 ,
0b01010000 ,
0b00100000} };
struct {
byte height ;
byte length ;
byte bitfield[3];
} ship = {3,3, { 0b11000000 ,
0b10100000 ,
0b01100000 } };
struct {
byte height ;
byte length ;
byte bitfield[4];
} behive = {4,3, { 0b01000000 ,
0b10100000 ,
0b10100000 ,
0b01000000} };
struct {
byte height ;
byte length ;
byte bitfield[1];
} blinker = {1,3, { 0b11100000 } };
struct {
byte height ;
byte length ;
byte bitfield[2];
} block = {2,2, { 0b11000000 ,
0b11000000 } };
// place all the objects in the object table
object_ptr_t objectTable[] = {
(object_ptr_t)&table,
(object_ptr_t)&glider,
(object_ptr_t)&loaf,
(object_ptr_t)&ship,
(object_ptr_t)&behive,
(object_ptr_t)&blinker,
(object_ptr_t)&block
};
#define OBJECT_COUNT (sizeof( objectTable/ sizeof(object_ptr_t)))
// enumerate all the objects, add any new objects to the end of this enum (note case difference )
// the life program references all objects using the names in this list
enum {Table,Glider,Loaf,Ship,Behive,Blinker,Block};