SetGravity


Sets gravity (motion down) on an object.

 object.SetGravity(speed) 

Parameters

speed

Refers to the rate at which the object will drop.

Notes

The larger the value, the faster the drop. Please note that using negative values will cause the object to rise instead of drop.

Sample Code

The following code will drop the sphere using the gravity command until it reaches a y value of “100, at which point it will be moved back to its starting point.

Please note as well that the Stop command will not stop an object under the gravity command. You must stop it by setting gravity to zero.

 oworld = New World(); ocamera = New Camera(oworld); // Create sphere 100 around, and place it at (0,300,0). osphere = oworld.CreateSphere(100,100,100) osphere.Set Position(0,300,0); ocamera.MoveBack(1200); osphere.set gravity(0.01); //Loop While(TRUE)  {   If((osphere.gety) < -100)    {     Osphere.SetPosition(0,300,0);    } } 



Elementary Game Programming and Simulators Using Jamagic
Elementary Game Programming & Simulations Using Jamagic (Charles River Media Game Development)
ISBN: 1584502614
EAN: 2147483647
Year: 2002
Pages: 105
Authors: Sergio Perez

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net