Thanks Peter.
I had a few ideas for more efficient collision detection. It only makes a small difference.
But if there are large numbers of objects I would then adopt a zone mapping strategy to avoid exponential increases in collision tests.
/*  Circle Collision by Peter  o5/o4/2011  */
  indexbase 0
  include "wFunc.h"
  OpenWindow "Circle Collison",800,600,ws_overlapped
  SetFont 16,16,0,0
  Long xCir1,yCir1,rCir1,xCir2,yCir2,rCir2,color,px,jx
  Long xBox1,yBox1,xBox2,yBox2
  Function CircleCollision(long xd, long yd,long rp) as long
  '=========================================================
  iF xd*xd+yd*yd < rp*rp
    return 1
  End iF
  End Function
  Function BoxCollision(long xd, long yd,long rp) as long
  '======================================================
  iF abs(yd) < rp
    iF abs(xd) < rp then return 1
  end if
  End Function
  xCir1 =0   : yCir1=300 : rCir1=20
  xCir2 =800 : yCir2=300 : rCir2=30
  xBox1=0 : yBox1=200
  xBox1=0 : yBox2=220
  '====
  'MAIN
  '====
  While WinExit=0
  ClearBuffer color
  Text "Collision " + Str(px) + "/" + Str(jx),312,32,RGB(255,255,255)
  color=0
  Circle xCir1,yCir1,rCir1,RGB(255,255,255)
  Circle xCir2,yCir2,rCir2,RGB(255,255,255)
  xCir1 +=1: xCir2 -=2
  iF xCir1 >=800 Then xCir1 =0
  iF xCir2 <=0   Then xCir2 =800
  px = CircleCollision xCir2-xCir1,yCir2-yCir1, rCir1+rCir2
  iF px Then color = RGB(Rand(24,200),Rand(24,200),Rand(24,200))
  Box xBox1,yBox1,40,40,RGB(255,255,255)
  Box xBox2,yBox2,20,20,RGB(255,255,255)
  xBox1 +=2: xBox2 -=2
  iF xBox1 >=800 Then xBox1 =0
  iF xBox2 <=0   Then xBox2 =840
  jx = BoxCollision xBox2-xBox1,yBox2-yBox1,30
  iF jx Then color or=255
  DoEvents
  FlipBuffer
  WaitFrames 80
  Wend
  WinEnd
Charles