include "sdl.inc"

SetDisplay 640,480,1
SetColorKey 255,0,255

Function Min(single a, b) as single
iF a <= b  
   Return a 
Else 
   Return b
End iF   
End Function

Function Max(single a, b) as single
iF a >= b 
   Return a 
Else 
   Return b
End iF   
End Function

single x, y, rot, vel, tx, ty, v
single dx, dy, angle, dist, da
sys p1,p2,z

p1=LoadImage "bmp/kurbis.bmp",16
p2=LoadImage "bmp/font32x.bmp",94

While Key(27)=0
ClsColor 200,200,248
tx = xMouse
ty = yMouse
dx = tx-x
dy = ty-y
dist = sqr(dx*dx+dy*dy)
angle = atan(ty-y, tx-x)
da = angle-rot
da = atan(Sin(da),Cos(da))
vel = Min (1, dist/100.0)
Rot=rot + da*vel*0.1
x=x + Cos(rot)*vel*5.0
y=y + Sin(rot)*vel*5.0
DrawText p2,112,16,"BUMERANG JACK"
DrawImage p1,x-5,y-5,z
v=v+.4
iF v>=1 Then
   v=0
   z=z+1
   iF z=16 Then z=0
End iF   
Flip
SetFps 60
Wend
Ends