diff options
author | kartofen <mladenovnasko0@gmail.com> | 2022-12-22 14:53:44 +0200 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2022-12-22 14:53:44 +0200 |
commit | 4c9fafc4c126af2466dc6c56b9c952f901a1c726 (patch) | |
tree | 16a7590ff005b1e49344836675731e86e2283bd7 | |
parent | 407e1bdc46fc3b4983aa95b3b270a017d631dc42 (diff) |
better tileset configuration
-rwxr-xr-x | build.sh | 2 | ||||
-rwxr-xr-x | download-tilesets.sh | 3 | ||||
-rw-r--r-- | src/config.h | 44 | ||||
-rw-r--r-- | src/gen_tiles.c | 9 |
4 files changed, 13 insertions, 45 deletions
@@ -37,7 +37,7 @@ mkdir -p $BIN mkdir -p $ODIR mkdir -p $FILES -gcc -c $SRCD/gen_tiles.c -o $ODIR/gen_tiles.o $FLAGS +gcc -c $SRCD/gen_tiles.c -o $ODIR/gen_tiles.o $FLAGS -DPATH=files/tilesets gcc -c $SRCD/ppm.c -o $ODIR/ppm.o $FLAGS gcc -c $SRCD/tilemap.c -o $ODIR/tilemap.o $FLAGS gcc -c $SRCD/tiles.c -o $ODIR/tiles.o $FLAGS diff --git a/download-tilesets.sh b/download-tilesets.sh index 2354890..f6e477b 100755 --- a/download-tilesets.sh +++ b/download-tilesets.sh @@ -4,6 +4,7 @@ cd ${0%/*} # go to project root URL="https://ftp.batnako.net/tilesets" +mkdir -p "files" mkdir -p "files/tilesets" function download { @@ -15,6 +16,8 @@ function download { for ((i=0; i<${#tiles[@]}; i++)); do image="${tiles[$i]}.ppm" wget -O "$path/$image" "$URL/$name/$image" done + + wget -O "$path/tileset.h" "$URL/$name/tileset.h" } name="black-white" diff --git a/src/config.h b/src/config.h index bd6fc31..f1fa501 100644 --- a/src/config.h +++ b/src/config.h @@ -1,52 +1,12 @@ // name of the tileset, localated in files/tilesets directory -#define TILESET_NAME "black-white" - -#define DIMENTIONS 2 -#define TILE_TYPES 5 - -tile tiles[TILE_TYPES] = { - { "empty" , 'X', { 0, 0, 0, 0 } }, - { "t" , 'T', { 0, 1, 1, 1 } }, - { "cross" , 'X', { 1, 1, 1, 1 } }, - { "line" , 'I', { 0, 1, 1, 0 } }, - { "corner" , 'T', { 1, 1, 0, 0 } } -}; +#define TILESET knots // Array for which tiles to include the tiles.dat int tiles_to_load[] = { 3, 4 }; -// // name of the tileset, localated in files/tilesets directory -// #define TILESET_NAME "circuit" - -// #define DIMENTIONS 2 -// #define TILE_TYPES 14 - -// // pcb green - 0 -// // green - 1, -// // grey - 2, -// // black - 3, -// // other - 4, 5 -// tile tiles[TILE_TYPES] = { -// { "bridge" , 'I', { 1, 2, 2, 1 } }, -// { "component" , 'X', { 3, 3, 3, 3 } }, -// { "connection" , 'T', { 1, 4, 5, 3 } }, -// { "corner" , 'T', { 0, 0, 4, 5 } }, -// { "dskew" , 'I', { 1, 1, 1, 1 } }, -// { "skew" , 'T', { 1, 1, 0, 0 } }, -// { "substrate" , 'X', { 0, 0, 0, 0 } }, -// { "t" , 'T', { 0, 1, 1, 1 } }, -// { "track" , 'I', { 1, 0, 0, 1 } }, -// { "transition" , 'T', { 2, 0, 0, 1 } }, -// { "turn" , 'T', { 1, 1, 0, 0 } }, -// { "viad" , 'I', { 0, 1, 1, 0 } }, -// { "vias" , 'T', { 1, 0, 0, 0 } }, -// { "wire" , 'I', { 0, 2, 2, 0 } }, -// }; - - -// // Array for which tiles to include the tiles.dat +// #define TILESET circuit // int tiles_to_load[] = { // 0, 1, 2, 3, 4, 5, 6, // 7, 8, 9, 10, 11, 12, 13, diff --git a/src/gen_tiles.c b/src/gen_tiles.c index c29bc29..5d6cba3 100644 --- a/src/gen_tiles.c +++ b/src/gen_tiles.c @@ -8,11 +8,16 @@ typedef struct tile { char name[64]; char symetry; small_t connections[SIDES_MAX]; - // small_t neighbours[TILES_CAP]; -// size_t neigbours_sz; } tile; #include "config.h" +#define STR_AUX(a) #a +#define STR(a) STR_AUX(a) +#define TILESET_PATH(name) STR(../PATH/name/tileset.h) +// include the tileset header configuration +#include TILESET_PATH(TILESET) + +#define TILESET_NAME STR(TILESET) void copy(char *tile_set, char *name, int n) { |