KO

← JumPHP 엔진 확장

Collision v0.5.12

jumphp/collision · MIT · 다운로드 0회

Shapes (circle, box, convex polygon), the separating axis test with the minimum translation, rays and a spatial hash broad phase.

JumPHP ^0.5에서 동작

제공하는 기능

  • Circle, Box, convex Polygon (regular(), rotated())
  • Collision::test() gives the normal and the depth: how to push apart
  • Collision::raycast(): the first shape a ray meets, with its normal
  • SpatialHash broad phase and a CollisionWorld service: collisions(), at(), overlapping(), raycast()
  • Pure PHP on floats: the same in the browser

게임에 추가

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

또는 Composer로:

bin/jumphp composer <game> require jumphp/collision

서비스: JumPHP\Collision\CollisionWorld

예제

$hit = Collision::test($player, $wall);if ($hit) { [$dx, $dy] = $hit->pushOutOfFirst(); $player->translate($dx, $dy); }

문서 소스 코드 Packagist

Collision

Collisions for JumPHP games (jumphp/collision): circles, boxes and convex polygons, overlap tests with the way out, rays, a broad phase. Documentation: doc/index.md; sample: samples/ (bin/jumphp extension:add <game> jumphp/collision copies both into your game). Example game: games/collision-demo.

이 확장에 대한 리뷰

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

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