home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 March / CHIP Turkiye Mart 1999.iso / araclar / Win98 / HTML-Tool / DWESD.EXE / data.z / bubbles.dcr / 00004_Behavior - move sprite.ls < prev    next >
Encoding:
Text File  |  1998-04-02  |  3.2 KB  |  64 lines

  1. property pResetSpritePosition, pTriggerResetPosition, pWhichDirection, pSpeed, pStartH, pOffsetFrequency, pNewTriggerResetPosition
  2.  
  3. on beginSprite me
  4.   set pStartH to the locH of sprite the spriteNum of me
  5.   set pNewTriggerResetPosition to pTriggerResetPosition + -random(50)
  6.   set the locH of sprite the spriteNum of me to the locH of sprite the spriteNum of me + random(8)
  7. end
  8.  
  9. on enterFrame me
  10.   if pWhichDirection = #up then
  11.     if the locV of sprite the spriteNum of me > pNewTriggerResetPosition then
  12.       set pNewTriggerResetPosition to pTriggerResetPosition + -random(50)
  13.       set the locV of sprite the spriteNum of me to the locV of sprite the spriteNum of me - pSpeed
  14.       set testForOffset to random(pOffsetFrequency)
  15.       if testForOffset = 2 then
  16.         set hOffset to -1
  17.       else
  18.         if testForOffset = 1 then
  19.           set hOffset to 1
  20.         else
  21.           set hOffset to 0
  22.         end if
  23.       end if
  24.       set the locH of sprite the spriteNum of me to the locH of sprite the spriteNum of me + hOffset
  25.     else
  26.       set the locV of sprite the spriteNum of me to pResetSpritePosition + random(8)
  27.     end if
  28.     if (the locH of sprite the spriteNum of me > 151) or (the locH of sprite the spriteNum of me < -8) then
  29.       set the locV of sprite the spriteNum of me to pResetSpritePosition + random(8)
  30.       set the locH of sprite the spriteNum of me to pStartH
  31.     end if
  32.   end if
  33.   if pWhichDirection = #down then
  34.     if the locV of sprite the spriteNum of me < pTriggerResetPosition then
  35.       set the locV of sprite the spriteNum of me to the locV of sprite the spriteNum of me + pSpeed
  36.     else
  37.       set the locV of sprite the spriteNum of me to pResetSpritePosition
  38.     end if
  39.   end if
  40.   if pWhichDirection = #left then
  41.     if the locH of sprite the spriteNum of me > pTriggerResetPosition then
  42.       set the locH of sprite the spriteNum of me to the locH of sprite the spriteNum of me - pSpeed
  43.     else
  44.       set the locH of sprite the spriteNum of me to pResetSpritePosition
  45.     end if
  46.   end if
  47.   if pWhichDirection = #right then
  48.     if the locH of sprite the spriteNum of me < pTriggerResetPosition then
  49.       set the locH of sprite the spriteNum of me to the locH of sprite the spriteNum of me + pSpeed
  50.     else
  51.       set the locH of sprite the spriteNum of me to pResetSpritePosition
  52.     end if
  53.   end if
  54. end
  55.  
  56. on getPropertyDescriptionList
  57.   set propertyDescriptionList to [#pWhichDirection: [#comment: "Which direction:", #format: #symbol, #range: [#up, #down, #left, #right], #default: #up], #pSpeed: [#comment: "What speed (#pixels per frame):", #format: #integer, #default: 1], #pTriggerResetPosition: [#comment: "Postion that triggers reset:", #format: #integer, #default: 0], #pResetSpritePosition: [#comment: "Position to reset to:", #format: #integer, #default: 0], #pOffsetFrequency: [#comment: "Offset frequency (bigger number is less frequent)", #format: #integer, #default: 4]]
  58.   return propertyDescriptionList
  59. end
  60.  
  61. on getBehaviorDescription
  62.   return "This behavior will move a sprite automatically up, down, left, or right at 1 or more pixels per frame, and also loop the motion.  You need to set the position the sprite will get to before resetting itself and the position it should reset itself to."
  63. end
  64.