diff --git a/README b/README index 7df6888..16a8121 100644 --- a/README +++ b/README @@ -3,7 +3,8 @@ SLE A simple project oriented single screen tilebased level editor. SLE read and write KBLE level files. -=> https://git.sr.ht/~kikoodx/kble +KBLE format specifications: +=> https://git.sr.ht/~kikoodx/kble/tree/dev/item/kbleformat.md COMPILATION =========== @@ -34,6 +35,7 @@ Main window - Editing Area -------------------------- Left click: draw with selected tile Right click: erase (tile 0) +Middle click: pick a tile Secondary window - Tile Picker ------------------------------ @@ -50,8 +52,8 @@ FLAGS Mandatory flags --------------- All these options take a path to a file as argument. --tileset Tileset image --level KBLE file +-tileset : tileset image +-level : KBLE file Optional flags -------------- diff --git a/src/editing_area/draw.c b/src/editing_area/draw.c index d7c24fc..019c8ac 100644 --- a/src/editing_area/draw.c +++ b/src/editing_area/draw.c @@ -18,10 +18,13 @@ 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[tile_index] - options.tile_first; + const Tile tile = + level.data[tile_index] - options.tile_first; /* if tile is not in tileset, skip */ - if (tile < 0 || (!tile && !options.tile_first) || tile >= options.tileset_width * - options.tileset_height) + if (tile < 0 || + (!tile && !options.tile_first) || + tile >= options.tileset_width * + options.tileset_height) continue; const Rectangle tile_rect = { diff --git a/src/editing_area/main.c b/src/editing_area/main.c index e4f98f5..7375fa4 100644 --- a/src/editing_area/main.c +++ b/src/editing_area/main.c @@ -108,17 +108,17 @@ static void update_mouse(int *mouse_x, int *mouse_y, struct Level level, level.height - 1); /* set tile */ - if (left_click) { + if (left_click) level.data[*mouse_x + *mouse_y * level.width] = shared_data->selected_tile; - } /* remove tile */ - if (right_click) { + if (right_click) level.data[*mouse_x + *mouse_y * level.width] = 0; - } - /* get info about tile */ + /* set tile to pointed cell (pick tile) */ if (middle_click) { INFO_VAR("%d", level.data[*mouse_x + *mouse_y * level.width]); + shared_data->selected_tile = + level.data[*mouse_x + *mouse_y * level.width]; } }