I'm currently replacing a physics-engine I wrote myself by Chipmunk. Congratulations, it seems to do an awesome job. Especially the great documentation and highly intuitive API impressed me and finally convinced me to switch.
The project I'm working at is a little game. It features diffent types of vehicles: A tank, a jeep, a bugyy and a helicopter. Now I'm currently trying to get the tank to work right:
Code: Select all
if (Key_Acceleration) {
cpVect f = cpvforangle(VehicleShape->body->a);
cpBodyApplyForce(VehicleShape->body, f, cpvzero);
} else if (Key_Deceleration) {
cpVect f = cpvneg(cpvforangle(VehicleShape->body->a));
cpBodyApplyForce(VehicleShape->body, f, cpvzero);
} else {
cpBodyResetForces(VehicleShape->body);
}
cpFloat v = cpvlength(VehicleShape->body->v);
if (v > Current_MaxSpeed) {
VehicleShape->body->v = cpvmult(VehicleShape->body->v, Current_MaxSpeed / v);
}
if (Key_Left) {
VehicleShape->body->a += (-3.0 / 180.0 * M_PI);
if (VehicleShape->body->a < 0) VehicleShape->body->a += 2 * M_PI;
} else if (Key_Right) {
VehicleShape->body->a += (3.0 / 180.0 * M_PI);
if (VehicleShape->body->a > 2 * M_PI) VehicleShape->body->a -= 2 * M_PI;
}
It's hard to explain (even more so since English is not my first language), I hope you unterstand :-/
Greetings,
Thanks in advance,
Johannes
PS: I noticed some minor flaws in the documentation: cpCircleShapeNew's prototype is given as cpBody*, cpVect, cpFloat - it is, however, cpBody*, cpFloat, cpVect. Also the prototype of cpSpaceNew takes one parameter (int) in the documentation whereas the implementation says it takes no paramters. And the cpSpaceFreeChildren() prototype is duplicate in the documentation.