on getBehaviorDescription
set string1 = "This program lets a sprite move around another with a sinusoidal motion."
set string2 = "You have to choose the x and y amplitude, angular frequency, and phase angle."
set st25 = " Phase angle should be set between 0.0 and 2.0."
set string3 = "You need to have a central sprite, and if you plan to move it around, choose that option. In your score you place the central sprite in one channel, and the object you want to rotate in another channel. The default value is one channel above the central sprite."
set st4 = "The motion can also be constrained to the x or y direction."
set st5 = "Visit http://www.ExploreScience.com/ to see this in action."
set mytext = string1&RETURN&RETURN&string2&st25&RETURN&RETURN&string3&RETURN&RETURN&st4&RETURN&RETURN&st5
return mytext
end getBehaviorDescription
on getPropertyDescriptionList
set goodNum = the currentSpriteNum - 1
set des = [:]
addprop des,#xAmpl,[#default:100,#format:#integer,#comment:"X Amplitude:"]
addprop des,#yAmpl,[#default:100,#format:#integer,#comment:"Y Amplitude:"]
addprop des,#omegaX,[#default:1.,#format:#float,#comment:"X ang freq:"]
addprop des,#omegaY,[#default:1.,#format:#float,#comment:"Y ang freq:"]
addprop des,#phiX,[#default:0.0,#format:#float,#comment:"X phase shift (*pi):"]
addprop des,#phiY,[#default:0.0,#format:#float,#comment:"Y phase shift (*pi):"]
addprop des,#theSpriteIorbit,[#default:goodNum,#format:#integer,#comment:"Central Sprite:"]
addprop des,#deltaTime,[#default:0.1,#format:#float,#comment:"Time increment:"]
addprop des,#activeCenter,[#default:0,#format:#boolean,#comment:"Moving Center Sprite:"]
addprop des,#activeXmotion,[#default:1,#format:#boolean,#comment:"Active X motion:"]
addprop des,#activeYmotion,[#default:1,#format:#boolean,#comment:"Active Y motion:"]
addprop des,#activeTrails,[#default:1,#format:#boolean,#comment:"Active Trails:"]
return des
end getPropertyDescriptionList
on beginSprite me
set the trails of sprite the currentSpriteNum = FALSE
set myTime = 0.0
set phiX = phiX*pi()
set phiY = phiY*pi()
set xHome = the locH of sprite thespriteIorbit
set yHome = the locV of sprite theSpriteIorbit
set x to xAmpl*cos(omegaX*myTime+phiX)
set y to yAmpl*sin(omegaY*myTime+phiY)
set the locH of sprite the currentSpriteNum to (xHome+x)
set the locV of sprite the currentSpriteNum to (yHome-y)
set the trails of sprite the currentSpriteNum = activeTrails
end
on exitFrame me
if activeCenter then
set xHome = the locH of sprite thespriteIorbit
set yHome = the locV of sprite theSpriteIorbit
end if
if activeXmotion then
set x to xAmpl*cos(omegaX*myTime+phiX)
set the locH of sprite the currentSpriteNum to (xHome+x)
end if
if activeYmotion then
set y to yAmpl*sin(omegaY*myTime+phiY)
set the locV of sprite the currentSpriteNum to (yHome-y)
end if
set myTime = myTime + deltaTime
end
on activateMyTrails me
if activeTrails then
set activeTrails = FALSE
set the trails of sprite the currentSpriteNum = FALSE
else
set activeTrails = TRUE
set the trails of sprite the currentSpriteNum = FALSE
end if
end
on changeMyPhi me, phi1,phi2
if phi1 = VOID then
nothing
else
set phix = phi1
end if
if phi2 = VOID then
nothing
else
set phiy = phi2
end if
end
on changeMyOmega me, Omega1,Omega2
if Omega1 = VOID then
nothing
else
set Omegax = Omega1
end if
if Omega2 = VOID then
nothing
else
set Omegay = Omega2
end if
end
on changeMyAmp me, amp1,amp2
if amp1 = VOID then
nothing
else
set xAmpl = amp1
end if
if amp2 = VOID then
nothing
else
set yAmpl = amp2
end if
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA