home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / WaterFight.dxr / 00002.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  10.4 KB  |  318 lines

  1. on initializeConstants
  2.   global dropEffectSO, dropFrames, maximumDrops, beamEffectSO, beamFrames, maximumBeams, cloudEffectSO, cloudFrames, maximumClouds
  3.   dropEffectSO = 100
  4.   dropFrames = 6
  5.   maximumDrops = 30
  6.   beamEffectSO = 30
  7.   beamFrames = 6
  8.   maximumBeams = 0
  9.   cloudEffectSO = 30
  10.   cloudFrames = 6
  11.   maximumClouds = 70
  12. end
  13.  
  14. on initializeDrops
  15.   global dropEffectSO, dropData, dropFrames, maximumDrops
  16.   dropData = []
  17.   repeat with wDrop = 1 to maximumDrops
  18.     wSprite = wDrop + dropEffectSO
  19.     set the loc of sprite wSprite to point(-50, -50)
  20.     add(dropData, [0, point(0, 0), 0, 0, 0, 0, 0])
  21.   end repeat
  22. end
  23.  
  24. on addDrop addLoc, addheight, addGrav
  25.   global dropEffectSO, dropData
  26.   validSlot = 0
  27.   repeat with wScan = 1 to count(dropData)
  28.     if (validSlot = 0) and (dropData[wScan][1] = 0) then
  29.       validSlot = wScan
  30.     end if
  31.   end repeat
  32.   spreadTime = 0
  33.   repeat while addLoc[2] < 280
  34.     addLoc[2] = addLoc[2] + 10
  35.     addheight = addheight - 10
  36.     spreadTime = 1
  37.   end repeat
  38.   if validSlot <> 0 then
  39.     wSprite = dropEffectSO + validSlot
  40.     dropData[validSlot] = [1, addLoc, addheight, addGrav, random(180) + 90, random(75) / 10.0, 0, #Na]
  41.     set the blend of sprite wSprite to 100
  42.     set the loc of sprite wSprite to addLoc
  43.   end if
  44. end
  45.  
  46. on moveBaloon
  47.   global throwState, throwDist, startLoc, TargetLoc, monsterData, monsterhitRange, playerScore, idleLoc
  48.   if throwDist >= 12 then
  49.     throwState = 0
  50.     throwDist = 0
  51.     repeat with whichDrop = 1 to 15
  52.       addDrop(TargetLoc + point(0, 25), -25, 0 - (random(350) / 10.0))
  53.     end repeat
  54.     playSound("Splash", 1)
  55.   end if
  56.   if throwState = 0 then
  57.     repeat with whichMonster = 1 to count(monsterData)
  58.       bPoint = TargetLoc
  59.       if bPoint <> VOID then
  60.         if monsterData[whichMonster][1] = 1 then
  61.           if monsterData[whichMonster][2] = 2 then
  62.             mRect = monsterhitRange[whichMonster]
  63.             if inside(bPoint, mRect) = 1 then
  64.               monsterData[whichMonster][2] = 4
  65.               TargetLoc = VOID
  66.               playerScore[monsterData[whichMonster][5]] = playerScore[monsterData[whichMonster][5]] + 1
  67.               integerScore = (playerScore[1] * 30) + (playerScore[2] * 50) - (playerScore[3] * 20)
  68.               if integerScore <= 0 then
  69.                 integerScore = 0
  70.               end if
  71.               member("Level Score").text = string(integerScore)
  72.               playSound("Hit enemy " & string(random(3)), 2)
  73.             end if
  74.           end if
  75.         end if
  76.       end if
  77.     end repeat
  78.     TargetLoc = VOID
  79.     idleLoc = point(290, 420) + point((the mouseH - 290) / 3, (the mouseV - 100) / 12)
  80.     set the loc of sprite 131 to idleLoc
  81.     set the width of sprite 131 to 100
  82.     set the height of sprite 131 to 85
  83.   else
  84.     dAim = throwDist * 15
  85.     locX = sin(dAim * PI / 180) * 125
  86.     throwDist = throwDist + 1
  87.     locMod = (startLoc - TargetLoc) / 12.0
  88.     newloc = startLoc - (locMod * throwDist) - point(0, locX)
  89.     modSize = 99 / 15.0
  90.     realSize = modSize * (15 - throwDist)
  91.     set the loc of sprite 131 to newloc
  92.     set the width of sprite 131 to realSize
  93.     set the height of sprite 131 to realSize
  94.   end if
  95. end
  96.  
  97. on moveDrops
  98.   global dropEffectSO, dropData, dropFrames
  99.   warpSides = 0
  100.   splashLocList = []
  101.   repeat with wDrop = 1 to 30
  102.     wSprite = wDrop + dropEffectSO
  103.     dAim = dropData[wDrop][5]
  104.     dSpeed = dropData[wDrop][6]
  105.     if dropData[wDrop][1] = 1 then
  106.       locY = cos(dAim * PI / 180) * -dSpeed / 3.0
  107.       locX = sin(dAim * PI / 180) * dSpeed
  108.       movePoint = point(locX, locY)
  109.       dropData[wDrop][2] = dropData[wDrop][2] + movePoint
  110.       if warpSides = 1 then
  111.         if dropData[wDrop][2][1] > 580 then
  112.           dropData[wDrop][2][1] = dropData[wDrop][2][1] - 580
  113.         end if
  114.         if dropData[wDrop][2][1] < 0 then
  115.           dropData[wDrop][2][1] = dropData[wDrop][2][1] + 580
  116.         end if
  117.         if dropData[wDrop][2][2] > 440 then
  118.           dropData[wDrop][2][2] = dropData[wDrop][2][2] - 440
  119.         end if
  120.         if dropData[wDrop][2][2] < 0 then
  121.           dropData[wDrop][2][2] = dropData[wDrop][2][2] + 440
  122.         end if
  123.       end if
  124.       dropData[wDrop][4] = dropData[wDrop][4] + 2.0
  125.       dropData[wDrop][3] = dropData[wDrop][3] + dropData[wDrop][4]
  126.       dLoc = dropData[wDrop][2] + point(0, dropData[wDrop][3])
  127.       if dropData[wDrop][3] > 0 then
  128.         if (dropData[wDrop][3] > 4) and (random(2) = 1) then
  129.           add(splashLocList, dLoc)
  130.         end if
  131.         dropData[wDrop][1] = 0
  132.         set the loc of sprite wSprite to point(-50, -50)
  133.         addCloud(dLoc, 1 + (random(4) / 10.0))
  134.         next repeat
  135.       end if
  136.       if dropData[wDrop][8] = #Na then
  137.         sprite(wSprite).rotation = 0
  138.       else
  139.         newRotate = findAngle(dLoc, dropData[wDrop][8])
  140.         sprite(wSprite).rotation = newRotate
  141.       end if
  142.       dropData[wDrop][8] = dLoc
  143.       set the loc of sprite wSprite to dLoc
  144.       sprite(wSprite).locZ = dropData[wDrop][2][2]
  145.     end if
  146.   end repeat
  147.   repeat with whichSplash = 1 to count(splashLocList)
  148.   end repeat
  149. end
  150.  
  151. on initializeBeams
  152.   global beamEffectSO, beamData, beamFrames
  153.   beamData = []
  154.   repeat with wBeam = 1 to 30
  155.     wSprite = wBeam + beamEffectSO
  156.     add(beamData, [0, 0])
  157.   end repeat
  158. end
  159.  
  160. on moveBeams
  161.   global beamEffectSO, beamData, beamFrames
  162.   repeat with wBeam = 1 to 30
  163.     if beamData[wBeam][1] = 1 then
  164.     end if
  165.   end repeat
  166. end
  167.  
  168. on initializeClouds
  169.   global cloudEffectSO, cloudData, cloudFrames, maximumClouds
  170.   cloudData = []
  171.   repeat with wCloud = 1 to maximumClouds
  172.     wSprite = wCloud + cloudEffectSO
  173.     add(cloudData, [0, 0, 0, point(0, 0)])
  174.   end repeat
  175. end
  176.  
  177. on addCloud addLoc, addScale
  178.   global cloudEffectSO, cloudData, cloudFrames
  179.   validSlot = 0
  180.   repeat with wScan = 1 to count(cloudData)
  181.     if (validSlot = 0) and (cloudData[wScan][1] = 0) then
  182.       validSlot = wScan
  183.     end if
  184.   end repeat
  185.   if validSlot <> 0 then
  186.     wSprite = cloudEffectSO + validSlot
  187.     cloudData[validSlot] = [1, -40, addScale, addLoc]
  188.     baseSize = (15 + (1 * cloudData[validSlot][2])) * cloudData[validSlot][3]
  189.     set the width of sprite wSprite to baseSize
  190.     set the height of sprite wSprite to baseSize / 3
  191.     set the blend of sprite wSprite to 100
  192.     set the loc of sprite wSprite to addLoc
  193.     sprite(wSprite).locZ = addLoc[2] - integer(baseSize / 3)
  194.   end if
  195. end
  196.  
  197. on moveClouds
  198.   global cloudEffectSO, cloudData, cloudFrames
  199.   repeat with wCloud = 1 to count(cloudData)
  200.     wSprite = cloudEffectSO + wCloud
  201.     if cloudData[wCloud][1] = 1 then
  202.       cloudData[wCloud][2] = cloudData[wCloud][2] + 1
  203.       if cloudData[wCloud][2] > 10 then
  204.         cloudData[wCloud] = [0, 0, 0, point(0, 0)]
  205.         set the loc of sprite wSprite to point(-50, -50)
  206.       end if
  207.     end if
  208.     if cloudData[wCloud][1] = 1 then
  209.       timeC = cloudData[wCloud][2]
  210.       if timeC < 1 then
  211.         timeC = 1
  212.       end if
  213.       baseSize = 75 - ((15 + (2 * timeC)) * cloudData[wCloud][3] * 2)
  214.       set the width of sprite wSprite to baseSize
  215.       set the height of sprite wSprite to baseSize / 2
  216.       set the blend of sprite wSprite to 100
  217.     end if
  218.   end repeat
  219. end
  220.  
  221. on applyMonsters
  222.   global monsterData, spawnDelay
  223.   spawnDelay = spawnDelay + 1
  224.   if spawnDelay > 60 then
  225.     spawnDelay = random(40)
  226.     validSlotList = []
  227.     repeat with whichSlot = 1 to count(monsterData)
  228.       if monsterData[whichSlot][1] = 0 then
  229.         add(validSlotList, whichSlot)
  230.       end if
  231.     end repeat
  232.     repeat with whichMon = 1 to random(3)
  233.       if count(validSlotList) > 0 then
  234.         rPick = random(count(validSlotList))
  235.         pickedSlot = validSlotList[rPick]
  236.         monsterData[pickedSlot] = [1, 1, -75, point(0, 0), random(3), 0]
  237.         deleteAt(validSlotList, rPick)
  238.       end if
  239.     end repeat
  240.   end if
  241. end
  242.  
  243. on moveMonsters
  244.   global monsterData, monasterInitialLocs, totalValidTargets, whichLevel
  245.   monsterSO = 10
  246.   repeat with wMonster = 1 to 12
  247.     wSprite = monsterSO + wMonster
  248.     appendation = ["A", "A", "A", "A", "B", "B", "B", "C", "C", "C", "C", "C", "C"][wMonster]
  249.     if monsterData[wMonster][1] = 1 then
  250.       case monsterData[wMonster][2] of
  251.         1:
  252.           maxheight = 0
  253.           if monsterData[wMonster][3] < maxheight then
  254.             monsterData[wMonster][3] = monsterData[wMonster][3] + 12
  255.           end if
  256.           if monsterData[wMonster][3] >= maxheight then
  257.             monsterData[wMonster][2] = 2
  258.             monsterData[wMonster][3] = maxheight
  259.             if random(10) = 1 then
  260.               monsterData[wMonster][6] = 3
  261.             else
  262.               monsterData[wMonster][6] = 60 + [60, 45, 30, 15, 0][whichLevel]
  263.               if monsterData[wMonster][5] <> 3 then
  264.                 totalValidTargets = totalValidTargets + 1
  265.               else
  266.               end if
  267.             end if
  268.           end if
  269.           set the loc of sprite wSprite to monasterInitialLocs[wMonster] + point(0, 0 - monsterData[wMonster][3])
  270.           set the member of sprite wSprite to "Target " & string(monsterData[wMonster][5]) & string(appendation)
  271.         2:
  272.           monsterData[wMonster][6] = monsterData[wMonster][6] - 1
  273.           if monsterData[wMonster][6] <= 0 then
  274.             monsterData[wMonster][2] = 3
  275.           end if
  276.         3:
  277.           if monsterData[wMonster][3] > -175 then
  278.             monsterData[wMonster][3] = monsterData[wMonster][3] - 12
  279.           end if
  280.           if monsterData[wMonster][3] <= -175 then
  281.             monsterData[wMonster][1] = 0
  282.             monsterData[wMonster][2] = 0
  283.             monsterData[wMonster][3] = -175
  284.           end if
  285.           set the loc of sprite wSprite to monasterInitialLocs[wMonster] + point(0, 0 - monsterData[wMonster][3])
  286.         4:
  287.           if monsterData[wMonster][3] > -175 then
  288.             monsterData[wMonster][3] = monsterData[wMonster][3] - 12
  289.           end if
  290.           if monsterData[wMonster][3] <= -175 then
  291.             monsterData[wMonster][1] = 0
  292.             monsterData[wMonster][2] = 0
  293.             monsterData[wMonster][3] = -175
  294.           end if
  295.           set the loc of sprite wSprite to monasterInitialLocs[wMonster] + point(0, 0 - monsterData[wMonster][3])
  296.           set the member of sprite wSprite to "hit " & string(monsterData[wMonster][5]) & string(appendation)
  297.       end case
  298.     end if
  299.   end repeat
  300. end
  301.  
  302. on throwBaloon
  303.   global throwState, throwDist, startLoc, TargetLoc, idleLoc
  304.   if throwState = 0 then
  305.     throwState = 1
  306.     throwDist = 0
  307.     startLoc = idleLoc
  308.     TargetLoc = the mouseLoc + point(0, 25)
  309.   end if
  310. end
  311.  
  312. on playSound whichSound, whichSlot
  313.   global lastClear
  314.   sound(whichSlot).stop()
  315.   sound(whichSlot).queue([#member: member(whichSound)])
  316.   sound(whichSlot).play()
  317. end
  318.