This should do the trick. It uses Cos and Sin functions to move the sphere on an eliptical orbit. Adjust the X and Y raduis's to alter the orbit.
Graphics3D 800,600
SetBuffer BackBuffer()
Global cam = CreateCamera()
PositionEntity cam,0,20,0
RotateEntity cam,90,0,0
Global cube = CreateCube()
Global s = CreateSphere()
Global orbit_raduis_x# = 10
Global orbit_raduis_y# = 5
Global angle# = 0
Global orbit_Speed# = 1
While Not KeyHit(1)
update_orbit()
UpdateWorld
RenderWorld
Flip
Wend
End
Function update_orbit()
angle = angle + orbit_speed
PositionEntity s,EntityX(cube) + Cos(angle)*orbit_raduis_x,0,EntityZ(cube) + Sin(angle)*orbit_raduis_y
End Function
The part that alters the orbit is this part:
angle = angle + orbit_speed
PositionEntity s,EntityX(cube) + Cos(angle)*orbit_raduis_x,0,EntityZ(cube) + Sin(angle)*orbit_raduis_y
The part that determines the orbit is this part. It takes the position of the cube, adds the Sin of the angle, multiplied by the orbit raduis, and the cos to the X and Z, and produces the circular movement.
|