Graphics 800,600,32,2
SeedRnd MilliSecs()

spalte = CreateImage(64,32)
SetBuffer ImageBuffer(spalte)
Color 255,255,0
Oval 0,-32,64,64
Color 0,0,0
Oval 0,-8,64,16

gabel = CreateImage(256,32)
SetBuffer ImageBuffer(gabel)
Color 255,200,64
Oval 1,10,200,12
Oval 182,0,24,32

Oval 190,0,30,6
Oval 195,13,30,6
Oval 190,26,30,6



TFormFilter 0

Dim spalten%(15)
For i = 0 To 15
	spalten%(i) = CopyImage( spalte )
	HandleImage spalten(i), 32, 16
	RotateImage(spalten(i%), i*22.5)
	MaskImage spalten(i), 0,0,0
Next
Dim gabeln%(15)
For i = 0 To 15
	gabeln%(i) = CopyImage( gabel )
	HandleImage gabeln(i), 192, 16
	RotateImage(gabeln(i%), i*22.5 -180)
	MaskImage gabeln(i), 0,0,0
Next

SetBuffer BackBuffer()

Local frametimer = CreateTimer(30)
Type rumpel
	Field x,y,a
	Field w,l
End Type

Type gabel
	Field victim.rumpel
	Field x#, y#
	Field speed#
End Type
Global gabeltimer = 0

For i = 0 To 30
	
	f.rumpel = New rumpel
	cdu=Rand(2,14)
	cdu=cdu*cdu
	f\l = 256-cdu
	f\w = Rand(289)
	
	f\a = Int(f\w / 22.5) Mod 16
Next

globalw# = 0

Repeat
	Cls
	Color 220,220,220
	Oval 400-255,300-255,510,510
	Color 200,200,200
	Oval 400-235,300-235,470,470
	Color 0,0,0
	creamx#=Cos(145 + globalw#)*200
	creamy#=Sin(145 + globalw#)*200
	Oval 400-creamx#-50,300-creamy#-50,100,100
	Color 255,255,255
	Oval 400-Cos(145 + globalw#)*200-47,300-Sin(145 + globalw#)*200-47,94,94

	;Oval
	For f.rumpel = Each rumpel
		f\a = Int( (f\w + globalw#) / 22.5) Mod 16
		DrawImage(spalten(f\a),400+f\l*Cos(f\w + globalw#),300+f\l*Sin(f\w + globalw#))
	Next
	For g.gabel = Each gabel
		If g\victim <> Null Then
			xx# = 400 + g\victim\l * Cos(g\victim\w + globalw#)
			yy# = 300 + g\victim\l * Sin(g\victim\w + globalw#)
			w = ATan2( (g\y-yy), g\x-xx ) + 180
			g\x = g\x + g\speed*Cos( w )
			g\y = g\y + g\speed*Sin( w )
			g\speed = g\speed + 0.01
			frame = Int((w+180) / 22.5) Mod 16
			DrawImage gabeln(frame), g\x,g\y
			If Sqr( (g\x-xx)^2 + (g\y-yy)^2) < 30 Then
				Delete g\victim
				Delete g
			ElseIf Sqr( (g\x-(400-creamx#))^2 + (g\y-(300-creamy#))^2) < 90 Then
				;Delete g\victim
				Delete g
			EndIf
		Else
			Delete g
		EndIf
	Next

	Flip
	flippi#= flippi# +(KeyDown(205)-KeyDown(203))
	If flippi# > 30 Then flippi# = 30
	If flippi# < -30 Then flippi# = -30
	flippi# = flippi# *0.95
	globalw# = globalw# + flippi /10
	If globalw#<0 Then globalw# = globalw# + 360
	If globalw#>359 Then globalw# = globalw# - 360
	
	If gabeltimer = 0 Then
		g.gabel = New gabel
		w = Rand(359)
		g\x = 400 + 400*Cos(w)
		g\y = 300 + 400*Sin(w)
		g\victim = rand_victim()
		g\speed# = gabelanz /10.0
		gabeltimer = 100 - gabelanz
		gabelanz = gabelanz +1
		If gabeltimer < 50 Then gabeltimer = 50
	Else
		gabeltimer = gabeltimer -1
	EndIf
	
	WaitTimer frametimer
Until KeyHit(1)
End

Function rand_victim.rumpel()
	Local i, g.rumpel
	For g.rumpel = Each rumpel
		i=i+1
	Next
	i = Rand(1,i)
	For g.rumpel = Each rumpel
		If i=1 Then
			Return g.rumpel
		Else
			i=i-1
		EndIf
	Next

End Function