home *** CD-ROM | disk | FTP | other *** search
- on clash p
- global x, y, d, check
- if the castNum of sprite (p + 7) <> 0 then
- repeat with j = p + 1 to 5
- set keeph to abs(the locH of sprite (p + 7) - the locH of sprite (j + 7))
- set keepv to abs(the locV of sprite (p + 7) - the locV of sprite (j + 7))
- set keephv to float(sqrt((keeph * keeph) + (keepv * keepv)))
- if keephv <= 18 then
- if getAt(getAt(check, p), j) = 0 then
- puppetSound("clash")
- set px to getAt(x, p)
- set py to getAt(y, p)
- set pd to getAt(d, p)
- set jx to getAt(x, j)
- set jy to getAt(y, j)
- set jd to getAt(d, j)
- set plh to the locH of sprite (p + 7)
- set plv to the locV of sprite (p + 7)
- set jlh to the locH of sprite (j + 7)
- set jlv to the locV of sprite (j + 7)
- set clh to float((plh + jlh) / 2)
- set clv to float((plv + jlv) / 2)
- set ph to plh - clh
- set pv to plv - clv
- set jh to jlh - clh
- set jv to jlv - clv
- if abs(ph) > 0 then
- set pradian to atan(pv / ph)
- if ph < 0 then
- set pradian to pradian + PI
- end if
- else
- if pv > 0 then
- set pradian to PI / 2
- else
- set pradian to -(PI / 2)
- end if
- end if
- if abs(jh) > 0 then
- set jradian to atan(jv / jh)
- if jh < 0 then
- set jradian to jradian + PI
- end if
- else
- if jv > 0 then
- set jradian to PI / 2
- else
- set jradian to -(PI / 2)
- end if
- end if
- set ph to px + cos(pradian)
- set pv to py + sin(pradian)
- set jh to jx + cos(jradian)
- set jv to jy + sin(jradian)
- if abs(ph) > 0 then
- set pradian to atan(pv / ph)
- if ph < 0 then
- set pradian to pradian + PI
- end if
- else
- if pv > 0 then
- set pradian to PI / 2
- else
- set pradian to -(PI / 2)
- end if
- end if
- if abs(jh) > 0 then
- set jradian to atan(jv / jh)
- if jh < 0 then
- set jradian to jradian + PI
- end if
- else
- if jv > 0 then
- set jradian to PI / 2
- else
- set jradian to -(PI / 2)
- end if
- end if
- set px to cos(pradian)
- set py to sin(pradian)
- set jx to cos(jradian)
- set jy to sin(jradian)
- if abs(pd) > abs(jd) then
- set jd to pd * 0.84999999999999998
- set pd to pd * 0.14999999999999999
- else
- if abs(pd) < abs(jd) then
- set pd to jd * 0.84999999999999998
- set jd to jd * 0.14999999999999999
- else
- set pd to 0
- set jd to 0
- end if
- end if
- setAt(x, p, px)
- setAt(y, p, py)
- setAt(d, p, pd)
- setAt(x, j, jx)
- setAt(y, j, jy)
- setAt(d, j, jd)
- setAt(getAt(check, p), j, 1)
- end if
- next repeat
- end if
- if getAt(getAt(check, p), j) = 1 then
- setAt(getAt(check, p), j, 0)
- end if
- end repeat
- end if
- end
-