Skip to content

klyph 1.4: Let's get physical

Latest

Choose a tag to compare

@inemtsev inemtsev released this 29 Nov 08:18
5cdedfc

klyph 1.4.0: Let's get physical. Add it to a game with

plugins { id("com.eventslooped.klyph") version "1.4.0" }
klyph { entryPoint = "mygame.main" }
kotlin {
    sourceSets.nativeMain.dependencies {
        implementation("com.eventslooped.klyph:klyph:1.4.0")
        implementation("com.eventslooped.klyph:klyph-physics:1.4.0")   // optional
    }
}

or start from klyph-template. The guide and API reference are at https://inemtsev.github.io/klyph/, and the Physics guide covers the new module.

klyph-physics is the work of @pererikbergman, who wrote the engine, the eighteen-scene playground and the explainers in #55. Thank you, Per-Erik!

The playground's Crates and Blobs scene: a crate resting on a squashed green blob, a crate in a sagging net of pink links, and a crate on the floor tied to a long rope

Rigid and soft bodies in one world: crates squash blobs, blobs knock crates over, and a net of links cradles a crate.

The Machines scene: a car on motorised wheels, a swinging pendulum, a turning windmill, a welded shelf of crates, a lift and a seesaw The Cloth scene: a flag in the wind, a curtain, and a net torn in two by a falling crate

Hinges, sliders, welds and motors (left), and cloth that flaps and tears (right).

A thousand crates toppling from a block, fifty blue blobs heaped on a bed of sand

The playground's stress scene: 1 000 crates, 5 000 grains of sand and 50 blobs in one world. Run it with ./gradlew :games:physics:runRelease, the optimized build, and press the keys to switch scenes.

Let's get physical: klyph-physics, an optional module where crates stack and tumble, blobs
squash, ropes tear and sand pours.

Added

  • klyph-physics, a new module: a 2D physics engine with rigid and soft bodies, particles and sand,
    ropes and cloth that tear, joints and motors, a level of solid tiles with slopes, contact and
    sensor events, raycasts and queries; see the Physics guide.
  • App.addPhysics steps it in the fixed step, PhysicsBody moves an entity with its body, and
    PhysicsWorld.rigidBody(collider, transform) builds a body from a klyph Collider.
  • games/physics: a playground of eighteen physics scenes, from a blob garden to a 5 000-grain stress test.