diff options
| -rw-r--r-- | src/config.h | 8 | ||||
| -rw-r--r-- | src/gen_tiles.c | 16 | 
2 files changed, 21 insertions, 3 deletions
| diff --git a/src/config.h b/src/config.h index 8d30884..06525cb 100644 --- a/src/config.h +++ b/src/config.h @@ -2,6 +2,14 @@  // want to use the tileset defined in the TILESET_NAME directive  // #define GENERATE_PPM_TILES +#ifdef GENERATE_PPM_TILES +    int generated_tile_colors[2][3] = { +        { 211, 211, 211 }, // blank     | default 255 +        { 30,  144, 155 }  // not blank | defalut 0 +    }; +#endif + +  // name of the tileset, localated in files/tilesets directory  // must be defined only when GENERATE_PPM_TILES is not  // if both arent defined, only tiles.dat will be generated diff --git a/src/gen_tiles.c b/src/gen_tiles.c index f7e030e..e4e2159 100644 --- a/src/gen_tiles.c +++ b/src/gen_tiles.c @@ -59,6 +59,8 @@ FILE *fp;  void save(small_t *t, small_t *c, int n, int i)  {  #ifdef GENERATE_PPM_TILES +    (void)i; +      char file_name[64] = {0};      sprintf(file_name, "files/tiles/tile_%d.ppm", n); @@ -66,9 +68,15 @@ void save(small_t *t, small_t *c, int n, int i)      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, 0); +            set_color(pixels, t, x, y, 0, +                      generated_tile_colors[0][0], +                      generated_tile_colors[1][0]); +            set_color(pixels, t, x, y, 1, +                      generated_tile_colors[0][1], +                      generated_tile_colors[1][1]); +            set_color(pixels, t, x, y, 2, +                      generated_tile_colors[0][2], +                      generated_tile_colors[1][2]);          }      save_as_ppm(file_name, pixels, TILE_WIDTH, TILE_HEIGHT, 1); @@ -76,6 +84,8 @@ void save(small_t *t, small_t *c, int n, int i)      printf("Saved file: %s\n", file_name);  #endif  #ifdef TILESET_NAME +    (void)t; (void)c; +      char command[128];      sprintf(command, "cp files/tilesets/%s/%s.ppm files/tiles/tile_%d.ppm", TILESET_NAME, tile_names[i], n);      system(command); | 
