Hi Sreedhar,
Here is a simple behavior to move a sprites randomly inside the stage. No
elasticity, may be someone here can help you on that or else you go through
the articles at www.director-online.com if need to implement physics related
stuff in Lingo.
Copy this into a script window and make sure script property is set to
Behavior.
------------------- drag this script to sprite on the
stage------------------------------
property pSprite
property pSpeed
property pDirectionH
property pDirectionV
property pLeft
property pTop
property pRight
property pBottom
on beginSprite me
pSprite = me.spriteNum
end
on exitFrame me
if sprite(pSprite).locH <= pLeft OR sprite(pSprite).locH >= pRight then
pDirectionH = pDirectionH * -1
end if
if sprite(pSprite).locV <= pTop OR sprite(pSprite).locV >= pBottom then
pDirectionV = pDirectionV * -1
end if
sprite(pSprite).locH = sprite(pSprite).locH + random(pSpeed) * pDirectionH
sprite(pSprite).locV = sprite(pSprite).locV + random(pSpeed) * pDirectionV
end
on getPropertyDescriptionList me
pdList = [:]
pdList.addProp(#pSpeed,[#comment:"Speed of movement inpixels", #default:3,
#format:#integer])
pdList.addProp(#pDirectionH,[#comment:"Horizontal direction (1 / -1)",
#default:1, #format:#integer])
pdList.addProp(#pDirectionV,[#comment:"Vericalal direction (1 / -1)",
#default:-1, #format:#integer])
pdList.addProp(#pLeft,[#comment:"Left edge in pixels", #default:0,
#format:#integer])
pdList.addProp(#pTop,[#comment:"Top edge in pixels", #default:0,
#format:#integer])
pdList.addProp(#pRight,[#comment:"Right edge in pixels", #default:640,
#format:#integer])
pdList.addProp(#pBottom,[#comment:"Bottom edge in pixels", #default:480,
#format:#integer])
return pdList
end
--------------------------Script ends------------------------
regards
Ramesh C T
-----Original Message-----
From: sreedhar reddy <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Friday, October 06, 2000 2:09 PM
Subject: <lingo-l> creating behaviours
>hello all
>i just want to make a behaviour which makes the sprite
>move randomly on the stage and also the restricts the
>movement of the sprite to the stage only and at the
>same time when the sprite touchec the edges of teh
>stage it should bounce back normally with an option
>for the use to control the elasticity as well as the
>speed of the bounce
>please help me out
>sreedhar
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]