Contents Articles Behaviors Books Director News Director Web Sites FAQ Games Mailing Lists News Groups Project Examples Reviews Software Tools Useful Web Sites Utilities Xtras

Don't miss these
 Asteroids Game simINET Xtra 27 Sum Game-Game Fields Hold for MPEG then go to marker X Morph a Vector graphics Removing the stage border DateTimeXtra Mile High Table O'Products Installed ActiveX Set ImageEnabled Property of a Flash Member

# Orbital Slave

 Compatibilities: This item has not yet been rated

Author: MichaelSeery

Use with orbital master behavior

 property planetList property currentForces on exitFrame me   -- calculate all forces:   set currentForces = [:]   repeat with planet in planetList          set F = [ #X:0, #Y:0 ]          set planetChan = the channel of planet     set planetObject = the object of planet          repeat with neighbor in planetList              set neighborChan = the channel of neighbor       set neighborObject = the object of neighbor              if planetChan <> neighborChan then                  --calculate the distance between the two planets:         set deltaLoc = the location of sprite neighborChan - the location of sprite planetChan           set dX = the X of deltaLoc         set dY = the Y of deltaLoc         set r = sqrt( dX*dX + dY*dY ) + 0.01                  --calculate the force between the two planets:         set tempF = the mass of planetObject * the mass of neighborObject / r         set Fx = tempF * dX / r         set Fy = tempF * dY / r         set F = F + [ #X:Fx, #Y:Fy ]                end if            end repeat          addProp currentForces, planetObject, F          end repeat      -- transmit net forces:   repeat with planet = count( currentForces ) down to 1     set thePlanetObj = getPropAt( currentForces, planet )     set theForce = getAt( currentForces, planet )     call( #push, thePlanetObj, theForce )   end repeat end on orbitalBodyReadyToRegister me, planetObject   if planetList <> VOID then     call( #registerOrbitalBodies, planetObject, planetList )   end if end on orbitalBodyReadyToRemove me, planetObject   if planetList <> VOID then     call( #removeOrbitalBodies, planetObject, planetList )   end if end on beginSprite me   set planetList = []   sendAllSprites( #registerOrbitalBodies, planetList ) end on endSprite me   set planetList = []   sendAllSprites( #removeOrbitalBodies, planetList ) end

 Contact MMI 36 South Court Sq Suite 300 Newnan, GA 30263 USA Send e-mail