Skip to content

klyph 1.3: Levels that move

Choose a tag to compare

@inemtsev inemtsev released this 20 Nov 19:49
· 33 commits to main since this release
0cd4efc

klyph 1.3.0: Levels that move. Add it to a game with

plugins { id("com.eventslooped.klyph") version "1.3.0" }
klyph { entryPoint = "mygame.main" }
kotlin { sourceSets.nativeMain.dependencies { implementation("com.eventslooped.klyph:klyph:1.3.0") } }

or start from klyph-template. The guide and API reference are at https://inemtsev.github.io/klyph/.

The roller's hero riding a girder that slides across a gap between two rooftops

A Solid with a Velocity is a moving platform. The hero stands on it, rides it across the gap, and keeps its speed when he jumps off.

A small level painted in Tiled, drawn by the sandbox: brick walls, a grass floor, a plank ledge and flowers

A level painted in the Tiled editor, loaded with assets.tileMap("level.tmj"), drawn with spawnTileLayer and made solid with spawnSolids. The turned flower is a tile flipped in Tiled.

The roller's debug overlay with the atlas off: 25 draw calls The roller's debug overlay with the atlas on: 17 draw calls

The same frame of the roller with the atlas off (left, 25 draws) and on (right, 17 draws). Nothing in the game changed; assets.region packs its files into shared pages.

Levels that move: maps painted in Tiled and loaded in one call, platforms that carry the
hero, and sprites packed into shared atlas pages behind the scenes.

Added

  • assets.tileMap(path) and tileMapOrNull: load a level saved from the Tiled map editor as JSON.
  • TileLayer, Tile and TileSet: draw a grid of tiles, only the cells in view, and change cells as the game runs.
  • Commands.spawnTileLayer and spawnSolids: draw a map layer, and make its tiles marked solid or oneWay into solids.
  • TileGrid.tileAt and solidRectangles: ask which tile is under a point, or get a layer's walls as merged boxes.
  • Moving platforms: a Solid with a Velocity, an error before, carries the bodies on it and pushes those in its way.
  • KinematicBody.floorVelocityX and floorVelocityY: the moving floor's speed, for a jump that keeps its momentum.
  • KinematicBody.wasCarried and isCrushed: say when the floor carried the body, or a moving solid crushed it.
  • Assets.region packs its files into shared atlas pages: sprites of different files in one layer draw in one call.
  • AppConfig.atlas and KLYPH_ATLAS=0: give every file its own texture again, to compare while debugging.
  • ParallaxLayer.anchorX and anchorY: place a layer where it should be when the camera starts, with no arithmetic.
  • Sprite.tiled(region, width, height, scale): a sprite that repeats its region at the region's own size.
  • SceneStack.current: the top scene without a null check, so a scene system reaches its own clock.
  • Assets.region(path) and regionOrNull: load an image as a TextureRegion in one call, for a Sprite.
  • Image.drawLine and a source rectangle on Image.draw: paint a one-pixel line, or cut one picture out of a sheet image.
  • KinematicBody.wasPushedOut and isStuck: say when a move pushed the body out of a solid, or found no way out.
  • AppConfig.frameDelta and KLYPH_FRAME_DELTA: every frame lasts the same game time, so runs and screenshots repeat.
  • Assets.readText and readBytes: read a file under the asset root, for a loader of your own format.

Changed

  • Tiled sprites and drawTiled on a clamped texture: the error names the fix, loading with SamplerAddress.REPEAT.
  • Camera.offsetX and offsetY reset to 0 when a scene changes: a pause pushed over a shake is drawn centered.
  • Image.fill, fillRect, fillCircle and draw are extensions now: import them, as in import klyph.platform.fill.

Fixed

  • A KinematicBody that starts a move inside a solid is pushed out of it instead of passing through.
  • drawnPositionOf on a child: counts a parent moved earlier in the frame instead of lagging a frame behind.