JumPHP extension: physics (read-only split of jumphp/jumPhp extensions/physics)
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-09 04:51:02 +01:00
doc JumPHP 0.5.13, IDE 0.1.52: the extensions' samples in doc/samples (three new ones, a physics demo game, a SamplesTest in every demo), a ▶ on a scene's class line runs that scene only 2026-11-05 10:05:22 +01:00
src shorts: Voice, Sprites, Quality; Recorder makes live voices in the background at half rate; Mixer and physics World synced with the game's copies 2026-11-09 04:51:02 +01:00
composer.json gh for every forge (tools/bin/gh + tools/forge.php: GitHub -> real gh, git.jumphp.net -> forge API), JumPHP's addresses moved to git.jumphp.net, old projects' remotes follow, extension splits on the same forge 2026-11-06 21:36:17 +01:00
LICENSE Extensions on Packagist: each split to its own repository on every tag (extensions-split workflow, tools/extensions-publish.sh, dry run by default), composer.json valid without jumphp/engine, docs 2026-11-04 10:41:59 +01:00
README.md Shorts video maker: extensions physics (balls in rotating / opening rings, seeded) and shorts (notes on collisions, MIDI, offline mix), bin/jumphp video:make -> vertical 1080x1920 60 FPS MP4 + cover, shorts-demo with three templates 2026-11-04 05:31:35 +01:00

jumphp/physics

A small 2D physics engine for JumPHP (an engine extension, docs/extensions.md), made for "satisfying" videos and simple games: balls bouncing inside rings and arcs (turning, opening, growing, shrinking, with gaps), on pegs and walls, under gravity. Fixed step, seeded, the same run on the desktop and in the browser (32-bit PHP).

public function __construct(private World $world) {}

$this->world->reset(42);
$ring = $this->world->addRing(new Ring(135, 240, 120, gap: 0.6, spin: 1.2));
$this->world->addBall(new Ball(135, 200, vx: 140, radius: 7, color: '#ff4fa3'));
$this->world->on(fn (array $hit) => $hit['type'] === 'escape' && $this->win());

// update(): $this->world->update($dt); foreach ($this->world->hits() as $hit) { ... }

project.yaml physics: {gravity: 600, restitution: 1.0, hz: 240, seed: 1}. Example: games/shorts-demo.