home *** CD-ROM | disk | FTP | other *** search
/ A Virtual Reality Guide to Texas / CD.iso / texdata / arcextra / ghost.dir / 00019_BangRunner.ls < prev    next >
Encoding:
Text File  |  1998-05-18  |  1.6 KB  |  59 lines

  1. property BangSprite, LastCallTime, BGSprite, NewBangPos, TurnTime, RunningDirection, RunningSpeed, IntersectedLast
  2.  
  3. on birth me
  4.   set BGSprite to 2
  5.   set BangSprite to 5
  6.   set LastCallTime to the ticks
  7.   set NewBangPos to 0
  8.   set TurnTime to the ticks + 60
  9.   set RunningSpeed to 2
  10.   set RunningDirection to 1
  11.   puppetSprite(BangSprite, 1)
  12.   return me
  13. end
  14.  
  15. on RunBang me
  16.   set StartLeft to the left of sprite BGSprite
  17.   if (the ticks - LastCallTime) > 1 then
  18.     if NewBangPos <= 100 then
  19.       set RunningDirection to 1
  20.     end if
  21.     if NewBangPos >= 800 then
  22.       set RunningDirection to -1
  23.     end if
  24.     if sprite 17 intersects BangSprite and not IntersectedLast then
  25.       if RunningDirection = -1 then
  26.         set NewDirection to 1
  27.       end if
  28.       if RunningDirection = 1 then
  29.         set NewDirection to -1
  30.       end if
  31.       set RunningDirection to NewDirection
  32.       Bounce()
  33.       set TurnTime to the ticks + 60
  34.       set RunningSpeed to 5
  35.       set IntersectedLast to 1
  36.     end if
  37.     if the ticks > TurnTime then
  38.       set NewRunDirection to random(2)
  39.       if NewRunDirection = 1 then
  40.         set RunningDirection to 1
  41.       else
  42.         set RunningDirection to -1
  43.       end if
  44.       set RunningSpeed to random(10)
  45.       set TurnTime to the ticks + random(300)
  46.       set IntersectedLast to 0
  47.     end if
  48.     if RunningDirection = 1 then
  49.       set the memberNum of sprite BangSprite to 86
  50.     end if
  51.     if RunningDirection = -1 then
  52.       set the memberNum of sprite BangSprite to 85
  53.     end if
  54.     set NewBangPos to (RunningDirection * RunningSpeed) + NewBangPos
  55.     set LastCallTime to the ticks
  56.   end if
  57.   set the locH of sprite BangSprite to NewBangPos + StartLeft
  58. end
  59.