Module klyph

klyph is a 2D game engine in pure Kotlin/Native on SDL3 and SDL_GPU. A game is a Gradle project with one plugin and one dependency, and it compiles to a native executable for macOS, Linux or Windows. This site holds the guide and the API reference.

Guide

Read the pages in order for a tour, or jump to a topic. The contents page has the same list.

  1. Getting started: the build files, SDL3 on each system, a first window with runApp and the KLYPH_* variables.

  2. Sprites and animation: assets, sprites, sheets, animations and the camera.

  3. Entities, systems and scenes: the world, phases and the order of a frame, the fixed step, scenes, Lifetime, Fade, resources and events.

  4. Input: the keyboard by position and by label, the mouse in points and in the world, and gamepads.

  5. Audio: sound effects with pitch and pan, music with fades, volumes and running without a device.

  6. Collisions and particles: colliders, layers, Overlap events, shape queries and particle emitters.

  7. Platformers: solids, one-way ledges, kinematic bodies and sweep queries, with gravity, coyote time and a jump buffer written as game code.

  8. Scrolling worlds: a camera that follows what the player sees and shakes, a sky and parallax layers, repeating textures, sprite origins and the scene clock.

  9. Tile maps: levels painted in the Tiled editor, drawn as tile layers, with solids from the tiles marked solid and tiles changed while the game runs.

  10. Text, canvas and overlay: fonts, the Text component, drawing on app.canvas and the debug overlay.

  11. Shipping: the distribution zip, SDL3 at runtime, fullscreen, the cursor and screenshots on CI.

  12. Performance: what each engine stage costs and how to keep a frame cheap.

API reference

The two modules below hold every public declaration. A game depends on klyph; klyph-platform comes with it and holds the colors, images, key names and window a game uses alongside it.

All modules:

Link copied to clipboard

The klyph engine: the frame loop, entities and scenes, sprites and the camera, text and the canvas, tile maps from the Tiled editor, input, audio, collisions with solids and kinematic bodies, and particles. A game depends on this module, which brings in klyph-platform with it.

Link copied to clipboard

The SDL3, stb_image and stb_vorbis bindings and the thin Kotlin API over them that the klyph engine is built on. It is the only module that touches C interop. Games depend on klyph, which brings this module in as an API dependency.