wie kann ich einen Blitz zwischen zwei Punkten zeichnen?
Klinkt erstmal einfach ist es aber aus meiner Sicht nicht, ich bekomm es zwar mit
Code: Alles auswählen
for x = 1 to 100
plot(x, y, #red)
y-1+random(2
next
Dann hab ich diesen Quellcode ausgegraben und verändert:
Code: Alles auswählen
Global MaxHeight = 100.0
#PIXELS = 1000
Global Dim ALine.f(#PIXELS)
Global mv.f, d.l, max.l
Procedure Split(low.l, high.l)
Protected m.l
m = (high + low) / 2
d = high - low
If d <= 1
ProcedureReturn 0
EndIf
mv = (ALine(high) + ALine(low)) / 2.0
ALine(m) = mv - (Random(10000) / 10000.0 - 0.5) * MaxHeight * d / (#PIXELS)
Split(m, high)
Split(low, m)
EndProcedure
width = 600
height = 300
PosY = 150
CreateImage(0, width, height)
OpenWindow(0, 200, 200, width, height, "Drawing", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ImageGadget(1, 0, 0, width, height, ImageID(0))
SetGadgetState(1, ImageID(0))
Repeat
StartDrawing(ImageOutput(0))
Box(0,0, width,height, 0) ; Sprite löschen
FrontColor(#White)
Split(0, #PIXELS)
For z = 1 To #PIXELS
LineXY((z-1)*width/#PIXELS, ALine(z-1)+PosY, z*width/#PIXELS, ALine(z)+PosY)
Next
StopDrawing()
SetGadgetState(1, ImageID(0))
Delay(10)
Until WindowEvent() = #PB_Event_CloseWindow
Gruß
Scarabol