#define RADIUS 10
#define NUM 64
#module
#include "hspmath.as"
c = 0
#defcfunc Collision int x1,int y1,int x2,int y2
return abs(sqrt(pow(x1-x2,2)+pow(y1-y2,2))) <= RADIUS@
#global
dim p,NUM,4
dim clr,NUM,3
repeat NUM
p.cnt.0 = rnd(640)
p.cnt.1 = rnd(480)
p.cnt.2 = 1 + (rnd(2) * -2)
p.cnt.3 = 1 + (rnd(2) * -2)
clr.cnt.0 = rnd(255)
clr.cnt.1 = rnd(255)
clr.cnt.2 = rnd(255)
loop
repeat
redraw 0
color 0,0,0
boxf
repeat NUM
color clr.cnt.0,clr.cnt.1,clr.cnt.2
circle p.cnt.0-RADIUS/2,p.cnt.1-RADIUS/2,p.cnt.0+RADIUS/2,p.cnt.1+RADIUS/2,1
if p.cnt.0 >= 640 : p.cnt.2 = -1 : p.cnt.0 = 640
if p.cnt.0 <= 0 : p.cnt.2 = 1 : p.cnt.0 = 0
if p.cnt.1 >= 480 : p.cnt.3 = -1 : p.cnt.1 = 480
if p.cnt.1 <= 0 : p.cnt.3 = 1 : p.cnt.1 = 0
c = cnt
repeat NUM
if cnt = c : break
if Collision(p.cnt.0,p.cnt.1,p.c.0,p.c.1) : p.c.2 *= -1 : p.c.3 *= -1 : p.cnt.2 *= -1 : p.cnt.3 *= -1
loop
if Collision(mousex,mousey,p.c.0,p.c.1) : p.c.2 *= -1 : p.c.3 *= -1
repeat 2 : p.c.cnt += p.c.(cnt+2) : loop
loop
redraw 1
await 0
loop