aboutsummaryrefslogtreecommitdiff
path: root/src/gen_tiles.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gen_tiles.c')
-rw-r--r--src/gen_tiles.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/src/gen_tiles.c b/src/gen_tiles.c
index e70990e..072ac1e 100644
--- a/src/gen_tiles.c
+++ b/src/gen_tiles.c
@@ -13,22 +13,22 @@
FILE *fp;
// possible types: X T I
-char symetry[TILES] = "XTXIT";
+char symetry[TILES] = "IT";
small_t tiles[TILES][TILE_SZ] = {
{
- 0, 0, 0,
- 0, 0, 0,
- 0, 0, 0
- }, {
- 0, 1, 0,
- 1, 1, 1,
- 0, 0, 0
- }, {
- 0, 1, 0,
- 1, 1, 1,
- 0, 1, 0
- },{
+ // 0, 0, 0,
+ // 0, 0, 0,
+ // 0, 0, 0
+ // }, {
+ // 0, 1, 0,
+ // 1, 1, 1,
+ // 0, 0, 0
+ // }, {
+ // 0, 1, 0,
+ // 1, 1, 1,
+ // 0, 1, 0
+ // },{
0, 1, 0,
0, 1, 0,
0, 1, 0
@@ -40,9 +40,9 @@ small_t tiles[TILES][TILE_SZ] = {
};
small_t tiles_connections[TILES][4] = {
- { 0, 0, 0, 0 },
- { 1, 1, 1, 0 },
- { 1, 1, 1, 1 },
+ // { 0, 0, 0, 0 },
+ // { 1, 1, 1, 0 },
+ // { 1, 1, 1, 1 },
{ 1, 0, 0, 1 },
{ 1, 0, 1, 0 },
};
@@ -78,12 +78,28 @@ void rotate_connections(small_t *tc, int i, int r)
}
+void set_color(small_t *pixels, small_t *t, int x, int y, char k, char blank, char connection)
+{
+ pixels[(y * TILE_WIDTH + x)*3 + k] = (t[y * TILE_WIDTH + x] == 0) ? blank : connection;
+
+}
+
void save(small_t *t, small_t *n, int i)
{
char file_name[64] = {0};
sprintf(file_name, "files/tiles/tile_%d.ppm", i);
- save_as_ppm(file_name, t, TILE_WIDTH, TILE_HEIGHT, 1);
+
+ small_t *pixels = malloc(TILE_WIDTH * TILE_HEIGHT *3);
+ for(int y = 0; y < TILE_HEIGHT; y++)
+ for(int x = 0; x < TILE_WIDTH; x++) {
+ set_color(pixels, t, x, y, 0, 255, 0);
+ set_color(pixels, t, x, y, 1, 255, 0);
+ set_color(pixels, t, x, y, 2, 255, 255);
+ }
+
+ save_as_ppm(file_name, pixels, TILE_WIDTH, TILE_HEIGHT, 1);
+ free(pixels);
printf("Saved file: %s\n", file_name);
small_t connections = 0;