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.
- All samples support zoom and pan using the mouse and mouse wheel
- All samples support object manipulation with the mouse
- All samples have features like reset, reset camera, toggle rendering, etc.
- Each sample may have it's own controls - see the console output when running for the full list of controls
Sample | Description | Concepts |
---|---|---|
BasketBall | A side view basketball game | Player Input, DistanceJoint, RevoluteJoint, Image Mapping/Texturing, Filtering, Bounds Listening |
Billiards | A top down billiards simulation | Density, Friction, Damping, Player Input |
Bowling | A side view of a bowling ball hitting pins | Density, Friction, Restitution, CategoryFilter |
Bridge | A side view of a bridge made from joined bodies | RevoluteJoint |
Bucket | A side view of a bucket with 200 random objects | Larger world |
Concave | A side view of a concave object | Concave vs. Convex, Convex Composition |
Crank | A side view of a piston | RevoluteJoint, PrismaticJoint |
Decomposition | A side view of a few simple polygons decomposed | Convex Decomposition |
Destructible | A side view of destruction of a body and joint | Remove/Add Buffering |
Images | A side view of a scene where images are mapped to bodies | Image Mapping/Texturing |
LinkTerrain | A side view of a link-based floor | Smooth Sliding, Link |
Maze | A top down view of a maze with a player controled body | MotorJoint, Player Control |
Organize | A side view of a scene where bodies are randomly joined and self organize | DistanceJoint |
Platformer | A side view of a platformer simulation | OnGround, Player Control, One-way Platform, Jumping |
Pyramid | A side view of a Pyramid of stacked boxes | Stacking |
Ragdoll | A side view of a ragdoll made from joints | RevoluteJoint |
Stacking | A side view of a scene where the player can add boxes dynamically | Stacking, Add Bodies |
Tank | A top down tank simulation | Raycasting, Player Control, FrictionJoint, RevoluteJoint |
Thrust | A side view of a scene with a rocket | Applying Forces |
Tracking | A scene where contact tracking is printed to the console | Contact Tracking |
Truck | A scene where a truck filled with boxes moves through a world | WheelJoint, Fixture Composition |
UsingGraphics2D | A scene with just a bunch of shapes rendered via Java 2D | Java 2D |
UsingJogl | A scene with a few shapes rendered via OpenGL via JOGL | JOGL |
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.
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.
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.
Use your mouse to drag around and contort the ragdoll
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.
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.
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.