Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ level; `docs/physics.md` is its guide page and `docs/physics/` the explainers, r
`Wave` resource and shown in the HUD, drifters and divers that swoop at the ship, and every fifth
wave is a boss with 12 hit points, a health bar drawn in world space and bullets on the
`ENEMY_BULLET` layer; `KLYPH_AUTOPILOT=1` plays itself, with 4 enemies a wave so a 90 second run
reaches the boss, and `KLYPH_FRAMES` or `KLYPH_SECONDS` bounds a run), `games:squish` (executable in `games/squish`; a bug-squishing game for young children, same layout and variables as the shooter; the system cursor is hidden because the swatter is the pointer, and F11 toggles fullscreen), `games:roller` (executable in `games/roller`; Rooftop Roller, a side-scrolling platformer of one level, a ninja on rollerblades with momentum, variable jumps, coyote time and a jump buffer, rings, hearts, stompable blobs and helicopters, same layout and variables as squish; the level is Kotlin data (`Level.kt`) whose roofs and ledges become invisible `Solid`s, and whose `Shuttle`, a girder over the widest gap, is a play-scene `Solid` with a `Velocity` and its own tiled `Sprite`, marked `Interpolated` and turned at the ends of its track by `moveShuttles`, which the hero rides and jumps off with `floorVelocityX` added, the hero is a `KinematicBody` whose acceleration, gravity, jumps, coyote time and jump buffer are the game's own (`Systems.kt`), the blobs and helicopters walk and fly their patrols by their `Transform`s, the brick, cap, window and girder tiles and the one-off art are painted into `Image`s at startup with `Image.fillRect`, `fillCircle` and `set`; the one-off art (air conditioner, skyline, clouds, pylon, star) is then drawn into one sheet image with `Image.draw` (alpha blending, clipped like the shapes) and uploaded as one texture, a `SheetLayout` setting the pieces in a row with their edge texels repeated one texel outwards, each building being `Sprite`s that repeat the tiles (`SamplerAddress.REPEAT` textures, one each because a tiled sprite repeats a whole texture, `Sprite.tiled`) with props standing on `originY = 1f`, the sky is one `DrawSpace.BACKGROUND` quad, the clouds and skyline are `ParallaxLayer` sprites anchored at the camera's start, the camera follows `app.drawnPositionOf(hero)` and shakes through `Camera.offsetX`, a respawn calls `snapInterpolation`, and the title's hero, the pickups and the end screens read their scene's `elapsed`; the autopilot plans again every fixed step, probing for the roof's end with `floorBelowOrNull` and for walls ahead with `sweepCollider` and following jump arcs with `slideCollider`, and fails at exit if it took no ring and stomped no enemy), `games:physics` (executable in `games/physics`, package `klyph.physics.demo`; the physics playground of eighteen scenes, from a blob garden to a stress test of 1 000 crates, 5 000 grains and 50 blobs, drawn with `DebugDraw`; keys switch scenes and debug views, the mouse grabs and spawns; its scene tests, `HeadlessTest`, `MouseTest` and `SceneTest`, take about ten minutes on the debug build, so `check` skips them unless `-Pklyph.physics.sceneTests=1` is set), `benchmarks`
reaches the boss, and `KLYPH_FRAMES` or `KLYPH_SECONDS` bounds a run), `games:squish` (executable in `games/squish`; a bug-squishing game for young children, same layout and variables as the shooter; the system cursor is hidden because the swatter is the pointer, and F11 toggles fullscreen), `games:roller` (executable in `games/roller`; Rooftop Roller, a side-scrolling platformer of one level, a ninja on rollerblades with momentum, variable jumps, coyote time and a jump buffer, rings, hearts, stompable blobs and helicopters, same layout and variables as squish; the level is Kotlin data (`Level.kt`) whose roofs and ledges become invisible `Solid`s, and whose `Shuttle`, a girder over the widest gap, is a play-scene `Solid` with a `Velocity` and its own tiled `Sprite`, marked `Interpolated` and turned at the ends of its track by `moveShuttles`, which the hero rides and jumps off with `floorVelocityX` added, the hero is a `KinematicBody` whose acceleration, gravity, jumps, coyote time and jump buffer are the game's own (`Systems.kt`), the blobs and helicopters walk and fly their patrols by their `Transform`s, the brick, cap, window and girder tiles and the one-off art are painted into `Image`s at startup with `Image.fillRect`, `fillCircle` and `set`; the one-off art (air conditioner, skyline, clouds, pylon, star) is then drawn into one sheet image with `Image.draw` (alpha blending, clipped like the shapes) and uploaded as one texture, a `SheetLayout` setting the pieces in a row with their edge texels repeated one texel outwards, each building being `Sprite`s that repeat the tiles (`SamplerAddress.REPEAT` textures, one each because a tiled sprite repeats a whole texture, `Sprite.tiled`) with props standing on `originY = 1f`, the sky is one `DrawSpace.BACKGROUND` quad, the clouds and skyline are `ParallaxLayer` sprites anchored at the camera's start, the camera follows `app.drawnPositionOf(hero)` and shakes through `Camera.offsetX`, a respawn calls `snapInterpolation`, and the title's hero, the pickups and the end screens read their scene's `elapsed`; the autopilot plans again every fixed step, probing for the roof's end with `floorBelowOrNull` and for walls ahead with `sweepCollider` and following jump arcs with `slideCollider`, and fails at exit if it took no ring and stomped no enemy), `games:physics` (executable in `games/physics`, package `klyph.physics.demo`; the physics playground of eighteen scenes, from a blob garden to a stress test of 1 000 crates, 5 000 grains and 50 blobs, drawn with `DebugDraw`; keys switch scenes and debug views, the mouse grabs and spawns; its scene tests, `HeadlessTest`, `MouseTest` and `SceneTest`, take about ten minutes on the debug build, so `check` skips them unless `-Pklyph.physics.sceneTests=1` is set), `games:topple` (executable in `games/topple`, depending on `klyph` and `klyph-physics`; Topple, a pixel-art slingshot game of three levels, a knight's sling against goblins on towers of stone blocks and planks, same layout and variables as the roller; the levels are Kotlin data (`Level.kt`, a `LevelBuilder`), the play scene's `onEnter` gives `app.physics` a new `PhysicsWorld` (gravity 700, damping 0.05) whose `SolidGrid` holds the ground and the stone walls, and every piece and goblin is a body built with `rigidBody(collider, transform)` and linked by `PhysicsBody` and `Interpolated`, the bolts are welds with a `breakForce` of 30 long planks' weight (a standing tower pulls them at most about 36 000 of its 430 000, as `joints.forceOf` logs) watched through `events.brokenJointAt`, the thrown stone is a `Motion.BULLET` given its speed with `setVelocity` and slowed by the game while it rolls on the ground, a goblin is down when `contactsBegun` pairs it with the stone, when its angle passes 70 degrees or when it touches `TouchSide.SOLIDS` below where it stood, and every screen pushed over play sets `physics.isPaused`, as the physics knows no scenes; the sling is dragged with the mouse or aimed with the keys or a stick, with a dotted arc of the first second, the camera follows `app.drawnPositionOf(stone)` and shakes through `Camera.offsetX`, the sprites are generated pixel art loaded with `assets.region(path, filter = SamplerFilter.NEAREST)` at one texel per world unit in a 360-unit-high world, and `tools/synth.py` writes the sounds and the march (through SoX); the autopilot makes each level's planned throws, straying a little on retries, and fails at exit if it knocked no goblin down), `benchmarks`
(executable; named benchmarks, run from the release build), `samples` (the `@sample` functions from
API_STYLE.md section 8, run as tests; `@Sample` is a typealias of `kotlin.test.Test` and
`assertPrints` lives in `samples/src/nativeTest/kotlin/samples/Harness.kt`), and
`klyph-gradle-plugin` (the `com.eventslooped.klyph` Gradle plugin games apply, with its own
reference in `klyph-gradle-plugin/README.md`; an included build through `pluginManagement` in
`settings.gradle.kts`, so `sandbox`, `games:shooter`, `games:squish`, `games:roller`, `games:physics` and `benchmarks` apply it by id and take
`settings.gradle.kts`, so `sandbox`, `games:shooter`, `games:squish`, `games:roller`, `games:physics`, `games:topple` and `benchmarks` apply it by id and take
their targets, SDL3 link flags, asset sync, `run`, `runRelease` and `distribute` from it; its
library mode, `com.eventslooped.klyph.library`, does the same without executables or their tasks
for the engine modules; it is a separate Gradle build, so its unit and TestKit tests run with
Expand Down Expand Up @@ -219,6 +219,7 @@ CI job (no display, no GPU) uses it; the Windows job runs it in bash like its ot
./gradlew :games:shooter:run -Pklyph.autopilot=1 -Pklyph.seconds=10 # plays itself, fails if no kill
./gradlew :games:squish:run # click or arrows/stick + Space/south; autopilot fails if no squish
./gradlew :games:roller:run # A/D/arrows/stick + Space/W/south; autopilot finishes the level in ~20 s
./gradlew :games:topple:run # drag the sling with the mouse, or arrows + hold Space/south; autopilot clears all three levels in ~45 s
./gradlew :games:shooter:distribute # zip in games/shooter/build/distributions/, runs without SDL3 installed
./gradlew :benchmarks:benchmarkSpritesOffscreen -Pklyph.sprites=100000
./gradlew :benchmarks:benchmarkSprites -Pklyph.sprites=50000 # in a window
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ opting the game in.
| `samples` | The `@sample` functions referenced from KDoc, run as tests. |
| `klyph-gradle-plugin` | The Gradle plugin games apply, a separate Gradle build included through `pluginManagement`. Its library mode configures the engine modules too, so the target rules and the SDL3 lookup live only here. |
| `buildSrc` | The engine modules' convention plugins (`klyph.native`, `klyph.publish`, `klyph.docs`, `klyph.lint`) and the shader and guide tasks, built against the plugin above. |
| `games/shooter`, `games/squish`, `games/roller` | The sample games. |
| `games/shooter`, `games/squish`, `games/roller`, `games/topple` | The sample games. |
| `games/physics` | The physics playground: eighteen scenes of `klyph-physics`. Its slow scene tests run only with `-Pklyph.physics.sceneTests=1`. |
| `sandbox` | Smoke test: opens a window and clears it each frame. |
| `benchmarks` | Named benchmarks, such as `sprites`, `mixer` and `physics`. |
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ program for Windows, macOS and Linux, with no JVM and nothing extra to install.
[![CI](https://github.com/inemtsev/klyph/actions/workflows/ci.yml/badge.svg)](https://github.com/inemtsev/klyph/actions/workflows/ci.yml)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE)

| [Rooftop Roller](games/roller) | [Bug Squish](games/squish) | [Shooter](games/shooter) |
|---|---|---|
| ![A ninja on rollerblades stomps a green blob on a brick rooftop](games/roller/screenshot.png) | ![A fly swatter over a picnic blanket with watermelon and cake](games/squish/screenshot.png) | ![A ship fires at red enemies in a starfield](games/shooter/screenshot.png) |
| [Rooftop Roller](games/roller) | [Topple](games/topple) | [Bug Squish](games/squish) | [Shooter](games/shooter) |
|---|---|---|---|
| ![A ninja on rollerblades stomps a green blob on a brick rooftop](games/roller/screenshot.png) | ![A bolted wooden tower with two goblins tips over after a stone hits it](games/topple/screenshot.png) | ![A fly swatter over a picnic blanket with watermelon and cake](games/squish/screenshot.png) | ![A ship fires at red enemies in a starfield](games/shooter/screenshot.png) |

## Your first window

Expand Down Expand Up @@ -48,8 +48,9 @@ template" and you have a window, a ship that flies, and CI on three desktops.
sprites to shipping, with every snippet compiled.
- **[API reference](https://inemtsev.github.io/klyph/)**: every public declaration, with samples
that run as tests.
- **[Three sample games](games/)**: a top-down shooter, a bug-squishing game for small children
and a platformer. Each plays itself with `-Pklyph.autopilot=1`.
- **[Four sample games](games/)**: a top-down shooter, a bug-squishing game for small children,
a platformer and a slingshot game on the physics module. Each plays itself with
`-Pklyph.autopilot=1`.
- **[The physics playground](games/physics)**: eighteen scenes of the `klyph-physics` module, from
a blob garden to 5,000 grains of sand; `./gradlew :games:physics:run`.

Expand Down
Loading
Loading