' test of: DynamicObjectSetRestitution
#include once "InitGL.bi"
#define USEDEBUG ' "optional" enable debug rendering and error report in file "debug.txt"
#include once "TrueAxis.bi"

sub _TrueAxisInit_ constructor
  InitGL()
  PhysicsCreateInstance()
end sub

sub _TrueAxisExit_ destructor
  PhysicsDestroyInstance()
end sub

const NCUBES=10
' create a dynamic cube 
dim as DynamicObject ptr cubes(NCUBES-1)

for i as integer=0 to NCUBES-1
 cubes(i) = DynamicObjectCreateNew()
 DynamicObjectInitialiseAsACube(cubes(i),0,0,0, 1)
 DynamicObjectSetPosition(cubes(i),-10+i*2,20,0)
 DynamicObjectSetRestitution(cubes(i),-0.4+i*0.1333)
 PhysicsAddDynamicObject cubes(i)
next

' create a static ground (25m x 25m)
PhysicsAddStaticGround(25)

' render and simulation loop
dim as integer frames
while inkey=""
  ' one step in simulation
  PhysicsUpdate(1.0/75.0)
  if frames mod 3=0 then
    glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
    glLoadIdentity
    glTranslatef 0,-3,-20
    ' draw all objects (only in debug mode) 
    PhysicsRender()
    flip
  end if
  Sleep(10)
  frames+=1
wend

