Home

Awesome

dyn4j-samples

A collection of samples that use the dyn4j library in a variety of ways.

The intent of these samples is to provide a simple framework for building applications with the dyn4j library. The samples show how to use features like joints, static collision detection, raycasting, CCD, and so on. They also provide some creative ways to solve common problems like one-way platforms, jumping, destruction, player control, and so on. That said, none of these are intended to be complete solutions or even the correct solution for your use-case.

SampleDescriptionConcepts
BasketBallA side view basketball gamePlayer Input, DistanceJoint, RevoluteJoint, Image Mapping/Texturing, Filtering, Bounds Listening
BilliardsA top down billiards simulationDensity, Friction, Damping, Player Input
BowlingA side view of a bowling ball hitting pinsDensity, Friction, Restitution, CategoryFilter
BridgeA side view of a bridge made from joined bodiesRevoluteJoint
BucketA side view of a bucket with 200 random objectsLarger world
ConcaveA side view of a concave objectConcave vs. Convex, Convex Composition
CrankA side view of a pistonRevoluteJoint, PrismaticJoint
DecompositionA side view of a few simple polygons decomposedConvex Decomposition
DestructibleA side view of destruction of a body and jointRemove/Add Buffering
ImagesA side view of a scene where images are mapped to bodiesImage Mapping/Texturing
LinkTerrainA side view of a link-based floorSmooth Sliding, Link
MazeA top down view of a maze with a player controled bodyMotorJoint, Player Control
OrganizeA side view of a scene where bodies are randomly joined and self organizeDistanceJoint
PlatformerA side view of a platformer simulationOnGround, Player Control, One-way Platform, Jumping
PyramidA side view of a Pyramid of stacked boxesStacking
RagdollA side view of a ragdoll made from jointsRevoluteJoint
StackingA side view of a scene where the player can add boxes dynamicallyStacking, Add Bodies
TankA top down tank simulationRaycasting, Player Control, FrictionJoint, RevoluteJoint
ThrustA side view of a scene with a rocketApplying Forces
TrackingA scene where contact tracking is printed to the consoleContact Tracking
TruckA scene where a truck filled with boxes moves through a worldWheelJoint, Fixture Composition
UsingGraphics2DA scene with just a bunch of shapes rendered via Java 2DJava 2D
UsingJoglA scene with a few shapes rendered via OpenGL via JOGLJOGL

BasketBall

Use angle, power, and position to attempt to make baskets. The sample only scores goals, so don't miss! If you are close you get 2 points, far away you get 3. Only if you get it in when you launch it is counted.

BasketBall Sample

Billiards

Use the cue stick to hit the cue ball to hit the other balls. You must wait until the balls settle before your next hit.

Billiards Sample

Platformer

Use the ball to "run" around the level and jump. You can jump onto platforms above you no matter where you are, but if you land on them, they are solid. You can drop down from the top level as well. Green means you are touching the ground and can jump. Purple means you are not touching the ground.

Platformer Sample

Ragdoll

Use your mouse to drag around and contort the ragdoll

Ragdoll Sample

Tank

Drive a tank! Independently operating the tracks and barrel. The barrel will be pushed aside by obstacles. The barrel is "shooting" a ray to see what it would hit. You can press a key to destroy the closest object you are aiming at.

Tank Sample

Thrust

How hard can it be to fly a rocket? Using only front, back and side thrusters (applied force) fly a rocket around an enclosed area. Challenge yourself to land without tipping over or flying in a smooth trajectory.

Thrust Sample

Truck

Drive a truck with cargo! Accelerate and decelerate using the keyboard or stop immediately. Watch the contents slide around as you drive. Use the mouse to manipulate the truck frame to see the suspension compress.

Truck Sample