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