Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
RGB Hex Module
Bubble Sort Algorithm (for Strings)
Getting full error messages
Distance Sensitive Button
Milliseconds
Fade In Out Text
Easy Dialog
3D SpeedPort Xtra
Basic 4 direction environment navigation
myPrint
MediaMacros Xtras Mall
 

 

 

Behavior Orbital Slave

Added on 6/10/1999

 

Compatibilities:
behavior D6_5 Mac PC

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  

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail