home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / BounceBack.dxr / 00007_Ball_script.ls < prev    next >
Encoding:
Text File  |  2002-01-31  |  5.7 KB  |  204 lines

  1. property spriteNum, pLoc, pSpeed, pMoveH, pMoveV, pFlash, pTemp
  2. global gLocH, gLocV, myAngle, h, v, gBallSpeed, gBallDirection, gPaddleHits, gPause, gLevel, gPaddle, gGoBall
  3.  
  4. on beginSprite me
  5.   gLocH = 290
  6.   gLocV = 264
  7.   gPaddle = 0
  8.   pFlash = 1
  9.   gBallSpeed = 4
  10.   gLocH = 290
  11.   gLocV = 264
  12.   sprite(5).locH = 290
  13.   sprite(5).locV = 264
  14.   gBallDirection = 180.0
  15.   gPaddleHits = 0
  16.   sprite(14).visible = 1
  17.   sprite(15).visible = 1
  18.   sprite(16).visible = 1
  19.   sprite(3).visible = 0
  20.   sprite(80).visible = 0
  21.   sprite(82).visible = 1
  22.   sprite(12).visible = 0
  23.   gLevel = 1
  24.   member("Level_display_a").text = "Level:" && string(gLevel)
  25.   member("Level_display_b").text = "Level:" && string(gLevel)
  26.   gScore = 0
  27.   member("Score01").text = "Score:" && string(gScore)
  28.   member("Score02").text = "Score:" && string(gScore)
  29.   cursor(200)
  30. end
  31.  
  32. on exitFrame
  33.   if gPause = 0 then
  34.     if (the timer > 195) and (the timer < 203) then
  35.       gGoBall = 1
  36.       sprite(82).visible = 0
  37.       sprite(80).visible = 0
  38.     end if
  39.     if gGoBall = 1 then
  40.       BallFly()
  41.       sprite(80).visible = 0
  42.       if gPaddle = 1 then
  43.         sprite(2).member = "ship_frame " & pFlash
  44.         pTemp = pTemp + 1
  45.         if pTemp > 2 then
  46.           pFlash = pFlash + 1
  47.           pTemp = 1
  48.         end if
  49.         if pFlash >= 5 then
  50.           pFlash = 1
  51.           gPaddle = 0
  52.         end if
  53.       end if
  54.     else
  55.       if the timer > 203 then
  56.         gamePaused()
  57.       end if
  58.     end if
  59.   end if
  60. end
  61.  
  62. on BallFly me
  63.   pMyAngle = gBallDirection * PI / 180.0
  64.   h = sin(pMyAngle) * gBallSpeed
  65.   v = -cos(pMyAngle) * gBallSpeed
  66.   gLocH = gLocH + h
  67.   gLocV = gLocV + v
  68.   sprite(4).loc = point(gLocH, gLocV)
  69.   updateStage()
  70.   wallBounce()
  71.   paddleBounce()
  72.   sprite(spriteNum).loc = point(gLocH, gLocV)
  73. end
  74.  
  75. on wallBounce me
  76.   if sprite(4).intersects(9) then
  77.     puppetSound(2, "hitwall")
  78.     gLocH = gLocH - h
  79.     gLocV = gLocV - v
  80.     gBallDirection = 270 - gBallDirection + 90
  81.   end if
  82.   if sprite(4).intersects(8) then
  83.     puppetSound(2, "hitwall")
  84.     gLocH = gLocH - h
  85.     gLocV = gLocV - v
  86.     gBallDirection = 90 - gBallDirection + 270
  87.   end if
  88.   if sprite(4).locV < 9 then
  89.     puppetSound(2, "hitwall")
  90.     gLocH = gLocH - h
  91.     gLocV = gLocV - v
  92.     gBallDirection = 180 - gBallDirection + 360
  93.   end if
  94.   if gBallDirection > 360 then
  95.     gBallDirection = gBallDirection - 360
  96.   else
  97.     if gBallDirection < 0 then
  98.       gBallDirection = gBallDirection + 360
  99.     end if
  100.   end if
  101. end
  102.  
  103. on paddleBounce me
  104.   if ((sprite(spriteNum).locV + 8) < 390) and ((sprite(spriteNum).locV + 8) > 300) then
  105.     if sprite(2).intersects(4) then
  106.       gPaddle = 1
  107.       puppetSound(2, "hit paddle")
  108.       gPaddleHits = gPaddleHits + 1
  109.       if gBallSpeed <= 16 then
  110.         if gPaddleHits = 1 then
  111.           gBallSpeed = 7
  112.         end if
  113.         if (gPaddleHits mod 4) = 0 then
  114.           gBallSpeed = gBallSpeed + 1
  115.         end if
  116.       end if
  117.       if (sprite(4).locH <= sprite(2).locH) and (sprite(4).locH > (sprite(2).locH - 6)) then
  118.         gLocH = gLocH - h
  119.         gLocV = gLocV - v
  120.         gBallDirection = 355 - random(10)
  121.       end if
  122.       if (sprite(4).locH <= (sprite(2).locH - 6)) and (sprite(4).locH > (sprite(2).locH - 12)) then
  123.         gLocH = gLocH - h
  124.         gLocV = gLocV - v
  125.         gBallDirection = 345 - random(10)
  126.       end if
  127.       if (sprite(4).locH <= (sprite(2).locH - 12)) and (sprite(4).locH > (sprite(2).locH - 18)) then
  128.         gLocH = gLocH - h
  129.         gLocV = gLocV - v
  130.         gBallDirection = 335 - random(10)
  131.       end if
  132.       if (sprite(4).locH <= (sprite(2).locH - 18)) and (sprite(4).locH > (sprite(2).locH - 24)) then
  133.         gLocH = gLocH - h
  134.         gLocV = gLocV - v
  135.         gBallDirection = 325 - random(10)
  136.       end if
  137.       if (sprite(4).locH <= (sprite(2).locH - 24)) and (sprite(4).locH > (sprite(2).locH - 30)) then
  138.         gLocH = gLocH - h
  139.         gLocV = gLocV - v
  140.         gBallDirection = 315 - random(10)
  141.       end if
  142.       if sprite(4).locH <= (sprite(2).locH - 30) then
  143.         gLocH = gLocH - h
  144.         gLocV = gLocV - v
  145.         gBallDirection = 305 - random(10)
  146.       end if
  147.       if (sprite(4).locH >= sprite(2).locH) and (sprite(4).locH < (sprite(2).locH + 6)) then
  148.         gLocH = gLocH - h
  149.         gLocV = gLocV - v
  150.         gBallDirection = 5 + random(10)
  151.       end if
  152.       if (sprite(4).locH >= (sprite(2).locH + 6)) and (sprite(4).locH < (sprite(2).locH + 12)) then
  153.         gLocH = gLocH - h
  154.         gLocV = gLocV - v
  155.         gBallDirection = 15 + random(10)
  156.       end if
  157.       if (sprite(4).locH >= (sprite(2).locH + 12)) and (sprite(4).locH < (sprite(2).locH + 18)) then
  158.         gLocH = gLocH - h
  159.         gLocV = gLocV - v
  160.         gBallDirection = 25 + random(10)
  161.       end if
  162.       if (sprite(4).locH >= (sprite(2).locH + 18)) and (sprite(4).locH < (sprite(2).locH + 24)) then
  163.         gLocH = gLocH - h
  164.         gLocV = gLocV - v
  165.         gBallDirection = 35 + random(10)
  166.       end if
  167.       if (sprite(4).locH >= (sprite(2).locH + 24)) and (sprite(4).locH < (sprite(2).locH + 30)) then
  168.         gLocH = gLocH - h
  169.         gLocV = gLocV - v
  170.         gBallDirection = 45 + random(10)
  171.       end if
  172.       if sprite(4).locH >= (sprite(2).locH + 30) then
  173.         gLocH = gLocH - h
  174.         gLocV = gLocV - v
  175.         gBallDirection = 55 + random(10)
  176.       end if
  177.     end if
  178.   else
  179.     if sprite(spriteNum).locV > 448 then
  180.       sprite(80).play()
  181.       loseALife()
  182.     end if
  183.   end if
  184.   if gBallDirection > 360 then
  185.     gBallDirection = gBallDirection - 360
  186.   else
  187.     if gBallDirection < 0 then
  188.       gBallDirection = gBallDirection + 360
  189.     end if
  190.   end if
  191. end
  192.  
  193. on gamePaused me
  194.   if (sprite(16).visible = 1) and (sprite(12).visible = 0) then
  195.     sprite(80).visible = 1
  196.     if keyPressed(SPACE) or the mouseDown then
  197.       sprite(80).rewind()
  198.       sprite(80).visible = 0
  199.       gPause = 0
  200.       gGoBall = 1
  201.     end if
  202.   end if
  203. end
  204.