Demo | Code | ×
Refreshed version with all samples ported to HTML5 using Haxe's Javascript target

Nape Samples are intended to both demonstrate the capabilities of the engine, as well as demonstrating how to use the engine through practice. All samples have documented source in Haxe to accompany them.

Getting Started.

These samples are specifically intended to demonstrate the basics of using Nape. All code for the samples is self-contained with no additional utilities being used.

BasicSimulation FixedDragging
Setting up a basic Nape simulation with debug drawing. [BasicSimulation] Fixed time-step simulations and dragging objects with mouse. [FixedDragging]

Feature Demonstrations.

Samples make use of a Template class to hide common code and focus on features. Download samples to view this class.

Constraints SoftBodies Viewports
Demonstrating the built-in Nape constraint types. [Constraints] Creating soft bodies using PivotJoint and easily creating Nape objects. [SoftBodies] Showing use of nape callbacks to efficiently track what objects are currently visible in viewport [Viewports]
PyramidStressTest PerlinSquares FilteringInteractions
Stress test forming large pyramid of boxes stressing contact solvers. [PyramidStressTest] Demo and stress-test of MarchingSquares with convex decompositions. [PerlinSquares] Using InteractionFilters to selectively permit collisions. [FilteringInteractions]
SpatialQueries MarioGalaxyGravity OneWayPlatforms
Using spatial queries like raycast and convex casts, together with per-query filtering. [SpatialQueries] Mario galaxy style gravity using Geom class with use of MarchingSquares in addition. [MarioGalaxyGravity] Creating one-way platforms, demonstrating conveyor belts and kinematic bodies in addition. [OneWayPlatforms]
BodyFromGraphic DestructibleTerrain Portals
Using MarchingSquares to generated Nape Bodies from Bitmaps and DisplayObjects. [BodyFromGraphic] Using MarchingSquares to create efficient destructible terrain using a Bitmap. [DestructibleTerrain] Very complex demo, creating general purpose Portals with callbacks and UserConstraint. [Portals]