~kikoodx/sle

8f53ecbdc7c970d2c2ce630c302e5a8955567983 — KikooDX 3 years ago a66aaf9 0.2.0
Tile first config option (-tile-first)
7 files changed, 10 insertions(+), 3 deletions(-)

M README
M include/conf.h
M include/options.h
M sample.kble
M src/editing_area/draw.c
M src/main.c
M src/options.c
M README => README +1 -0
@@ 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

M include/conf.h => include/conf.h +1 -0
@@ 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 }

M include/options.h => include/options.h +1 -0
@@ 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;

M sample.kble => sample.kble +0 -0
M src/editing_area/draw.c => src/editing_area/draw.c +2 -3
@@ 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;


M src/main.c => src/main.c +4 -0
@@ 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;

M src/options.c => src/options.c +1 -0
@@ 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,