Skip to content

klyph 1.2: Scrolling worlds

Choose a tag to compare

@inemtsev inemtsev released this 15 Nov 06:59
· 44 commits to main since this release
6fc417f

klyph 1.2.0: Scrolling worlds. Add it to a game with

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

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

Scrolling worlds: layers that move at their own speed, textures that repeat, a sky under the
world, and a camera that follows what is drawn.

Added

  • ParallaxLayer: a sprite that follows the camera at a fraction of the world's speed and repeats to fill the view;
    see the Scrolling worlds guide.
  • DrawSpace.BACKGROUND: canvas quads in points drawn under the whole world, such as a one-call sky.
  • Repeating textures: SamplerAddress.REPEAT on Assets.texture, textureOrNull and createTexture, then
    Sprite.tileWidth and tileHeight or Canvas.drawTiled to repeat the texture across a larger area instead of stretching it.
  • Sprite.originX and originY: anchor a sprite to its Transform at any point, such as a character's feet, instead of the center.
  • Camera.offsetX and offsetY: shift the view after follow and the bounds clamp, such as for a screen shake.
  • drawnPositionOf on World and App: where an Interpolated entity is drawn this frame, for a camera to follow.
  • World.snapInterpolation(entity): draws a teleported or respawned Interpolated entity at its new place, with no sweep from the old one.
  • Scene.elapsed and elapsedSeconds: how long a scene has been on top, standing still while another scene covers it.
  • AppConfig.textureFilter and Assets.textureFilter: the filter that textures, sprite sheets and fonts load with
    unless the call passes one, so a pixel-art game sets NEAREST once.
  • Image.fillRect and Image.draw: paint a rectangle, or lay one image over another with alpha blending, before createTexture.
  • Overlap.otherOrNull(entity): the other entity of a pair, or null for an entity in neither slot.
  • Time.fixedDeltaSeconds and elapsedSeconds: the fixed step's length and the game time as Float seconds, beside deltaSeconds.
  • TextureRegion.aspectRatio: a region's width over its height, to size a sprite by one side without distorting it.

Changed

  • DrawSpace.BACKGROUND is the enum's first entry, before WORLD and SCREEN: an exhaustive when over
    the two needs a branch for it, and the ordinals moved.