
Here my code :
Code: Select all
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Created by threedslider 17/10/2023
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(1, 0,0,800 / DesktopResolutionX(),600 / DesktopResolutionY(),"Funny circles", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1),0,0,800,600,0,0,0)
Structure rond
x.i
y.i
rayon.i
EndStructure
Myvar.rond
myvar\x = 10
myvar\y = 10
myvar\rayon = 5
Procedure Cercle(X, Y, *cl.rond)
For n=0 To 1800
cx = *cl\rayon * Cos(n)
cy= *cl\rayon * Sin(n)
Plot(cx+*cl\x+ X,cy+*cl\y+Y,RGB(255,0,0))
Next
EndProcedure
Procedure sim(xx, yy, X1.i, Y1.i, iter)
Myvar_other.rond
myvar_other\x = 100
myvar_other\y = 100
myvar_other\rayon = 30
For n=0 To 5
d2 = Sqr((xx-myvar_other\x) * (xx-myvar_other\x) + (yy-myvar_other\y) * (yy-myvar_other\y))
r2 = Sqr(myvar_other\rayon * myvar_other\rayon)
in_d2 = Sqr((xx-x1)*(xx-x1) + (yy-y1)*(yy-y1))
If d2*20 > r2 And in_d2*10 > r2
myvar_other\rayon=Myvar_other\rayon-100/in_d2
myvar_other\x = X1
myvar_other\y = Y1
Cercle(0,0,@myvar_other)
; EndIf
; Else
; ;If d2 > r2
; myvar_other\rayon = 30-n+2*2
; ;myvar_other\x = xx
; ;myvar_other\y = yy
; Cercle(0,0,@myvar_other)
; ;EndIf
;
EndIf
Next
If iter > 0 ;And d2 > r2
sim(xx, yy, X1+120, Y1, iter-1)
EndIf
EndProcedure
; Déplacement de la souris
MouseLocate(0,0)
Repeat
ExamineKeyboard()
Repeat
event = WindowEvent()
Until event = 0
ClearScreen(RGB(255,200,0))
ExamineMouse() ; Etat de la souris
xm = MouseX() ; Position en x de la souris
ym = MouseY() ; Position en y de la souris
;Debug x
;Debug y
StartDrawing(ScreenOutput())
For x = 0 To 4
move.f + 1/10000
wave_x.f = Cos(x) * 200
wave_y.f = Sin(x) * 200
;myvar\x = x+10
;myvar\y = y+10
If xm < 3
xm = 3
Else
If xm >750
xm = 750
EndIf
EndIf
If ym < 3
ym = 3
Else
If ym > 550
ym = 550
EndIf
EndIf
cercle(xm,ym,@myvar)
sim(xm,ym, 100, 100+x*100, 5)
Next
StopDrawing()
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
FlipBuffers()
ForEver
End