home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / pc / tutorial / devglry / vanguard / source / balls.dir / 00019.ls < prev    next >
Encoding:
Text File  |  1996-04-22  |  2.5 KB  |  90 lines

  1. on startMovie
  2.   global gBounceRect, Inertia, gravity, gDeltaShowLoc, gDeltaViewSprite
  3.   set gDeltaViewSprite to 7
  4.   set gDeltaShowLoc to [the locH of sprite gDeltaViewSprite, the locV of sprite gDeltaViewSprite]
  5.   set Inertia to 1.0956999999999999
  6.   set gravity to 8.69079999999999941
  7.   set gBounceRect to [the stageLeft, the stageRight, the stageTop, the stageBottom]
  8. end
  9.  
  10. on runGame
  11.   global gDeltaShowLoc, gDeltaViewSprite
  12.   setPuppet()
  13.   set gameSP to 4
  14.   set howMany to 18
  15.   set baseCast to 1
  16.   set speed to 1
  17.   set counter to 0
  18.   set Shipdelta to [0, 0]
  19.   repeat while not (the mouseDown)
  20.     set when to the ticks + speed
  21.     set the castNum of sprite gameSP to baseCast + (counter mod howMany)
  22.     set Shipdelta to move(gameSP, Shipdelta)
  23.     Update(when)
  24.     set counter to counter + 1
  25.     showDelta(Shipdelta, gDeltaViewSprite)
  26.   end repeat
  27.   set the castNum of sprite gameSP to baseCast
  28.   updateStage()
  29.   go("Pause")
  30. end
  31.  
  32. on unPuppet
  33.   repeat with x = 1 to 48
  34.     puppetSprite(x, 0)
  35.   end repeat
  36. end
  37.  
  38. on setPuppet
  39.   repeat with x = 1 to 48
  40.     puppetSprite(x, 1)
  41.   end repeat
  42. end
  43.  
  44. on Update when
  45.   repeat while the ticks < when
  46.   end repeat
  47.   updateStage()
  48. end
  49.  
  50. on showDelta delta, gDeltaViewSprite
  51.   global gDeltaShowLoc
  52.   set the locH of sprite gDeltaViewSprite to getAt(gDeltaShowLoc, 1) + (getAt(delta, 1) / 5)
  53.   set the locV of sprite gDeltaViewSprite to getAt(gDeltaShowLoc, 2) + (getAt(delta, 2) / 5)
  54. end
  55.  
  56. on move whichChan, delta
  57.   global Inertia, gravity
  58.   set deltaH to (the mouseH - the locH of sprite whichChan) / gravity
  59.   set deltaV to (the mouseV - the locV of sprite whichChan) / gravity
  60.   set newvector to [(getAt(delta, 1) + deltaH) / Inertia, (getAt(delta, 2) + deltaV) / Inertia]
  61.   set the locH of sprite whichChan to the locH of sprite whichChan + getAt(newvector, 1)
  62.   set the locV of sprite whichChan to the locV of sprite whichChan + getAt(newvector, 2)
  63.   return newvector
  64. end
  65.  
  66. on setVarPos
  67.   global gravity, Inertia
  68.   set topPos to 99
  69.   set the locH of sprite 4 to 134
  70.   set the locV of sprite 4 to topPos + (181 - ((gravity - 1) / 0.08839999999999999))
  71.   set the locH of sprite 5 to 286
  72.   set the locV of sprite 5 to topPos + (181 - ((Inertia - 1.0) / 0.0011))
  73. end
  74.  
  75. on GetInertiaFromPos
  76.   global Inertia
  77.   set lowPos to 181 + 99
  78.   set pos to the locV of sprite 5
  79.   set value to lowPos - pos
  80.   set Inertia to 1.0 + (value * 0.0011)
  81. end
  82.  
  83. on GetGravityFromPos
  84.   global gravity
  85.   set lowPos to 181 + 99
  86.   set pos to the locV of sprite 4
  87.   set value to lowPos - pos
  88.   set gravity to (value * 0.08839999999999999) + 1
  89. end
  90.