
Je m'y remets un peu sur purebasic encore ^^
Voici un code de petite simulation en particules si on peut dire ça

Code : Tout sélectionner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Created by threedslider 16/10/2023
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
InitSprite()
InitKeyboard()
OpenWindow(1, 0,0,800,600,"line as little simulation", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1),0,0,800,600,0,0,0)
SetFrameRate(30)
Procedure MyLine(X.f, Y.f)
LineXY(X, Y, 0, Y, RGB(255, 0, 0) )
EndProcedure
Procedure Line_sim(X1.f, Y1.f, iter)
Line( X1, Y1, 1, 2, RGB(255, 0, 0) )
If iter > 0
Line_sim(X1-iter*8, Y1-iter*8, iter-1)
EndIf
EndProcedure
Repeat
ExamineKeyboard()
event = WindowEvent()
ClearScreen(RGB(255,200,0))
StartDrawing(ScreenOutput())
For x = 0 To 1200
move.f + 1/10000
wave_x.f = Sin(move+x)* 120 - Cos(move-x/200) * 120
wave_y.f = Cos(move-x/400) * 120
;MyLine(800.0, 500.0)
Line_sim(((wave_x))*12+(wave_y)+200, (Sin(wave_x)*4+Sin(wave_y))+ wave_y+300, 4)
; Line( (wave_x)*12+(wave_y)+200, Sin(wave_x)*12+Sin(wave_y)+ wave_y+300, 1, 1, RGB(255, 0, 0) )
; Line( (-wave_x)*12+(-wave_y)+200, Sin(-wave_x)*12+Sin(-wave_y)+wave_y+300, 1, 1, RGB(255, 0, 0) )
; Line( (wave_x)*12+(wave_y)+200, Sin(wave_x)*12+Sin(wave_y)+ wave_y+400, 1, 1, RGB(255, 0, 0) )
;Debug wave_x
Next
StopDrawing()
Delay(1) : FlipBuffers()
Until event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End