JA

← 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 でログインしてください。

まだレビューはありません。最初の投稿者になりましょう。