KO

← JumPHP 엔진 확장

Physics v0.5.13

jumphp/physics · MIT · 다운로드 11회

A small 2D physics engine for JumPHP: balls, rings and arcs (rotating, opening, growing, shrinking, with gaps), pegs, walls; gravity, restitution, collision events; fixed step, seeded, 32-bit safe

JumPHP ^0.5에서 동작

게임에 추가

bin/jumphp extension:add <game> jumphp/physics

또는 Composer로:

bin/jumphp composer <game> require jumphp/physics

서비스: JumPHP\Physics2d\World
project.yaml 키: physics

소스 코드 Packagist

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.

이 확장에 대한 리뷰

GitHub 로그인 이 확장을 평가하려면 GitHub로 로그인하세요.

아직 리뷰가 없습니다. 첫 번째가 되어 보세요.