home *** CD-ROM | disk | FTP | other *** search
/ Seeker / Seeker.iso / files_w / 5balls.dir / 00057.ls < prev    next >
Encoding:
Text File  |  1994-12-05  |  3.3 KB  |  111 lines

  1. on clash p
  2.   global x, y, d, check
  3.   if the castNum of sprite (p + 7) <> 0 then
  4.     repeat with j = p + 1 to 5
  5.       set keeph to abs(the locH of sprite (p + 7) - the locH of sprite (j + 7))
  6.       set keepv to abs(the locV of sprite (p + 7) - the locV of sprite (j + 7))
  7.       set keephv to float(sqrt((keeph * keeph) + (keepv * keepv)))
  8.       if keephv <= 18 then
  9.         if getAt(getAt(check, p), j) = 0 then
  10.           puppetSound("clash")
  11.           set px to getAt(x, p)
  12.           set py to getAt(y, p)
  13.           set pd to getAt(d, p)
  14.           set jx to getAt(x, j)
  15.           set jy to getAt(y, j)
  16.           set jd to getAt(d, j)
  17.           set plh to the locH of sprite (p + 7)
  18.           set plv to the locV of sprite (p + 7)
  19.           set jlh to the locH of sprite (j + 7)
  20.           set jlv to the locV of sprite (j + 7)
  21.           set clh to float((plh + jlh) / 2)
  22.           set clv to float((plv + jlv) / 2)
  23.           set ph to plh - clh
  24.           set pv to plv - clv
  25.           set jh to jlh - clh
  26.           set jv to jlv - clv
  27.           if abs(ph) > 0 then
  28.             set pradian to atan(pv / ph)
  29.             if ph < 0 then
  30.               set pradian to pradian + PI
  31.             end if
  32.           else
  33.             if pv > 0 then
  34.               set pradian to PI / 2
  35.             else
  36.               set pradian to -(PI / 2)
  37.             end if
  38.           end if
  39.           if abs(jh) > 0 then
  40.             set jradian to atan(jv / jh)
  41.             if jh < 0 then
  42.               set jradian to jradian + PI
  43.             end if
  44.           else
  45.             if jv > 0 then
  46.               set jradian to PI / 2
  47.             else
  48.               set jradian to -(PI / 2)
  49.             end if
  50.           end if
  51.           set ph to px + cos(pradian)
  52.           set pv to py + sin(pradian)
  53.           set jh to jx + cos(jradian)
  54.           set jv to jy + sin(jradian)
  55.           if abs(ph) > 0 then
  56.             set pradian to atan(pv / ph)
  57.             if ph < 0 then
  58.               set pradian to pradian + PI
  59.             end if
  60.           else
  61.             if pv > 0 then
  62.               set pradian to PI / 2
  63.             else
  64.               set pradian to -(PI / 2)
  65.             end if
  66.           end if
  67.           if abs(jh) > 0 then
  68.             set jradian to atan(jv / jh)
  69.             if jh < 0 then
  70.               set jradian to jradian + PI
  71.             end if
  72.           else
  73.             if jv > 0 then
  74.               set jradian to PI / 2
  75.             else
  76.               set jradian to -(PI / 2)
  77.             end if
  78.           end if
  79.           set px to cos(pradian)
  80.           set py to sin(pradian)
  81.           set jx to cos(jradian)
  82.           set jy to sin(jradian)
  83.           if abs(pd) > abs(jd) then
  84.             set jd to pd * 0.84999999999999998
  85.             set pd to pd * 0.14999999999999999
  86.           else
  87.             if abs(pd) < abs(jd) then
  88.               set pd to jd * 0.84999999999999998
  89.               set jd to jd * 0.14999999999999999
  90.             else
  91.               set pd to 0
  92.               set jd to 0
  93.             end if
  94.           end if
  95.           setAt(x, p, px)
  96.           setAt(y, p, py)
  97.           setAt(d, p, pd)
  98.           setAt(x, j, jx)
  99.           setAt(y, j, jy)
  100.           setAt(d, j, jd)
  101.           setAt(getAt(check, p), j, 1)
  102.         end if
  103.         next repeat
  104.       end if
  105.       if getAt(getAt(check, p), j) = 1 then
  106.         setAt(getAt(check, p), j, 0)
  107.       end if
  108.     end repeat
  109.   end if
  110. end
  111.