#include <stdlib.h>
typedef struct {
- Tile ***tiles;
+ Tile **tiles;
Point2i dimensions;
} Board_t;
b->dimensions.y = sizey;
b->tiles = malloc(sizet * sizeof(Tile));
+ //for(int x = 0; x < sizex; ++x){
+ // b->tiles[x] = malloc(sizey * sizeof(Tile));
+ // for(int y = 0; y < sizey; ++y){
+ // b->tiles[x][y] = tile_init(point3i(x,y,1), PLAINS);
+ // }
+ //}
for(int x = 0; x < sizex; ++x){
- b->tiles[x] = malloc(sizey * sizeof(Tile));
for(int y = 0; y < sizey; ++y){
- b->tiles[x][y] = tile_init(point3i(x,y,1), PLAINS);
+
+ b->tiles[x + (y * sizey)] =
+ tile_init(point3i(x,y,1), PLAINS);
}
}
for(int i = 0; i < bt->dimensions.x; ++i){
for(int j = 0; j < bt->dimensions.y; ++j){
- tile_cleanup(bt->tiles[i][j]);
+ tile_cleanup(bt->tiles[i + (j*bt->dimensions.y)]);
}
}
return NULL;
}
- return bt->tiles[point.x][point.y];
+ return bt->tiles[point.x + (point.y * bt->dimensions.y)];
}
Point2i loc;
Tile* sel = NULL;
- for(int i = 0; i < 5; ++i){
- for(int j = 0; j < 3; ++j){
- loc.x = i;
- loc.y = j;
+ for(int x = 0; x < 5; ++x){
+ for(int y = 0; y < 3; ++y){
+ loc.x = x;
+ loc.y = y;
sel = board_tile_at(board, loc);
if(sel == NULL){
printf("N");