REM Demonstration of the Box2D (v2.2.1 or v2.3.1) Physics Engine REM by Richard Russell, http://www.rtrussell.co.uk/, 26-Jan-2013 MODE 8 : OFF INSTALL @lib$+"box2dlib" : PROC_b2Init INSTALL @lib$+"box2ddbg" ON ERROR PROCcleanup : IF ERR=17 CHAIN @lib$+"../examples/tools/touchide" ELSE ERROR 0,REPORT$+" at line "+STR$ERL ON CLOSE PROCcleanup : QUIT gravity_x = 0.0 gravity_y = -9.8 myWorld%% = FN_b2CreateWorld(gravity_x, gravity_y) PROC_b2DebugInit(myWorld%%, %01011, 20) ground%% = FN_b2StaticBox(myWorld%%, 16.0, 0.1, 0.0, 16.0, 0.1) platform%% = FN_b2KinematicBody(myWorld%%, 4.0, 12.0, 0, 3.0, 0, 0, 0, 0) fixture%% = FN_b2BoxFixture(platform%%, 0, 0, 0, 4.0, 0.3, 0.0, 0.0, 1.0) DIM x(2), y(2) x() = -0.5, 0.5, 0.0 y() = 0.0, 0.0, 1.5 body%% = FN_b2DynamicBody(myWorld%%, 10.0, 20.0, 0.0, 0, 0, 0.2, 0, 0) fixture%% = FN_b2PolygonFixture(body%%, 3, x(), y(), 0.0, 0.6, 1.0) timeStep = 1.0/60.0 velIterations% = 8 posIterations% = 3 *REFRESH OFF REPEAT CLS PROC_b2WorldStep(myWorld%%, timeStep, velIterations%, posIterations%) PROC_b2DebugDraw(myWorld%%) *REFRESH WAIT 1 IF INKEY(-1) PROC_b2DebugFlags(4, 0) ELSE PROC_b2DebugFlags(4, 4) UNTIL FALSE PROCcleanup END DEF PROCcleanup myWorld%% += 0 : IF myWorld%% PROC_b2DestroyWorld(myWorld%%) : myWorld%% = 0 PROC_b2Exit ENDPROC