home *** CD-ROM | disk | FTP | other *** search
/ GQ - Louise, World Cup, …remy Clarkson, Armageddon / GQCD.iso / files / game.dxr / 00007_asteroidScript.ls < prev    next >
Encoding:
Text File  |  1998-05-21  |  2.2 KB  |  80 lines

  1. property ancestor, myAngle, myDistance, animCounter, myName, myVelocity, myEnergy, myValue, myDamage, DESTROYED, mySound
  2. global gShipObj, asteroidList
  3.  
  4. on new me, angle, type, speed, energy, whichSound
  5.   set ancestor to new(script "spriteGenerator")
  6.   set myDistance to 700.0
  7.   set myAngle to angle
  8.   set myName to the memberNum of member type
  9.   set myVelocity to speed
  10.   set myEnergy to energy
  11.   set mySound to whichSound
  12.   set myValue to energy * 10
  13.   set DESTROYED to 0
  14.   append(the actorList, me)
  15.   appear(me, getLoc(myAngle, myDistance), type, 255, 0, 100)
  16.   return me
  17. end
  18.  
  19. on stepFrame me
  20.   animateRock(me)
  21.   moveRock(me)
  22. end
  23.  
  24. on moveRock me
  25.   set myDistance to myDistance - myVelocity
  26.   if myDistance > 180.0 then
  27.     set the loc of sprite the spriteNum of me to getLoc(myAngle, myDistance)
  28.     if DESTROYED then
  29.       set DESTROYED to 0
  30.       set myCurrentNum to myName + animCounter + 30
  31.       set the memberNum of sprite the spriteNum of me to myCurrentNum
  32.       set myEnergy to myEnergy - myDamage
  33.       if myEnergy < 0.10000000000000001 then
  34.         increaseEnergyLevel(gGameObj, myValue)
  35.         deleteAt(asteroidList, getPos(asteroidList, me))
  36.         explode(me, myName + 60)
  37.       end if
  38.     end if
  39.   else
  40.     if myDistance > 80.0 then
  41.       set the loc of sprite the spriteNum of me to getLoc(myAngle, myDistance)
  42.       fadeOutRock(me)
  43.     else
  44.       increaseEnergyLevel(gGameObj, -(myValue * 2))
  45.       deleteAt(asteroidList, getPos(asteroidList, me))
  46.       playSound(2, mySound)
  47.       destroy(me)
  48.     end if
  49.   end if
  50. end
  51.  
  52. on fadeOutRock me
  53.   set fadeNum to integer(myDistance - 80.0)
  54.   if fadeNum > 100 then
  55.     set fadeNum to 100
  56.   end if
  57.   set the blend of sprite the spriteNum of me to fadeNum
  58. end
  59.  
  60. on animateRock me
  61.   set animCounter to animCounter + 1
  62.   if animCounter > 29 then
  63.     set animCounter to 0
  64.   end if
  65.   set myMemberNum to myName + animCounter
  66.   set the memberNum of sprite the spriteNum of me to myMemberNum
  67. end
  68.  
  69. on setDamage me, amount
  70.   set myDamage to amount
  71. end
  72.  
  73. on explode me, member
  74.   set startposition to the loc of sprite the spriteNum of me
  75.   destroy(me)
  76.   playSound(2, mySound)
  77.   set explosion to new(script "explosionScript", member, 20, myDistance, myAngle, myVelocity, 0)
  78.   appear(explosion, startposition, member, 255, 0, 50)
  79. end
  80.