class Coordinates{
private:
uint8_t x;
uint8_t y;
public:
void defineCoordinates(uint8_t x,uint8_t y){
this->x = x;
this->y = y;
}
uint8_t getX(){
return x;
}
uint8_t getY(){
return y;
}
};
class Tile{
private:
uint8_t value;
uint8_t bitmapType;
uint8_t bitmapNum;
Coordinates placement;
Coordinates adjacencies[4];
public:
void setValue(uint8_t newval){
value = newval;
if(newval==0){
bitmapType=0;
bitmapNum=1;
}else if(newval==1){
bitmapType=1;
bitmapNum=1;
}else if(newval==2){
bitmapType=2;
bitmapNum = 1;
}else if(newval==3){
bitmapType=0;
bitmapNum = 1;
}else if(newval==4){
bitmapType=0;
bitmapNum = 1;
}else if(newval==5){
bitmapType=3;
bitmapNum = 1;
}else if(newval==6){
bitmapType=4;
bitmapNum = 1;
}else if(newval==7){
bitmapType=5;
bitmapNum = 10;
}else if(newval==8){
bitmapType=15;
bitmapNum = 2;
}
}
void setGroupCoordinates(uint8_t grid_layout[][21],uint8_t grid_width,uint8_t grid_height,uint8_t x,uint8_t y){
placement.defineCoordinates(x,y);
uint8_t atual;
if((y-1)>=0){
atual = y-1;
} else {
atual = grid_height-1;
}
if(grid_layout[atual][x]<6){
adjacencies[0].defineCoordinates(x,atual);
} else {
adjacencies[0].defineCoordinates(0xFF,0xFF);
}
if((y+1)<grid_height){
atual = y+1;
} else {
atual = 0;
}
if(grid_layout[atual][x]<6){
adjacencies[1].defineCoordinates(x,atual);
} else {
adjacencies[1].defineCoordinates(0xFF,0xFF);
}
if((x-1)>=0){
atual = x-1;
} else {
atual = grid_width-1;
}
if(grid_layout[y][atual]<6){
adjacencies[2].defineCoordinates(atual,y);
} else {
adjacencies[2].defineCoordinates(0xFF,0xFF);
}
if((x+1)<grid_width){
atual = x+1;
} else {
atual = 0;
}
if(grid_layout[y][atual]<6){
adjacencies[3].defineCoordinates(atual,y);
} else {
adjacencies[3].defineCoordinates(0xFF,0xFF);
}
}
};
Tile tile_grid[12][21];
uint8_t tileBitmapset[17][4] = {
{
0,
0,
0,
0
},
{
0b00000000,
0b00011000,
0b00011000,
0b00000000
},
{
0b00111100,
0b01111110,
0b01111110,
0b00111100
},
{
0b00000000,
0b11111111,
0b11111111,
0b00000000
},
{
0b01111110,
0b10000001,
0b10000001,
0b01111110
},
{
0b00011000,
0b00101100,
0b00110100,
0b00011000
},
{
0b00010000,
0b00110000,
0b00010000,
0b00111000
},
{
0b00111000,
0b01000100,
0b00001000,
0b01111100
},
{
0b00111000,
0b01000100,
0b00011000,
0b01000100
},
{
0b00011000,
0b00101000,
0b01111100,
0b00001000
},
{
0b00111100,
0b00110000,
0b00001000,
0b00110000
},
{
0b00011100,
0b00110000,
0b01001000,
0b00111000
},
{
0b00111100,
0b00000100,
0b00001000,
0b00010000
},
{
0b00111000,
0b00101000,
0b00010000,
0b00101000
},
{
0b00111000,
0b00101000,
0b00011000,
0b00001000
},
{
0b00100100,
0b00100100,
0b00111100,
0b00100100
},
{
0b00111100,
0b00011000,
0b00011000,
0b00111100
}
};
void setup() {
Serial.begin(115200); // Any baud rate should work
uint8_t temporary[12][21] = {
{7,7,7,7,7,7,7,7,6,0,6,8,8,7,7,7,7,7,7,7,7},
{6,6,6,6,6,6,6,6,6,0,6,6,6,6,6,6,6,6,6,6,6},
{6,2,1,1,1,1,1,1,6,0,6,6,6,6,1,1,1,1,1,2,6},
{6,1,6,6,6,6,6,1,1,1,1,1,1,1,1,6,0,6,6,1,6},
{6,1,1,1,1,1,1,1,6,0,6,6,6,6,5,6,0,6,1,1,6},
{6,6,6,1,6,6,6,1,6,0,6,4,4,4,4,6,0,6,1,6,6},
{0,0,0,1,6,1,1,1,6,0,6,6,6,6,6,6,0,6,1,0,0},
{6,6,6,1,6,1,6,1,6,1,1,1,1,1,1,1,1,6,1,6,6},
{6,1,1,1,6,1,6,6,6,1,6,6,6,6,6,6,1,1,1,1,6},
{6,1,6,6,6,1,6,1,1,1,1,1,6,1,1,1,1,6,1,6,6},
{6,2,1,1,1,1,1,1,6,0,6,1,3,1,6,6,1,1,1,2,6},
{6,6,6,6,6,6,6,6,6,0,6,6,6,6,6,6,6,6,6,6,6},
};
for(uint8_t i = 0; i<12;i++){
for(uint8_t j = 0; j<21;j++){
tile_grid[i][j].setValue(temporary[i][j]);
tile_grid[i][j].setGroupCoordinates(temporary,21,12,j,i);
}
}
}
void loop() {
}