Gamestudio/A8 contains a physics subsystem based on the PhysX™ Engine by nVIDIA, which allows for realistic motion of models. The basic functions support rigid bodies and joints. With additional plugins, deformable bodies, liquids, cloth and many other effects can be supported.
Because this type of simulation is CPU resp. GPU intensive, the physics subsystem is disabled by default. When you wish to use it, include the ackphysx.h header, and call physX_open(). Afterwards you can load a level and register dynamic physics objects for the simulation. This delegates exclusive motion control of those objects to the engine; they can not be moved anymore by changing their position. When you no longer need a physics entity, unregister it or disable the physics system.
physX_ | Global functions that open or close the physics simulator. |
pX_ | Global functions that change the behavior of the physics simulator or the simulated world |
pXent_ | Physical entity functions which operate on a single entity at a time |
pXcon_ | Constraint functions, which limit the movement of physical entities |
#include <default.c>
#include <ackphysx.h>
function main() { physX_open(); level_load(""); // load an empty level vec_set(camera.x,vector(-100,0,30)); pXent_settype (NULL,PH_STATIC,PH_PLANE); // create a static plane at groundlevel zero ENTITY* ball = ent_create(SPHERE_MDL,vector(0,0,100),NULL); pXent_settype (ball,PH_RIGID,PH_SPHERE ); // create a ball pXent_setelasticity(ball,50); pXent_addvelcentral(ball,vector(0,-10,0)); // make it jump and roll sidewards while(1){ pX_pick(); // pick and move the ball with the cursor wait(1); } }