home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / DogFight.dxr / 00010.ls < prev    next >
Encoding:
Text File  |  2002-01-31  |  15.8 KB  |  461 lines

  1. global playerSO, bulletSO, enemySO, targetSO, bombSO, backGroundSO, shadowSO, maxBullets, maxEnemies, maxtargets, maxShadows, playerData, enemyData, pBulletData, bombData, inputString, particleSO, maxParticles
  2.  
  3. on initializeConstants
  4.   backGroundSO = 10
  5.   playerSO = 20
  6.   bulletSO = 30
  7.   maxBullets = 6
  8.   enemySO = 40
  9.   maxEnemies = 45
  10.   targetSO = 75
  11.   maxtargets = 10
  12.   bombSO = 90
  13.   particleSO = 95
  14.   maxParticles = 25
  15.   shadowSO = 130
  16.   maxShadows = maxEnemies + 1
  17. end
  18.  
  19. on initializeStuff
  20.   global BGtileHeight
  21.   bgScroll = 0
  22.   BGtileHeight = 256
  23.   repeat with wBG = 1 to 5
  24.     wSprite = backGroundSO + wBG
  25.     puppetSprite(wSprite, 1)
  26.     set the member of sprite wSprite to "Terrain 1"
  27.     yloc = 0 - BGtileHeight + (BGtileHeight * wBG) + bgScroll
  28.     xloc = 0
  29.     set the loc of sprite wSprite to point(xloc, yloc)
  30.     sprite(wSprite).locZ = 5
  31.     set the blend of sprite wSprite to 100
  32.   end repeat
  33.   playerData = [1, 0, point(490, 300), point(0, 0), 0, 0]
  34.   puppetSprite(playerSO, 1)
  35.   set the member of sprite playerSO to "PP_00"
  36.   set the ink of sprite playerSO to 36
  37.   sprite(playerSO).locZ = 21
  38.   bombData = [0, point(0, 0), 0, 0]
  39.   puppetSprite(playerSO + 1, 1)
  40.   set the member of sprite (playerSO + 1) to "Player Bomb Target"
  41.   set the ink of sprite (playerSO + 1) to 36
  42.   sprite(playerSO + 1).locZ = 22
  43.   puppetSprite(bombSO, 1)
  44.   set the ink of sprite bombSO to 36
  45.   sprite(bombSO).locZ = 19
  46.   pBulletData = []
  47.   repeat with wBullet = 1 to maxBullets
  48.     add(pBulletData, [0, 0])
  49.     puppetSprite(bulletSO + wBullet, 1)
  50.     set the member of sprite (bulletSO + wBullet) to "Player Bullet"
  51.     set the ink of sprite (bulletSO + wBullet) to 36
  52.     sprite(bulletSO + wBullet).locZ = 20
  53.   end repeat
  54.   enemyData = []
  55.   repeat with wEnemy = 1 to maxEnemies
  56.     wSprite = enemySO + wEnemy
  57.     add(enemyData, [0, 0, point(490, 300), point(0, 0), 0, 0])
  58.     puppetSprite(wSprite, 1)
  59.     set the member of sprite wSprite to "GermanPlane00"
  60.     set the ink of sprite wSprite to 36
  61.     sprite(wSprite).locZ = 19
  62.     set the loc of sprite wSprite to point(-50, -50)
  63.   end repeat
  64.   repeat with wEnemy = 1 to maxShadows
  65.     wSprite = shadowSO + wEnemy
  66.     puppetSprite(wSprite, 1)
  67.     set the member of sprite wSprite to "S_00"
  68.     set the ink of sprite wSprite to 36
  69.     sprite(wSprite).locZ = 9
  70.     sprite(wSprite).flipV = 1
  71.     set the blend of sprite wSprite to 50
  72.     set the loc of sprite wSprite to point(-50, -50)
  73.   end repeat
  74.   sprite(shadowSO + 1).flipV = 0
  75. end
  76.  
  77. on movePlayer
  78.   global wMuzzle, bombData, bombSO, bombAccuracyStats, playerData, totalScore, levelScore, deathDelay, playerInvincible, playerLives, shadowSO, playerCool
  79.   if playerData[1] = 1 then
  80.     killPlaya = 0
  81.     repeat with wEnemy = 1 to count(enemyData)
  82.       if enemyData[wEnemy][1] = 1 then
  83.         eType = enemyData[wEnemy][2]
  84.         eLoc = enemyData[wEnemy][3]
  85.         if eType <> 1 then
  86.           if findDistance(eLoc, playerData[3]) <= 25 then
  87.             killPlaya = 1
  88.           end if
  89.         end if
  90.       end if
  91.     end repeat
  92.     if playerInvincible > 0 then
  93.       playerInvincible = playerInvincible - 1
  94.       killPlaya = 0
  95.     end if
  96.     if killPlaya = 1 then
  97.       playerData[1] = 0
  98.       addparticle(5, playerData[3] * 10, point(0, 0))
  99.       deathDelay = 45
  100.       playerLives = playerLives - 1
  101.       set the member of sprite 770 to "Lives Display " & string(playerLives)
  102.       playerInvincible = 60
  103.       playSound("Player Die", 5)
  104.     end if
  105.   end if
  106.   if playerData[1] = 1 then
  107.     if inputString[1] = 1 then
  108.       playerData[4][1] = playerData[4][1] - 2
  109.     else
  110.       if inputString[2] = 1 then
  111.         playerData[4][1] = playerData[4][1] + 2
  112.       else
  113.         playerData[4][1] = playerData[4][1] * 0.80000000000000004
  114.       end if
  115.     end if
  116.     if inputString[4] = 1 then
  117.       playerData[4][2] = playerData[4][2] - 2
  118.     else
  119.       if inputString[3] = 1 then
  120.         playerData[4][2] = playerData[4][2] + 2
  121.       else
  122.         playerData[4][2] = playerData[4][2] * 0.80000000000000004
  123.       end if
  124.     end if
  125.     foundSlot = 0
  126.     if (inputString[6] = 1) and (bombData[1] = 0) then
  127.       playerData[6] = playerData[6] + 1
  128.       set the loc of sprite (playerSO + 1) to playerData[3] + point(0, -150)
  129.     else
  130.       if playerData[6] > 2 then
  131.         bombData = [1, playerData[3] + point(0, -150), 150, 34, 0]
  132.         playSound("dropBomb", 3)
  133.       else
  134.         set the loc of sprite (playerSO + 1) to point(-100, -100)
  135.       end if
  136.       playerData[6] = 0
  137.     end if
  138.     if playerCool > 0 then
  139.       playerCool = playerCool - 1
  140.     else
  141.       playerCool = 2
  142.       if (inputString[5] = 1) and (playerData[6] = 0) then
  143.         playSound("machinegun", 4)
  144.         repeat with wSearch = 1 to count(pBulletData)
  145.           if (value(pBulletData[wSearch][1]) = 0) and (foundSlot = 0) then
  146.             if wMuzzle >= 4 then
  147.               wMuzzle = 1
  148.             else
  149.               wMuzzle = wMuzzle + 1
  150.             end if
  151.             foundSlot = 1
  152.             pBulletData[wSearch] = [1, playerData[3], 0, 0]
  153.           end if
  154.         end repeat
  155.       end if
  156.     end if
  157.     if playerData[4][1] > 9 then
  158.       playerData[4][1] = 9
  159.     end if
  160.     if playerData[4][1] < -9 then
  161.       playerData[4][1] = -9
  162.     end if
  163.     if playerData[4][2] > 9 then
  164.       playerData[4][2] = 9
  165.     end if
  166.     if playerData[4][2] < -9 then
  167.       playerData[4][2] = -9
  168.     end if
  169.     if integer(playerData[4][1]) = 0 then
  170.       set the member of sprite playerSO to "PP_00"
  171.     else
  172.       if playerData[4][1] > 0 then
  173.         set the member of sprite playerSO to "PP_R" & string(abs(integer(playerData[4][1])))
  174.       else
  175.         if playerData[4][1] < 0 then
  176.           set the member of sprite playerSO to "PP_L" & string(abs(integer(playerData[4][1])))
  177.         end if
  178.       end if
  179.     end if
  180.     playerData[3] = playerData[3] + playerData[4]
  181.     drawMuzzle = 1
  182.     set the loc of sprite playerSO to playerData[3]
  183.   else
  184.     set the loc of sprite playerSO to point(-50, -50)
  185.   end if
  186.   if bombData[1] = 1 then
  187.     bombData[4] = bombData[4] - 1.5
  188.     if bombData[4] > 0 then
  189.       bombData[2] = bombData[2] + point(0, 1)
  190.       bombData[3] = bombData[3] * 10 / 11
  191.       set the loc of sprite bombSO to bombData[2] + point(0, bombData[3])
  192.       bombData[5] = bombData[5] + 1
  193.       set the member of sprite bombSO to "Bomb" & string(integer(bombData[5]))
  194.     else
  195.       enemyHit = 0
  196.       testHeight = 0
  197.       repeat with wEnemy = 1 to count(enemyData)
  198.         if (enemyData[wEnemy][1] = 1) and (enemyData[wEnemy][2] = 1) then
  199.           if enemyData[wEnemy][8] = 0 then
  200.             testDist = findDistance(enemyData[wEnemy][3], bombData[2])
  201.             if testDist <= 30 then
  202.               enemyHit = wEnemy
  203.             end if
  204.           end if
  205.         end if
  206.       end repeat
  207.       bombAccuracyStats[1] = bombAccuracyStats[1] + 1
  208.       if enemyHit <> 0 then
  209.         enemyData[enemyHit][6] = enemyData[enemyHit][6] + 100
  210.       else
  211.         addEnemy(1, bombData[2], 9)
  212.       end if
  213.       playSound("explosion", 3)
  214.       addparticle(4, bombData[2] * 10, point(0, 10))
  215.       bombData[1] = 0
  216.       set the loc of sprite bombSO to point(-100, -100)
  217.     end if
  218.   end if
  219.   repeat with wBullet = 1 to count(pBulletData)
  220.     bSprite = bulletSO + wBullet
  221.     if pBulletData[wBullet][1] = 1 then
  222.       if pBulletData[wBullet][4] = 0 then
  223.         enemyHit = 0
  224.         testHeight = 0
  225.         repeat with wEnemy = 1 to count(enemyData)
  226.           if (enemyData[wEnemy][1] = 1) and (pBulletData[wBullet][1] = 1) and (enemyData[wEnemy][2] <> 1) then
  227.             if enemyData[wEnemy][3][2] < playerData[3][2] then
  228.               testDist = abs(pBulletData[wBullet][2][1] - enemyData[wEnemy][3][1])
  229.               if testDist <= 20 then
  230.                 if enemyData[wEnemy][3][2] > testHeight then
  231.                   testHeight = enemyData[wEnemy][3][2]
  232.                   enemyHit = wEnemy
  233.                 end if
  234.               end if
  235.             end if
  236.           end if
  237.         end repeat
  238.         oldMuzzlePosList = [15, -25, 25, -15]
  239.         muzzlePosList = [0, 0, 0, 0]
  240.         repeat with wAim = 1 to 4
  241.           newAim = 90 + (abs(integer(playerData[4][1])) * 36 / 4)
  242.           locX = integer(sin(newAim * PI / 180) * oldMuzzlePosList[wAim])
  243.           muzzlePosList[wAim] = locX
  244.         end repeat
  245.         if enemyHit <> 0 then
  246.           enemyData[enemyHit][6] = enemyData[enemyHit][6] + 1
  247.           set the loc of sprite (enemySO + enemyHit) to point(-50, -50)
  248.           set the locV of sprite bSprite to enemyData[enemyHit][3][2]
  249.           pBulletData[wBullet][2] = point(playerData[3][1], enemyData[enemyHit][3][2] + 25) + point(muzzlePosList[wMuzzle], -15)
  250.           pBulletData[wBullet][3] = abs(enemyData[enemyHit][3][2] - playerData[3][2]) / 5 * 3
  251.         else
  252.           pBulletData[wBullet][2] = playerData[3] + point(0, -300) + point(muzzlePosList[wMuzzle], -15)
  253.           pBulletData[wBullet][3] = 300 / 5 * 3
  254.         end if
  255.       else
  256.         if pBulletData[wBullet][4] <= 8 then
  257.           set the member of sprite bSprite to "Player Bullet"
  258.           set the loc of sprite bSprite to pBulletData[wBullet][2]
  259.           set the height of sprite bSprite to pBulletData[wBullet][3]
  260.           set the width of sprite bSprite to 1
  261.           pBulletData[wBullet][3] = pBulletData[wBullet][3] / 1.80000000000000004
  262.         else
  263.           set the loc of sprite bSprite to point(-50, -50)
  264.           pBulletData[wBullet][1] = 0
  265.         end if
  266.       end if
  267.       pBulletData[wBullet][4] = pBulletData[wBullet][4] + 1
  268.       next repeat
  269.     end if
  270.     set the loc of sprite bSprite to point(-50, -50)
  271.   end repeat
  272. end
  273.  
  274. on addEnemy spawnType, spawnLoc, extraBit
  275.   global levelDelay
  276.   validSlot = 0
  277.   repeat with wScan = 1 to count(enemyData)
  278.     if (validSlot = 0) and (enemyData[wScan][1] = 0) then
  279.       validSlot = wScan
  280.     end if
  281.   end repeat
  282.   if validSlot <> 0 then
  283.     if spawnType = 1 then
  284.       case random(3) of
  285.         1:
  286.           rBit = random(3)
  287.         otherwise:
  288.           rBit = random(2) + 3
  289.       end case
  290.       rBit = extraBit
  291.     end if
  292.     if extraBit = 9 then
  293.       healthState = 600
  294.     else
  295.       healthState = 0
  296.     end if
  297.     enemyData[validSlot] = [1, spawnType, spawnLoc, 0, random(500) + 40, healthState, 0, 0, rBit]
  298.   end if
  299. end
  300.  
  301. on moveEnemies
  302.   global levelScore, bombData, bombAccuracyStats, totalEnemies, totalScore, shadowData, shadowSO
  303.   shadowData = []
  304.   if playerData[1] = 1 then
  305.     add(shadowData, [playerData[3], integer(playerData[4][1])])
  306.   else
  307.     add(shadowData, [point(-1500, -1500), integer(playerData[4][1])])
  308.   end if
  309.   totalEnemies = 0
  310.   updatePScore = 0
  311.   repeat with wEnemy = 1 to count(enemyData)
  312.     wSprite = enemySO + wEnemy
  313.     if enemyData[wEnemy][1] = 1 then
  314.       terminate = 0
  315.       neutralized = 0
  316.       if enemyData[wEnemy][3][2] > 530 then
  317.         neutralized = 1
  318.       end if
  319.       case enemyData[wEnemy][2] of
  320.         1:
  321.           moveSpeed = point(0, 1)
  322.           maxHealth = 2
  323.           theDepth = 10
  324.           sweepingMove = 0
  325.           if enemyData[wEnemy][8] = 0 then
  326.             memName = "Structure " & ["A", "B", "C", "D", "E", "F", "G", "H", "I"][enemyData[wEnemy][9]] & "1"
  327.             if enemyData[wEnemy][6] >= maxHealth then
  328.               terminate = 1
  329.             end if
  330.             theDepth = 12
  331.           else
  332.             memName = "Structure " & ["A", "B", "C", "D", "E", "F", "G", "H", "I"][enemyData[wEnemy][9]] & "2"
  333.             theDepth = 10
  334.           end if
  335.           if enemyData[wEnemy][9] <= 4 then
  336.             totalEnemies = totalEnemies + 1
  337.           end if
  338.         2:
  339.           memName = "GermanPlane"
  340.           moveSpeed = point(0, 2)
  341.           maxHealth = 4
  342.           theDepth = 20
  343.           sweepingMove = 1
  344.           if enemyData[wEnemy][6] >= maxHealth then
  345.             terminate = 1
  346.           end if
  347.           totalEnemies = totalEnemies + 1
  348.           add(shadowData, [enemyData[wEnemy][3], enemyData[wEnemy][7]])
  349.       end case
  350.       if (terminate = 0) and (neutralized = 0) then
  351.         if sweepingMove = 1 then
  352.           if enemyData[wEnemy][4] > 0 then
  353.             enemyData[wEnemy][4] = enemyData[wEnemy][4] - 1
  354.           else
  355.             enemyData[wEnemy][4] = 25 + random(60)
  356.             enemyData[wEnemy][5] = random(500) + 40
  357.           end if
  358.           currMoveSpeed = enemyData[wEnemy][7] * 4
  359.           if enemyData[wEnemy][3][1] > (enemyData[wEnemy][5] - currMoveSpeed) then
  360.             enemyData[wEnemy][7] = enemyData[wEnemy][7] - 1
  361.           else
  362.             if enemyData[wEnemy][3][1] < (enemyData[wEnemy][5] + currMoveSpeed) then
  363.               enemyData[wEnemy][7] = enemyData[wEnemy][7] + 1
  364.             else
  365.               if enemyData[wEnemy][7] > 0 then
  366.                 enemyData[wEnemy][7] = enemyData[wEnemy][7] - 1
  367.               else
  368.                 if enemyData[wEnemy][7] < 0 then
  369.                   enemyData[wEnemy][7] = enemyData[wEnemy][7] + 1
  370.                 end if
  371.               end if
  372.             end if
  373.           end if
  374.           if enemyData[wEnemy][7] > 9 then
  375.             enemyData[wEnemy][7] = 9
  376.           end if
  377.           if enemyData[wEnemy][7] < -9 then
  378.             enemyData[wEnemy][7] = -9
  379.           end if
  380.           if enemyData[wEnemy][7] > 0 then
  381.             memName = memName & "R" & string(abs(enemyData[wEnemy][7]))
  382.             shadeName = "S_R" & string(abs(enemyData[wEnemy][7]))
  383.           else
  384.             if enemyData[wEnemy][7] < 0 then
  385.               memName = memName & "L" & string(abs(enemyData[wEnemy][7]))
  386.               shadeName = "S_L" & string(abs(enemyData[wEnemy][7]))
  387.             else
  388.               memName = memName & "00"
  389.               shadeName = "S_00"
  390.             end if
  391.           end if
  392.           moveSpeed[1] = enemyData[wEnemy][7]
  393.         end if
  394.         shadeSprite = shadowSO + wEnemy
  395.         enemyData[wEnemy][3] = enemyData[wEnemy][3] + moveSpeed
  396.         set the loc of sprite wSprite to enemyData[wEnemy][3]
  397.         set the member of sprite wSprite to memName
  398.         sprite(wSprite).locZ = theDepth
  399.         set the member of sprite shadeSprite to shadeName
  400.         next repeat
  401.       end if
  402.       if neutralized = 0 then
  403.         if enemyData[wEnemy][2] = 1 then
  404.           if enemyData[wEnemy][8] = 0 then
  405.             if enemyData[wEnemy][9] <= 4 then
  406.               eOffset = [point(10, 10), point(-10, 10), point(10, -10), point(-10, -10)]
  407.               repeat with woff = 1 to count(eOffset)
  408.                 addparticle(4, enemyData[wEnemy][3] * 10, point(0, 10) + (eOffset[woff] * 2))
  409.               end repeat
  410.               eOffset = [point(15, 0), point(-15, 0), point(0, -15), point(0, 15)]
  411.               repeat with woff = 1 to count(eOffset)
  412.                 addparticle(4, enemyData[wEnemy][3] * 10, point(0, 10) + (eOffset[woff] * 2))
  413.               end repeat
  414.               levelScore = levelScore + 25
  415.               bombAccuracyStats[2] = bombAccuracyStats[2] + 1
  416.               updatePScore = 1
  417.             end if
  418.             enemyData[wEnemy][8] = 1
  419.           end if
  420.           set the loc of sprite wSprite to enemyData[wEnemy][3]
  421.           enemyData[wEnemy][3] = enemyData[wEnemy][3] + point(0, 1)
  422.         else
  423.           addparticle(5, enemyData[wEnemy][3] * 10, point(0, 20))
  424.           levelScore = levelScore + 10
  425.           playSound("explosion", 5)
  426.           updatePScore = 1
  427.           enemyData[wEnemy][1] = 0
  428.           set the loc of sprite wSprite to point(-100, -100)
  429.         end if
  430.         next repeat
  431.       end if
  432.       enemyData[wEnemy][1] = 0
  433.       set the loc of sprite wSprite to point(-100, -100)
  434.     end if
  435.   end repeat
  436.   maxShadows = maxEnemies + 1
  437.   repeat with wScan = 1 to maxShadows
  438.     wSprite = shadowSO + wScan
  439.     sprite(wSprite).locZ = 10
  440.     if wScan > count(shadowData) then
  441.       set the loc of sprite wSprite to point(-100, -100)
  442.       next repeat
  443.     end if
  444.     set the loc of sprite wSprite to shadowData[wScan][1] + point(20, 20)
  445.     frameNum = shadowData[wScan][2]
  446.     if frameNum > 0 then
  447.       memName = "S_R" & string(abs(frameNum))
  448.     else
  449.       if frameNum < 0 then
  450.         memName = "S_L" & string(abs(frameNum))
  451.       else
  452.         memName = "S_00"
  453.       end if
  454.     end if
  455.     set the member of sprite wSprite to memName
  456.   end repeat
  457.   if updatePScore = 1 then
  458.     member("Player Score Display").text = string(levelScore + totalScore)
  459.   end if
  460. end
  461.