Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lightning Globe
#1
Since everyone is playing around with balls, globes, coins, circles and tigers and bears -- Oh my!!  I decided to share this old Lightning Globe that I'd wrote sometime back in the stone ages of QB64.   Maybe Dav, or someone skilled with the SOUND command will go in and add a nice little zappy zappy sizzle for us.

Just click on the screen and watch the lightning globe make lightning!

Code: (Select All)
Screen _NewImage(640, 480, 32)
Dim Kolor As _Unsigned Long
Const LevelOfVariance = 5 'Change this value to have fun with the strength of the "draw" to target.
Do
_Limit 60
Cls
Circle (320, 240), 20, &HFFAAAAAA
Paint (320, 240), &HFFAAAAAA
While _MouseInput: Wend
If _MouseButton(1) Then
StartX = 320: StartY = 240: EndX = _MouseX: EndY = _MouseY
Kolor = &HFF000000 + Int(Rnd * &H1000000)
Color Kolor
Do Until StartX = EndX And StartY = EndY
CoinToss = Rnd * 100 'The strength of "draw" which pulls the lightning to the target.
If CoinToss < LevelOfVariance Then 'Higher values meander less and go directly to the target.
XChange = Sgn(EndX - StartX) '-1,0,1, drawn always towards the mouse
YChange = Sgn(EndY - StartY)
Else
XChange = Int(Rnd * 3) - 1 '-1, 0, or 1, drawn in a random direction to let the lightning wander
YChange = Int(Rnd * 3) - 1
End If
StartX = StartX + XChange
StartY = StartY + YChange
PSet (StartX, StartY), Kolor
Loop
End If
_Display
Loop
Reply
#2
I submit TheBOB's rain and thunder OGG's.


Attached Files
.rar   Rain and Thunder OGGs.rar (Size: 1.64 MB / Downloads: 35)
Shoot first and shoot people who ask questions, later.
Reply
#3
Penultimate line

_Display: _Delay .5

will show lightning in slow motion

like in my slow "School themes"

https://qb64phoenix.com/forum/showthread...310&page=3
Write name of program in 1st line to copy & paste & save filename.bas
Insert program pictures: press print-screen-shot button
Open paint & Paste & Save as PNG
Add picture file to program topic

Russia looks world from future. Big data is peace data.
I never recommend anything & always write only about myself
Reply
#4
Very cool, Steve! That's some fancy programming... and I likes zappin' thangs!
Reply
#5
I remember us playing with globes back in the ancient times. Here is mine: 

Code: (Select All)

'This program was made on Sept. 5, 2019 by SierraKen
'Thank you to B+ and Steve from the QB64 forum for the inspiration and some help.
_Title "Lightning Globe by SierraKen - Use Mouse and Left Mouse Button On the Globe. Esc to end."
_ScreenMove 400, 60
Screen _NewImage(800, 600, 32)
x = 400
y = 300
c = 1
st = 2
go:
a$ = InKey$
If a$ = Chr$(27) Then End
_Limit 1000
Line (400, 300)-(150, 600), _RGB32(50, 50, 50)
Line (400, 300)-(650, 600), _RGB32(50, 50, 50)
Line (150, 600)-(650, 600), _RGB32(50, 50, 50)
Paint (500, 580), _RGB32(50, 50, 50)

For sz = 1 To 200 Step .25
    c = c + .05 + r
    Circle (x, y), sz, _RGB32(c, c / 2, c)
Next sz
c = 0
For sz = 1 To 30 Step .25
    c = c + .005
    Circle (x, y), sz, _RGB32(c, c, c)
Next sz

While _MouseInput: Wend
handx = _MouseX: handy = _MouseY: MB = _MouseButton(1)

If l > 500 Then l = 500
If l < 50 Then l = 50

If MB = -1 And _Hypot(handx - 400, handy - 300) < 200 Then
    r = .1
    Randomize Timer
    lxx = (Rnd * 60) + 370
    lyy = (Rnd * 60) + 270
    Randomize Timer
    lxxx = (Rnd * 60) + 370
    lyyy = (Rnd * 60) + 270
    bolts = Int(Rnd * 100) + 1
    Circle (lxx, lyy), 4, _RGB32(255, 245, 255)
    Paint (lxx, lyy), _RGB32(255, 245, 255)
    If bolts > 50 Then
        Circle (lxxx, lyyy), 4, _RGB32(255, 245, 255)
        Paint (lxxx, lyyy), _RGB32(255, 245, 255)
    End If

    Do
        _Limit 1000
        oldlx = lxx
        oldly = lyy
        oldlxx = lxxx
        oldlyy = lyyy
        If lxx < handx Then dxx = 10
        If lxx > handx Then dxx = -10
        If lyy < handy Then dyy = 10
        If lyy > handy Then dyy = -10
        If lxxx < handx Then dxxx = 10
        If lxxx > handx Then dxxx = -10
        If lyyy < handy Then dyyy = 10
        If lyyy > handy Then dyyy = -10
        Randomize Timer
        dx = (Rnd * 8) - 4
        dy = (Rnd * 8) - 4
        Randomize Timer
        dxxxx = (Rnd * 8) - 4
        dyyyy = (Rnd * 8) - 4
        lxx = lxx + dx
        lyy = lyy + dy
        lxx = lxx + dxx
        lyy = lyy + dyy
        lxxx = lxxx + dxxxx
        lyyy = lyyy + dyyyy
        lxxx = lxxx + dxxx
        lyyy = lyyy + dyyy
        Line (oldlx, oldly)-(lxx, lyy), _RGB32(255, 230, 255)
        If bolts > 50 Then Line (oldlxx, oldlyy)-(lxxx, lyyy), _RGB32(255, 230, 255)
        ttt = ttt + 1
        If ttt > 20 Then
            Circle (lxx, lyy), 10, _RGB32(255, 245, 255)
            Paint (lxx, lyy), _RGB32(255, 245, 255)
            GoTo nex:
        End If
    Loop
End If
r = 0
nex:
ttt = 0
Randomize Timer
lxx2 = (Rnd * 60) + 370
lyy2 = (Rnd * 60) + 270
Randomize Timer
lxx3 = (Rnd * 200) + 270
lyy3 = (Rnd * 200) + 170
Randomize Timer
lxx4 = (Rnd * 60) + 370
lyy4 = (Rnd * 60) + 270
Randomize Timer
lxx5 = (Rnd * 200) + 270
lyy5 = (Rnd * 200) + 170

Circle (lxx2, lyy2), 4, _RGB32(255, 245, 255)
Paint (lxx2, lyy2), _RGB32(255, 245, 255)
Circle (lxx4, lyy4), 4, _RGB32(255, 245, 255)
Paint (lxx4, lyy4), _RGB32(255, 245, 255)

Do
    _Limit 1000
    oldlx2 = lxx2
    oldly2 = lyy2
    oldlx4 = lxx4
    oldly4 = lyy4
    If lxx2 < lxx3 Then dxx = 10
    If lxx2 > lxx3 Then dxx = -10
    If lyy2 < lyy3 Then dyy = 10
    If lyy2 > lyy3 Then dyy = -10

    If lxx4 < lxx5 Then dxx2 = 10
    If lxx4 > lxx5 Then dxx2 = -10
    If lyy4 < lyy5 Then dyy2 = 10
    If lyy4 > lyy5 Then dyy2 = -10
    Randomize Timer
    dx = (Rnd * 8) - 4
    dy = (Rnd * 8) - 4
    Randomize Timer
    dx2 = (Rnd * 8) - 4
    dy2 = (Rnd * 8) - 4
    lxx2 = lxx2 + dx
    lyy2 = lyy2 + dy
    lxx2 = lxx2 + dxx
    lyy2 = lyy2 + dyy
    lxx4 = lxx4 + dx2
    lyy4 = lyy4 + dy2
    lxx4 = lxx4 + dxx2
    lyy4 = lyy4 + dyy2
    Line (oldlx2, oldly2)-(lxx2, lyy2), _RGB32(255, 161, 255)
    Line (oldlx4, oldly4)-(lxx4, lyy4), _RGB32(255, 161, 255)
    ttt2 = ttt2 + 1
    If ttt2 > 50 Then
        Circle (lxx2, lyy2), 8, _RGB32(255, 230, 255)
        Paint (lxx2, lyy2), _RGB32(255, 230, 255)
        Circle (lxx4, lyy4), 8, _RGB32(255, 230, 255)
        Paint (lxx4, lyy4), _RGB32(255, 230, 255)
        GoTo nex2:
    End If
Loop

nex2:
Line (0, 0)-(_Width, _Height), _RGB32(0, 0, 0, 30), BF
ttt2 = 0
_Display
GoTo go:
'Going back to the start of Main Loop.

Reply




Users browsing this thread: 2 Guest(s)