diff --git a/README b/README index 8ea20b1..7df6888 100644 --- a/README +++ b/README @@ -64,6 +64,7 @@ These flags take integers as argument. -tile-height -level-width : used by -create -level-height : used by -create +-tile-first -editor-width -editor-height -editor-target-fps diff --git a/include/conf.h b/include/conf.h index 9f53a66..24dfaea 100644 --- a/include/conf.h +++ b/include/conf.h @@ -6,6 +6,7 @@ #define TILE_WIDTH 16 #define TILE_HEIGHT 16 +#define TILE_FIRST 0 #define EDITOR_BACKGROUND_COLOR \ (Color) { 0, 0, 0, 255 } diff --git a/include/options.h b/include/options.h index 3818247..25d0269 100644 --- a/include/options.h +++ b/include/options.h @@ -13,6 +13,7 @@ struct Options { /* optionnal arguments, default values in conf.h */ int tile_width; int tile_height; + int tile_first; int new_level_width; int new_level_height; int editor_width; diff --git a/sample.kble b/sample.kble index 3c18d3b..71997e2 100644 Binary files a/sample.kble and b/sample.kble differ diff --git a/src/editing_area/draw.c b/src/editing_area/draw.c index cc96203..d7c24fc 100644 --- a/src/editing_area/draw.c +++ b/src/editing_area/draw.c @@ -18,10 +18,9 @@ void level_draw(struct Level level, struct Options options, /* if tile index is out of bound, skip */ if (tile_index >= level.width * level.height) continue; - const Tile tile = - level.data[x + y * level.width]; + const Tile tile = level.data[tile_index] - options.tile_first; /* if tile is not in tileset, skip */ - if (!tile || tile >= options.tileset_width * + if (tile < 0 || (!tile && !options.tile_first) || tile >= options.tileset_width * options.tileset_height) continue; diff --git a/src/main.c b/src/main.c index 1085be4..b2a3e3f 100644 --- a/src/main.c +++ b/src/main.c @@ -99,6 +99,7 @@ static void process_arguments(int argc, char **argv, {"tileset", required_argument, 0, 't'}, {"tile-width", required_argument, 0, 'w'}, {"tile-height", required_argument, 0, 'h'}, + {"tile-first", required_argument, 0, 'I'}, {"level-width", required_argument, 0, 'i'}, {"level-height", required_argument, 0, 'e'}, {"editor-width", required_argument, 0, 'W'}, @@ -136,6 +137,9 @@ static void process_arguments(int argc, char **argv, case 'h': /* tile height */ options->tile_height = int_arg_min(opt, 1); break; + case 'I': /* first tile index */ + options->tile_first = int_arg_min(opt, 0); + break; case 'i': /* new level width */ options->new_level_width = int_arg_min(opt, 1); break; diff --git a/src/options.c b/src/options.c index 12e92f8..5911d51 100644 --- a/src/options.c +++ b/src/options.c @@ -8,6 +8,7 @@ struct Options options_defaults(void) .level_path = "", .tile_width = TILE_WIDTH, .tile_height = TILE_HEIGHT, + .tile_first = TILE_FIRST, .tileset_width = 0, .tileset_height = 0, .new_level_width = NEW_LEVEL_WIDTH,