mirror of https://git.sr.ht/~kikoodx/sle
Tile first config option (-tile-first)
This commit is contained in:
parent
a66aaf9bdc
commit
8f53ecbdc7
1
README
1
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
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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;
|
||||
|
|
BIN
sample.kble
BIN
sample.kble
Binary file not shown.
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue