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

  1. property ancestor, myAngle, myDistance, myPower, DESTROYED
  2. global gShipObj, gGameObj, asteroidList
  3.  
  4. on new me, angle, hyp, power
  5.   set ancestor to new(script "spriteGenerator")
  6.   set myDistance to hyp
  7.   set myAngle to angle
  8.   set myPower to power
  9.   set DESTROYED to 0
  10.   append(the actorList, me)
  11.   return me
  12. end
  13.  
  14. on stepFrame me
  15.   hitRockCheck(me)
  16.   moveRocket(me)
  17. end
  18.  
  19. on moveRocket me
  20.   set myDistance to myDistance + 10
  21.   if (myDistance < 700.0) and not DESTROYED then
  22.     set the loc of sprite the spriteNum of me to getLoc(myAngle, myDistance)
  23.   else
  24.     destroy(me)
  25.     depleteRocketNum(gShipObj)
  26.   end if
  27. end
  28.  
  29. on hitRockCheck me
  30.   repeat with i = 1 to count(asteroidList)
  31.     set asteroid to getAt(asteroidList, i)
  32.     if collision(the spriteNum of me, the spriteNum of asteroid) then
  33.       set the DESTROYED of me to 1
  34.       setDamage(asteroid, myPower, the loc of sprite the spriteNum of me)
  35.       set the DESTROYED of asteroid to 1
  36.       exit repeat
  37.     end if
  38.   end repeat
  39. end
  40.  
  41. on collision interceptor, target
  42.   set myLoch to the locH of sprite interceptor
  43.   set myLocv to the locV of sprite interceptor
  44.   set leftLoch to the locH of sprite interceptor - (the width of the member of sprite interceptor / 4)
  45.   set topLocv to the locV of sprite interceptor - (the height of the member of sprite interceptor / 4)
  46.   set rightLoch to the locH of sprite interceptor + (the width of the member of sprite interceptor / 4)
  47.   set bottomLocv to the locV of sprite interceptor + (the height of the member of sprite interceptor / 4)
  48.   set minLoch to the left of sprite target
  49.   set maxLoch to the right of sprite target
  50.   set minLocv to the top of sprite target
  51.   set maxLocv to the bottom of sprite target
  52.   if ((myLoch > minLoch) and (myLoch < maxLoch) and ((myLocv > minLocv) and (myLocv < maxLocv))) or ((leftLoch > minLoch) and (leftLoch < maxLoch) and ((topLocv > minLocv) and (topLocv < maxLocv))) or ((rightLoch > minLoch) and (rightLoch < maxLoch) and ((bottomLocv > minLocv) and (bottomLocv < maxLocv))) then
  53.     return 1
  54.   end if
  55.   return 0
  56. end
  57.