DE

← Erweiterungen der JumPHP-Engine

Collision v0.5.13

jumphp/collision · MIT · 0 Downloads

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

Funktioniert mit JumPHP ^0.5

Was sie mitbringt

  • 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

Zu deinem Spiel hinzufügen

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

Oder mit Composer:

bin/jumphp composer <game> require jumphp/collision

Dienste: JumPHP\Collision\CollisionWorld

Beispiel

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

Dokumentation Quellcode 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.

Bewertungen dieser Erweiterung

Mit GitHub anmelden Melde dich mit GitHub an, um diese Erweiterung zu bewerten.

Noch keine Rezension: Sei der Erste.