`gravity cursor
`by Crit
 
set display mode 1024, 768, 32
hide mouse
sync on
sync rate 100
 
#constant numplanets 10
#constant minsize 6
#constant maxsize 20
#constant trailsize 5
 
type xy
 x as integer
 y as integer
endtype
 
type PlanetType
   size as integer
   x as integer
   y as integer
   xspeed as integer
   yspeed as integer
   angle as integer
endtype
 
dim planets(numplanets) as PlanetType
 
dim trail (numplanets, trailsize) as xy
index =1
 
 
 
position mouse 512, 384
 
cursorx=512
cursory=384
 
angle as float
 
for x=1 to numplanets
  planets(x).size = rnd (maxsize-minsize) + minsize
  planets(x).x=rnd(500)-250+cursorx
  planets(x).y=rnd(500)-250+cursory
  planets(x).xspeed = 0
  planets(x).yspeed = 0
  if rnd(1)=1 then angle=16 else angle=-16
  planets(x).angle = angle
  next x
ink rgb(255,255,255), rgb(0,0,0)
 
deltax as float
deltay as float
dist as float
 
do
cursorx=mousex()
cursory=mousey()
  cls
 
  for x=1 to numplanets
    size=planets(x).size
 
    ydistance=cursory-planets(x).y
    xdistance=cursorx-planets(x).x
    dist=(xdistance^2+ydistance^2)
 
 
    angle=atanfull(ydistance, xdistance)+planets(x).angle
 
 
    deltax=cos(angle)*2
    deltay=sin(angle)*2
 
 
    planets(x).xspeed=planets(x).xspeed+deltax
    planets(x).yspeed=planets(x).yspeed+deltay
    planets(x).x=planets(x).x+planets(x).xspeed
    planets(x).y=planets(x).y+planets(x).yspeed
 
    trail(x, index).x=planets(x).x
    trail(x, index).y=planets(x).y
   next x
 
 
   for x=1 to numplanets
    ink rgb(100,0,100), rgb(0,0,0)
    for y= 0 to trailsize
      circle trail(x,y).x,trail(x,y).y,planets(x).size
    next y
    ink rgb(255,255,255), rgb(0,0,0)
    circle planets(x).x, planets(x).y, planets(x).size
   next x
 
 
   circle cursorx,cursory, 5
   index = (index + 1) mod (trailsize+1)
   sync
 loop