dchip is a D2 port of the Chipmunk2D physics library.
To use this package, run the following command in your project's root directory:
Put the following dependency into your project's dependences section:
This package provides sub packages which can be used individually:
dchip:simple - dchip simple demo
dchip:demo - dchip demo
dchip:old_demo - dchip old_demo
This is a D2 port of the Chipmunk2D game physics library.
Currently DChip targets Chimpunk2D version 6.2.1.
DChip is a platform-independent library with no dependencies.
The sample projects have dependencies on either [GLFW] or [SDL], and the OpenGL Utility Library (GLU).
This D2 port has been created by [Andrej Mitrovic].
The older v5.3.5 port was created by [Stephan Dilly], and is being maintained here: https://bitbucket.org/Extrawurst/chipmunkd/wiki/Home
Note: The two ports are not compatible with each other.
The older [SDL]-based samples were created by [Stephan Dilly], and updated to the new API by [Andrej Mitrovic].
The newer samples use [GLFW] and were written by [Scott Lembcke] and [Howling Moon Software], and were ported to D by [Andrej Mitrovic].
Compiler Version Compatibility
Currently DMD v2.065 (or any other compiler based on the same fronted) is required.
You can use [dub] to make this library a dependency for your project.
-version=NAME switches are supported:
Make private or package fields public. This switch will enable you to directly manipulate internal fields. However this is not future-compatible since these fields might be reordered or changed in the future. You should prefer to use accessor methods unless performance demands that you directly manipulate internal fields.
Enable internal library warnings. When the internal state is in an
unexpected state turning this switch on will print out warnings to
the standard error stream (
By default all floating-point types are declared as
float. Enabling this
switch will use
double types instead.
Note: Regardless of this switch, the D compiler will still use
for floating-point calculations, meaning that enabling this switch will
likely not give you a big improvement in accuracy. On the other hand
double's will use twice as much memory and could lead to a
Warning: There is a large performance hit when enabling this switch and using DMD.
Running the examples
Most examples require the [GLFW] library. See the [GLFW] homepage on how to obtain this library.
Compile and run one of the examples via:
# Showcases a simple iteration of the physics engine without any drawing. dub run dchip:simple # Contains a series of visual and interactive demos, selectable with the keyboard. # Select each of the demo's by pressing the keys 'a' through 'y'. dub run dchip:demo # Similar to the above, but demos were based on the older v5.3.5 version and they # use the [SDL] library (which means you'll have to install [SDL] to run it). dub run dchip:old_demo # Build with another compiler, in release mode (Run `dub build --help` for more help) dub --compiler=ldc2 --build=release
old_demo examples are based on the v5.3.5 version and require
[SDL] rather than [GLFW].
Note: If you're using Windows you might get dub errors when automatically
running the samples. The samples should still be built and located in the
Note: As of 04 February 2014, building with LDC2 from the latest prepackaged
binary of LDC2 on Windows might produce crashing applications.
However the latest LDC2 built from source (commit
using the MinGW instructions
is known to work.
dchip is a straight port of the C library to D all existing C-based
documentation should be applicable and easily transferable to D with very little
to no code modification. In particular, the Chipmunk2D documentation will
come in handy:
- Chipmunk2D v6.2.1 documentation.
You can import the
dchip.all module to bring in the entire library at your disposal.
Alternatively if you're using the latest compiler (e.g. 2.065+ or git-head) you may
use the new package module feature and import
Most dchip types have getter and setter functions to access and modify internal fields,
for example the
cpArbiter's internal fields such as the
e field for elasticity
can be accessed and manipulated with this code:
cpArbiter * arb cpFloat elasticity = cpArbiterGetElasticity(arb); // get the internal 'e' field elasticity += 1.0; cpArbiterSetElasticity(arb, elasticity); // set the internal 'e' field
The getters and setters are auto-generated via a mixin template, such as:
// Inject 'cpArbiterGetElasticity' and 'cpArbiterSetElasticity' which // operate on a `cpFloat` type. mixin CP_DefineArbiterStructProperty!(cpFloat, "e", "Elasticity");
Some dchip types only define getters and not setters, via:
// Inject 'cpBodyGetRot', which returns the internal 'rot' field of // type 'cpVect'. mixin CP_DefineBodyStructGetter!(cpVect, "rot", "Rot");
As mentioned in the
Building section above, passing the
version flag allows you to access all fields directly rather than through getter and
setter functions. However, using the internal fields directly is not future-proof as
these internal fields are not part of the public API and may change at any future
Additionally, setter functions typically perform additional actions, for example
cpBody setters usually call
cpBodyActivate before assigning to an internal field,
followed by a call to
cpBodyAssertSane. If you ever have bodies that seem to
"hang in the air", they might be sleeping, so make sure you call
before manipulating internal fields.
Distributed under the MIT License. See the accompanying file LICENSE.txt.
- Registered by Henning Pohl
- 0.1.3 released 5 years ago
- Copyright (c) 2007-2013 Scott Lembcke and Howling Moon Software
- Sub packages:
- dchip:simple, dchip:demo, dchip:old_demo
0.1.3 2017-Oct-05 0.1.2 2015-Feb-01 0.1.1 2014-Aug-22 0.1.0 2014-May-23 0.0.1 2014-May-15
- Download Stats:
0 downloads today
0 downloads this week
1 downloads this month
235 downloads total
- Short URL: