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

  1. on findDistance pointA, pointB
  2.   hDistance = pointA[1] - pointB[1]
  3.   vDistance = pointA[2] - pointB[2]
  4.   finalDistance = sqrt((hDistance * hDistance) + (vDistance * vDistance))
  5.   return finalDistance
  6. end
  7.  
  8. on findAngle pointA, pointB
  9.   global watchThisAngle
  10.   xDist = pointB[1] - pointA[1]
  11.   yDist = pointB[2] - pointA[2]
  12.   if xDist <> 0 then
  13.     watchThisAngle = atan(1.0 * yDist / xDist) * 180 / PI
  14.     theAngle = atan(1.0 * yDist / xDist) * 180 / PI
  15.     if xDist > 0 then
  16.       theAngle = theAngle + 90
  17.     else
  18.       if xDist < 0 then
  19.         theAngle = theAngle - 90
  20.       else
  21.         if yDist < 0 then
  22.           theAngle = 0
  23.         else
  24.           if yDist > 0 then
  25.             theAngle = 180
  26.           end if
  27.         end if
  28.       end if
  29.     end if
  30.   else
  31.     if yDist < 0 then
  32.       theAngle = 0
  33.     else
  34.       if yDist > 0 then
  35.         theAngle = 180
  36.       end if
  37.     end if
  38.   end if
  39.   return theAngle
  40. end
  41.  
  42. on harvestInput
  43.   global inputString
  44.   inputString = [0, 0, 0, 0, 0, 0, 0, 0]
  45.   if keyPressed(0) = 1 then
  46.     inputString[1] = 1
  47.   end if
  48.   if keyPressed(2) = 1 then
  49.     inputString[2] = 1
  50.   end if
  51.   if keyPressed(43) = 1 then
  52.     inputString[1] = 1
  53.   end if
  54.   if keyPressed(47) = 1 then
  55.     inputString[2] = 1
  56.   end if
  57. end
  58.  
  59. on playSound whichSound, whichSlot
  60.   sound(whichSlot).stop()
  61.   sound(whichSlot).queue([#member: member(whichSound)])
  62.   sound(whichSlot).play()
  63. end
  64.