ZH

← JumPHP 引擎扩展

Collision v0.5.13

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: doc/samples/ (bin/jumphp extension:add <game> jumphp/collision copies both into your game). Example game: games/collision-demo.

对此扩展的评价

使用 GitHub 登录 请使用 GitHub 登录后为此扩展评分。

暂无评价:来做第一个吧。