Personally I would do this using proper gravitation physics as it would look nicer / more realistic. Using your previous program as a basis, I knocked this up quickly to give you a start ...
Press SPACE to reset.
Stevie
Press SPACE to reset.
Stevie
Graphics3D 640,480,32,1 Global camera = CreateCamera() PositionEntity camera, 0,50,0 RotateEntity camera, 90,0,0 Global Sphere = CreateSphere() EntityColor Sphere,255,0,0 Tmp = CreateSphere( 8 , Sphere ) ScaleEntity Tmp, 5, 5, 5 EntityAlpha Tmp, .25 Global CubePiv = CreatePivot() Global Cube = CreateCube( CubePiv ) EntityColor Cube, 0,0,255 Global RotationSpeed# = 2.0 Global RotationTimer Global RotationDirection RESET() While Not KeyDown(1) If KeyHit(57) RESET() UPDATE() RenderWorld() Flip Wend ;================================================================== ;================================================================== ;================================================================== Function UPDATE() If GetParent( CubePiv ) = Sphere If RotationTimer <= ( 180 / RotationSpeed ) TurnEntity Sphere, 0 , RotationDirection * RotationSpeed , 0 RotationTimer = RotationTimer + 1 Else EntityParent( CubePiv, 0 ) RotationTimer = -1 EndIf Else If EntityDistance( CubePiv, Sphere ) < 5 And RotationTimer = 0 TFormPoint 0,0,0,CubePiv, Sphere If TFormedX() < 0 RotationDirection = 1 Else RotationDirection = - 1 EndIf EntityParent CubePiv, Sphere Else MoveEntity CubePiv, 0,0,.25 EndIf EndIf TurnEntity Cube, 0,5,0 End Function ;================================================================== ;================================================================== ;================================================================== Function RESET() EntityParent CubePiv, 0 RotationTimer = 0 RotateEntity Sphere, 0 , Rand(-180,180 ) , 0 RotateEntity CubePiv, 0 , EntityYaw( Sphere ) - 180 , 0 TFormPoint 4 * ( Rand(0,1) * 2 - 1 ) ,0,Rand(30,50 ), Sphere, 0 PositionEntity CubePiv, TFormedX(), TFormedY(), TFormedZ() End Function