Simple tilebased level editor written in C99

cb9bc1e shift level data w/ arr keys

~kikoodx pushed to ~kikoodx/sle git

2 years ago

fc21450 meson: increment version number

~kikoodx pushed to ~kikoodx/sle git

2 years ago
A simple project oriented single screen tilebased level editor.

SLE read and write KBLE level files.
KBLE format specifications:
=> https://git.sr.ht/~kikoodx/kble/tree/dev/item/kbleformat.md

Runtime dependencies: raylib
Build dependencies: meson, raylib

$ git clone https://git.sr.ht/~kikoodx/sle && cd sle
$ meson setup builddir && cd builddir
$ meson compile

The following will install the resulting `sle` binary on your system.
# meson install

$ <SLE binary path> -tileset <tileset> -level <KBLE level to open>
$ sle -tileset assets/tileset.png -level sample.kble

usage: sle -tileset path -level path [options]

Two windows should appear. A main window, with the level you are
currently editing, and a secondary one, containing the tileset you

This software is controlled using a mice.

Main window - Editing Area
Left click: draw with selected tile
Right click: erase (tile 0)
Middle click: pick a tile

Click on a first tile while holding nothing, then click on another tile
holding Left Control and the area between the two points will be filled.

Left arrow key: shift the level data towards the left
Right arrow key: shift the level data towards the right
Up arrow key: shift the level data towards the top
Down arrow key: shift the level data towards the bottom

Secondary window - Tile Picker
Left click on the tile you want to select.

Exit and save
Close/kill the main window. The secondary window will close automaticly
and your modifications to the level file will be writen to disk.


Mandatory flags
All these options take a path to a file as argument.
-tileset : tileset image
-level : KBLE file

Optional flags
These flags are boolean toggles. They take no option.
-verbose : print debug informations to the standard output
-create : create an empty level instead of reading from the -level path

These flags take integers as argument.
-level-width : used by -create
-level-height : used by -create

These flags take colors as argument.
Color format : #RRGGBB or RRGGBB

Example aliases
By using the flags, it's very easy to create specific configurations.
Following are various aliases. They assume than sle is in your PATH.

# PICO-8-like configuration
alias sle-p8='sle -tile-width 8 -tile-height 8 -level-width 16 \
  -level-height 16 -editor-width 128 -editor-height 128 \
  -editor-off-x 0 -editor-off-y 0'

# fx-CG50 configuration
alias sle-cg='sle -tile-width 16 -tile-height 16 -level-width 25 \
  -level-height 14 -editor-width 396 -editor-height 224 \
  -editor-off-x -2 -editor-off-y 0'

# fx-9860G configuration
alias sle-fx='sle -tile-width 8 -tile-height 8 -level-width 16 \
  -level-height 8 -editor-width 128 -editor-height 64 \
  -editor-off-x 0 -editor-off-y 0 -editor-bg-color #b0b0b0 \
  -picker-bg-color #b0b0b0'

Edit include/conf.h to change default configuration. Read the comments!
Don't forget to recompile after you made your modifications.

The following features are enabled with the -verbose flag.
Pressing middle mouse button in the editor will print the value of the
tile pointed to STDIN.

Copyright (C) 2021 KikooDX <kikoodx@paranoici.org>
This software is under the GPL-3.0-or-later license.
See COPYING for more informations.