diff --git a/_modules/github.com/korlibs/korge-ext/korma-tile-matching/korma-tile-matching.md b/_modules/github.com/korlibs/korge-ext/korma-tile-matching/korma-tile-matching.md new file mode 100644 index 0000000..54bb2a0 --- /dev/null +++ b/_modules/github.com/korlibs/korge-ext/korma-tile-matching/korma-tile-matching.md @@ -0,0 +1,58 @@ +--- +layout: module +title: Tile Pattern Matching +authors: [korlibs] +category: Tilemaps +link: https://github.com/korlibs/korge-ext/tree/main/korma-tile-matching/korma-tile-matching +base: https://github.com/korlibs/korge-ext/raw/2a331af4bab999c105c5f945b152e5f95dbf49f1/korma-tile-matching/resources/ +files: +- tiles.ase +assets_base: https://raw.githubusercontent.com/korlibs/korge-ext/f5859c899f371406d096485155a3abb3f5b4d518/korma-tile-matching/resources/ +assets: +- { title: Tiles, name: tiles, preview: screenshot.png, download: tiles.ase } + +--- + +This module allows to automatically find IntArray2 patterns and update a StackedTileMap tile information from it. Similar to what LDtk does. + +## Some code to get started + +```kotlin +suspend fun main() = Korge(windowSize = Size(256 * 2, 196 * 2)) { + val tilesIDC = resourcesVfs["tiles.ase"].readImageDataContainer(ASE) + val tiles = tilesIDC.mainBitmap.slice() + val tileSet = TileSet(tiles.splitInRows(16, 16).mapIndexed { index, slice -> TileSetTileInfo(index, slice) }) + val tileMap = tileMap(TileMapData(32, 24, tileSet = tileSet)) + val snakeMap = tileMap(TileMapData(32, 24, tileSet = tileSet)) + val rules = CombinedRuleMatcher(WallsProvider, AppleProvider) + val ints = IntArray2(tileMap.map.width, tileMap.map.height, GROUND).observe { rect -> + IntGridToTileGrid(this.base as IntArray2, rules, tileMap.map, rect) + } + ints.lock { + ints[RectangleInt(0, 0, ints.width, 1)] = WALL + ints[RectangleInt(0, 0, 1, ints.height)] = WALL + ints[RectangleInt(0, ints.height - 1, ints.width, 1)] = WALL + ints[RectangleInt(ints.width - 1, 0, 1, ints.height)] = WALL + ints[RectangleInt(4, 4, ints.width / 2, 1)] = WALL + } +} + +val GROUND = 0 +val WALL = 1 +val APPLE = 2 + +object AppleProvider : ISimpleTileProvider by (SimpleTileProvider(value = APPLE).also { + it.rule(SimpleRule(Tile(12))) +}) + +object WallsProvider : ISimpleTileProvider by (SimpleTileProvider(value = WALL).also { + it.rule(SimpleRule(Tile(16))) + it.rule(SimpleRule(Tile(17), right = true)) + it.rule(SimpleRule(Tile(18), left = true, right = true)) + it.rule(SimpleRule(Tile(19), left = true, down = true)) + it.rule(SimpleRule(Tile(20), up = true, left = true, down = true)) + it.rule(SimpleRule(Tile(21), up = true, left = true, right = true, down = true)) +}) +``` + +{% include asset_grid.html assets_base=page.assets_base assets=page.assets %} diff --git a/_modules/github.com/korlibs/korge-ext/korma-tile-raycasting/korma-tile-raycasting.md b/_modules/github.com/korlibs/korge-ext/korma-tile-raycasting/korma-tile-raycasting.md index 79bdda2..329d841 100644 --- a/_modules/github.com/korlibs/korge-ext/korma-tile-raycasting/korma-tile-raycasting.md +++ b/_modules/github.com/korlibs/korge-ext/korma-tile-raycasting/korma-tile-raycasting.md @@ -2,7 +2,7 @@ layout: module title: Tiled-based Raycasting authors: [korlibs] -category: Other +category: Tilemaps link: https://github.com/korlibs/korge-ext/tree/main/korma-tile-raycasting/korma-tile-raycasting icon: /i/modules/korma-tile-raycasting.png --- diff --git a/_repotags/github.com/korlibs/korge-ext/github.com-korlibs-korge-ext.json b/_repotags/github.com/korlibs/korge-ext/github.com-korlibs-korge-ext.json index 08bb0fb..e947e40 100644 --- a/_repotags/github.com/korlibs/korge-ext/github.com-korlibs-korge-ext.json +++ b/_repotags/github.com/korlibs/korge-ext/github.com-korlibs-korge-ext.json @@ -2,6 +2,7 @@ layout: repotag title: github.com-korlibs-korge-ext tags: +- v0.1.3: 2a331af4bab999c105c5f945b152e5f95dbf49f1 - v0.1.2: de29df486b4cf755a5ab32b35a64c06f9f7722d0 - v0.1.1: 77b2681247c0218e94961290a6b29cb72df816cc - v0.1.0: 60d7185b0d740af8b4950d7cf84ea3c2db378945 @@ -11,6 +12,7 @@ tags: - 0.0.2: 143fcd75de1269d6425d51cd3d9a9b907c1d5c7a - 0.0.1: 7c4c3f6c11cd9d5662a49340a3b0c5dd8b0beaf2 dates: + 2a331af4bab999c105c5f945b152e5f95dbf49f1: '2024-06-20T21:06:38Z' de29df486b4cf755a5ab32b35a64c06f9f7722d0: '2023-10-05T13:49:55Z' 77b2681247c0218e94961290a6b29cb72df816cc: '2023-10-04T19:50:38Z' 60d7185b0d740af8b4950d7cf84ea3c2db378945: '2023-10-03T18:19:52Z' diff --git a/run.bat b/run.bat new file mode 100644 index 0000000..45a00a7 --- /dev/null +++ b/run.bat @@ -0,0 +1,3 @@ +@echo off +setlocal +docker run -v "%CD%:/srv/jekyll" -v "%CD%/vendor/bundle:/usr/local/bundle" -p 4000:4000 -it jekyll/jekyll:3.8 jekyll serve %* -H 0.0.0.0 \ No newline at end of file diff --git a/start.sh b/run.sh old mode 100755 new mode 100644 similarity index 100% rename from start.sh rename to run.sh