rem control mouse speed rem push circle around using mouse rem by latch set display mode 800,600,16 sync on sync rate 60 hide mouse rem seed the random generator randomize timer() grey=rgb(150,150,150) rem create mouse pointer and circle cls 0 ink RGB(0,255,255),0 box 0,0,8,8 line 8,8,16,16 get image 1,0,0,17,17 sprite 1,screen width()/2,screen height()/2,1 rem intialize radius=25 x#=rnd(screen width()-(4*radius))+radius*2 y#=rnd(screen height()-(4*radius))+radius*2 newx#=x# newy#=y# cls grey ink 0,0 circle x#,y#,radius rem main loop do cls grey movemouse(.5) text 0,0,str$(angle) rem check if the pointer is hitting the circle x1=x#-radius x2=x#+radius y1=y#-radius y2=y#+radius if mouse_within(x1,y1,x2,y2) rem calculate angle angle=wrapvalue((atanfull(y#-oldy,x#-oldx))*-1) rem how much force to hit the circle with? force#=(abs(mousemovex())+abs(mousemovey()))/2.0 force#=force#*20 rem new postions of the circle newx#=force#*cos(angle)+x# newy#=-1*force#*sin(angle)+y# `x=newx `y=newy endif rem possible collision with screen border? if newx# <= radius*2 or newx# >= screen width()-radius*2 then newx#=newx#*-1.0 if newy# <= radius*2 or newy# >= screen height()-radius*2 then newy#=newy#*-1.0 rem interpolate position over time x#=curvevalue(newx#,x#,20) y#=curvevalue(newy#,y#,20) circle x#,y#,radius oldx=sprite x(1) oldy=sprite y(1) sync loop end function movemouse(speed#) x=sprite x(1)+(mousemovex()*speed#) y=sprite y(1)+(mousemovey()*speed#) if x > screen width() then x=screen width()-1 if x < 0 then x=0 if y > screen height() then y=screen height()-1 if y < 0 then y=0 sprite 1,x,y,1 endfunction function mouse_within(x1,y1,x2,y2) result=0 sx=sprite x(1) sy=sprite y(1) if sx>=x1 and sx<=x2 and sy>=y1 and sy <=y2 result=1 endif endfunction result