by Chaitanya Dhareshwar (4 Submissions)
Category: Graphics
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 27th May 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Draws lightning from X1,Y1 to X2,Y2 fast, slow, or in any way you can think of. Be careful - dont zap yourself :)
API Declarations
'No declarations needed, for .NET I'm sure smart people will figure out what 2 Do
'Notes: BackBuffer is a picturebox control
' Just because the lightning is slow does not mean its stupid :)
On Error Resume Next
dx = Abs(X2 - X1) / Steps
If X1 = X2 Then dx = Int(Rnd * 5) + 10
dy = Abs(Y2 - Y1) / Steps
If Y1 = Y2 Then dx = Int(Rnd * 5) + 10
oX1 = 0
oY1 = 0
tt = Timer + 5
Do
If X1 < X2 Then X1 = X1 + Int(Rnd * dx) + 3 Else X1 = X1 - Abs(Int(Rnd * dx) + 3)
If Y1 < Y2 Then Y1 = Y1 + Int(Rnd * dy) + 3 Else Y1 = Y1 - Abs(Int(Rnd * dy) + 3)
For i = -Rnd * 2 To Rnd * 2
For k = -Rnd * 2 To Rnd * 2
rd = Int(Rnd * 50) + 180
If Not (oX1 = 0 And oY1 = 0) Then
If BufferOnly Then
BackBuffer.Line (oX1 + i, oY1 + k)-(X1 + i, Y1 + k), &HFF0000 + rd * 256 + rd
Else
Form1.Line (oX1 + i, oY1 + k)-(X1 + i, Y1 + k), &HFF0000 + rd * 256 + rd
End If
End If
If Slow Then
BackBuffer.Line (oX1 + i, oY1 + k)-(X1 + i, Y1 + k), &HFF0000 + rd * 256 + rd
t = Timer + 0.003
Do
DoEvents
Loop Until Timer >= t
End If
Next
Next
oX1 = X1
oY1 = Y1
Loop Until (Abs(X1 - X2) <= dx + 1 And Abs(Y1 - Y2) <= dy + 1 And Not (Slow Or Stupid)) Or (Timer >= tt And (Slow Or Stupid))
End Sub
No comments have been posted about Draws lightning from X1,Y1 to X2,Y2 fast, slow, or in any way you can think of. Be careful - dont z. Why not be the first to post a comment about Draws lightning from X1,Y1 to X2,Y2 fast, slow, or in any way you can think of. Be careful - dont z.