home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / Beams.dxr / 00157_MouseInput.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  7.6 KB  |  261 lines

  1. global gBlockArray, gPeiceSelected, gPeiceX, gPeiceY, gLaserList, gOtherPeiceSelected, gLevelNum, gStupidCounter
  2.  
  3. on doMouseInput
  4.   checkMouseUp()
  5.   checkMouseDown()
  6.   checkMouseMove()
  7. end
  8.  
  9. on checkMouseUp
  10.   if (the mouseUp = 1) and (gOtherPeiceSelected = 1) then
  11.     if gBlockArray[gPeiceY][gPeiceX].getObjectType() = 1 then
  12.       gOtherPeiceSelected = 0
  13.       gBlockArray[gPeiceY][gPeiceX].rotateObject()
  14.       repeat with a = 1 to count(gLaserList)
  15.         gLaserList[a].updateLaser()
  16.       end repeat
  17.       exit
  18.     end if
  19.   end if
  20.   if (the mouseUp = 1) and (gPeiceSelected = 1) then
  21.     gPeiceSelected = 0
  22.     gBlockArray[gPeiceY][gPeiceX].dropBlock()
  23.     if ((((gBlockArray[gPeiceY][gPeiceX].getBlockPosY() - 25) / 50) + 1) = gPeiceY) and ((((gBlockArray[gPeiceY][gPeiceX].getBlockPosX() - 20) / 50) + 1) = gPeiceX) then
  24.       gBlockArray[gPeiceY][gPeiceX].rotateObject()
  25.     else
  26.       col = ((gBlockArray[gPeiceY][gPeiceX].getBlockPosY() - 25) / 50) + 1
  27.       row = ((gBlockArray[gPeiceY][gPeiceX].getBlockPosX() - 20) / 50) + 1
  28.       gBlockArray[((gBlockArray[gPeiceY][gPeiceX].getBlockPosY() - 25) / 50) + 1][((gBlockArray[gPeiceY][gPeiceX].getBlockPosX() - 20) / 50) + 1] = gBlockArray[gPeiceY][gPeiceX]
  29.       gBlockArray[gPeiceY][gPeiceX] = 0
  30.       if gBlockArray[col][row].getObjectType() = 7 then
  31.         gLaserList[gBlockArray[col][row].getLaserReference()].setDirection(gBlockArray[col][row].getOjectDirection())
  32.         gLaserList[gBlockArray[col][row].getLaserReference()].setCoordinates(col, row)
  33.       end if
  34.     end if
  35.     setAllBlocksUnlit()
  36.     repeat with a = 1 to count(gLaserList)
  37.       gLaserList[a].updateLaser()
  38.     end repeat
  39.     if checkMissionObjectives() = 1 then
  40.       if gLevelNum = 5 then
  41.         puppetSound(4, "win")
  42.         go(19)
  43.       else
  44.         puppetSound(4, "levelcomplete10")
  45.         go(34)
  46.       end if
  47.     end if
  48.   end if
  49.   gOtherPeiceSelected = 0
  50. end
  51.  
  52. on checkMouseDown
  53.   if gOtherPeiceSelected = 1 then
  54.     exit
  55.   end if
  56.   if (the mouseDown = 1) and (gPeiceSelected = 0) then
  57.     mouseX = mouseH()
  58.     mouseY = mouseV()
  59.     if (mouseX < 20) or (mouseX > 425) or (mouseY < 25) or (mouseY > 420) then
  60.       exit
  61.     end if
  62.     gPeiceX = ((mouseX - 20) / 50) + 1
  63.     gPeiceY = ((mouseY - 25) / 50) + 1
  64.     if (gPeiceX < 1) or (gPeiceX > 8) then
  65.       exit
  66.     end if
  67.     if (gPeiceY < 1) or (gPeiceY > 8) then
  68.       exit
  69.     end if
  70.     if gBlockArray[gPeiceY][gPeiceX] = 0 then
  71.       gPeiceSelected = 0
  72.     else
  73.       if gBlockArray[gPeiceY][gPeiceX].getObjMovable() = 1 then
  74.         puppetSound(1, "pick up block")
  75.         gPeiceSelected = 1
  76.       else
  77.         gOtherPeiceSelected = 1
  78.       end if
  79.     end if
  80.   end if
  81. end
  82.  
  83. on checkMouseMove
  84.   posXLock = 0
  85.   posYLock = 0
  86.   if gOtherPeiceSelected = 1 then
  87.     exit
  88.   end if
  89.   if gPeiceSelected = 0 then
  90.     exit
  91.   end if
  92.   selectedX = gBlockArray[gPeiceY][gPeiceX].getBlockPosX()
  93.   selectedY = gBlockArray[gPeiceY][gPeiceX].getBlockPosY()
  94.   mouseX = mouseH()
  95.   mouseY = mouseV()
  96.   if selectedX > mouseX then
  97.     if (selectedX - mouseX) > 20 then
  98.       mouseX = selectedX - 20
  99.     end if
  100.   else
  101.     if (mouseX - selectedX) > 20 then
  102.       mouseX = selectedX + 20
  103.     end if
  104.   end if
  105.   if selectedY > mouseY then
  106.     if (selectedY - mouseY) > 20 then
  107.       mouseY = selectedY - 20
  108.     end if
  109.   else
  110.     if (mouseY - selectedY) > 20 then
  111.       mouseY = selectedY + 20
  112.     end if
  113.   end if
  114.   sprite(9).loc = point(mouseX, gBlockArray[gPeiceY][gPeiceX].getBlockPosY())
  115.   sprite(10).loc = point(gBlockArray[gPeiceY][gPeiceX].getBlockPosX(), mouseY)
  116.   updateStage()
  117.   counter = 51
  118.   repeat with y = 1 to 8
  119.     repeat with x = 1 to 8
  120.       if sprite(gBlockArray[gPeiceY][gPeiceX].getChannel()).intersects(counter) then
  121.         if gBlockArray[gPeiceY][gPeiceX].getChannel() <> counter then
  122.           gStupidCounter = gStupidCounter + 1
  123.         end if
  124.       end if
  125.       if (sprite(9).intersects(counter) = 1) or (sprite(10).intersects(counter) = 1) then
  126.         if not ((x = gPeiceY) and (y = gPeiceX)) then
  127.           colidedX = sprite(counter).locH
  128.           colidedY = sprite(counter).locV
  129.           if (selectedY > (colidedY + 48)) and (selectedX > (colidedX - 48)) and (selectedX < (colidedX + 48)) then
  130.             mouseY = colidedY + 50
  131.           else
  132.             if (selectedY < (colidedY - 48)) and (selectedX > (colidedX - 48)) and (selectedX < (colidedX + 48)) then
  133.               mouseY = colidedY - 50
  134.             else
  135.               if (selectedY > (colidedY - 48)) and (selectedY < (colidedY + 48)) and (selectedX > (colidedX + 48)) then
  136.                 mouseX = colidedX + 50
  137.               else
  138.                 if (selectedY > (colidedY - 48)) and (selectedY < (colidedY + 48)) and (selectedX < (colidedX - 48)) then
  139.                   mouseX = colidedX - 50
  140.                 end if
  141.               end if
  142.             end if
  143.           end if
  144.         end if
  145.       end if
  146.       counter = counter + 1
  147.     end repeat
  148.   end repeat
  149.   sprite(11).loc = point(mouseX, mouseY)
  150.   updateStage()
  151.   bool = 1
  152.   counter = 51
  153.   repeat with y = 1 to 8
  154.     repeat with x = 1 to 8
  155.       if not (gBlockArray[gPeiceY][gPeiceX].getChannel() = counter) then
  156.         if sprite(11).intersects(counter) = 1 then
  157.           bool = 0
  158.         end if
  159.       end if
  160.       counter = counter + 1
  161.     end repeat
  162.   end repeat
  163.   if gPeiceSelected = 1 then
  164.     if bool = 1 then
  165.       gBlockArray[gPeiceY][gPeiceX].setBlockPosition(mouseX, mouseY)
  166.     end if
  167.   end if
  168. end
  169.  
  170. on setAllBlocksUnlit
  171.   repeat with x = 1 to 8
  172.     repeat with y = 1 to 8
  173.       if not (gBlockArray[x][y] = 0) then
  174.         gBlockArray[x][y].unlitObject()
  175.         gBlockArray[x][y].setBlueFalse()
  176.         gBlockArray[x][y].setGreenFalse()
  177.         gBlockArray[x][y].setRedFalse()
  178.       end if
  179.     end repeat
  180.   end repeat
  181. end
  182.  
  183. on checkMissionObjectives
  184.   bool = 0
  185.   case gLevelNum of
  186.     1:
  187.       repeat with x = 1 to 8
  188.         repeat with y = 1 to 8
  189.           if not (gBlockArray[x][y] = 0) then
  190.             if gBlockArray[x][y].getObjectType() = 8 then
  191.               if gBlockArray[x][y].pObjLit = 1 then
  192.                 bool = 1
  193.               end if
  194.             end if
  195.           end if
  196.         end repeat
  197.       end repeat
  198.     2:
  199.       repeat with x = 1 to 8
  200.         repeat with y = 1 to 8
  201.           if not (gBlockArray[x][y] = 0) then
  202.             if gBlockArray[x][y].getObjectType() = 8 then
  203.               if gBlockArray[x][y].pObjLit = 1 then
  204.                 bool = 1
  205.               end if
  206.             end if
  207.           end if
  208.         end repeat
  209.       end repeat
  210.     3:
  211.       counter = 0
  212.       repeat with x = 1 to 8
  213.         repeat with y = 1 to 8
  214.           if not (gBlockArray[x][y] = 0) then
  215.             if gBlockArray[x][y].getObjectType() = 8 then
  216.               if gBlockArray[x][y].pObjLit = 1 then
  217.                 counter = counter + 1
  218.               end if
  219.             end if
  220.           end if
  221.         end repeat
  222.       end repeat
  223.       if counter >= 3 then
  224.         bool = 1
  225.       end if
  226.     4:
  227.       counter = 0
  228.       repeat with x = 1 to 8
  229.         repeat with y = 1 to 8
  230.           if not (gBlockArray[x][y] = 0) then
  231.             if gBlockArray[x][y].getObjectType() = 3 then
  232.               if gBlockArray[x][y].pObjLit = 1 then
  233.                 counter = counter + 1
  234.               end if
  235.             end if
  236.           end if
  237.         end repeat
  238.       end repeat
  239.       if counter >= 4 then
  240.         bool = 1
  241.       end if
  242.     5:
  243.       counter = 0
  244.       repeat with x = 1 to 8
  245.         repeat with y = 1 to 8
  246.           if not (gBlockArray[x][y] = 0) then
  247.             if gBlockArray[x][y].getObjectType() = 3 then
  248.               if gBlockArray[x][y].pObjLit = 1 then
  249.                 counter = counter + 1
  250.               end if
  251.             end if
  252.           end if
  253.         end repeat
  254.       end repeat
  255.       if counter >= 3 then
  256.         bool = 1
  257.       end if
  258.   end case
  259.   return bool
  260. end
  261.