Brian,
Not sure if this will help.
These functions I use work with RCBasic but should not be difficult to convert
This one is for detecting the collision between two circles:
Requires the x and y coords of each circle and the radius of each circle.
function collide(circ1x, circ1y, circ2x, circ2y, r1, r2)
' Calculate difference between centres
distX = circ1x - circ2x
distY = circ1y - circ2y
' Get distance using Pythagoras
dist = sqrt((distX * distX) + (distY * distY))
if dist <= (r1 + r2) then
collision = 1
else
collision = 0
end if
return collision
end function
This one detects the collision between a circle and rectangle:
Requires the x and y coord of the circle and it's radius. The x and y coords of the rectangle together with its width and height.
function collide(cx,cy,radius,rx,ry,rw,rh)
distX = abs(cx - rx - rw / 2)
distY = abs(cy - ry - rh / 2)
if distX > (rw / 2 + radius) then
return false
end if
if distY > (rh / 2 + radius) then
return false
end if
if distX <= rw / 2 then
return true
end if
if distY < rh / 2 then
return true
end if
dx = distX - rw / 2
dy = distY - rh / 2
return (dx * dx + dy * dy <= (radius * radius))
end function
I hope this helps....
J