Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3D Disco Lights
#1
I doubled up my Anemometer and turned them into disco lights! Plus I added a random setting to make them go at a random direction and speed if random mode is turned on. To turn it on press the Space Bar as it says in the title bar. If you press the Space Bar and it doesn't work, press it again a few more times, sometimes it's caught up in a loop I think. To turn random mode off press it again. Without random mode you can use the mouse wheel to change the speed and direction of the lights. Tell me what you think, thanks.

Code: (Select All)
Screen _NewImage(800, 600, 32)
start:
t = (_Pi / 2) * 100
t2 = ((11 * _Pi) / 6) * 100
t3 = ((7 * _Pi) / 6) * 100
t6 = (_Pi / 2) * 100
t5 = ((11 * _Pi) / 6) * 100
t4 = ((7 * _Pi) / 6) * 100

cc = 200
cc4 = 200

Do
    _Limit 50
    While _MouseInput: wheel = wheel + _MouseWheel: Wend
    a$ = InKey$
    If (a$ = " " Or a$ = "r" Or a$ = "R") And rand = 1 Then
        rand = 0
        a$ = ""
    End If
    If (a$ = " " Or a$ = "r" Or a$ = "R") And rand = 0 Then
        rand = 1
        a$ = ""
        w = 1
    End If
    If wheel > 5 Then wheel = 5
    If wheel < -5 Then wheel = -5
    If rand = 0 Then
        w = wheel
        _Title "Disco Lights by SierraKen - Use Mouse Wheel - Space Bar to turn random mode on"
    End If
    If rand = 1 Then
        lights = Rnd * 100
        If lights > 95 Then w = Int(Rnd * 5) - 5
        _Title "Disco Lights by SierraKen - Use Mouse Wheel - Space Bar to turn random mode off"
    End If

    If t2 < 0 Then GoTo start:
    x = (Sin(t) * 20) * (_Pi * 2) + 400
    y = (Cos(t) * 10) * (_Pi / 2) + 200
    r = (Cos(t) * 180) / _Pi / 1.5 + 50
    t = t - (.25 + w / 10)
    x2 = (Sin(t2) * 20) * (_Pi * 2) + 400
    y2 = (Cos(t2) * 10) * (_Pi / 2) + 200
    r2 = (Cos(t2) * 180) / _Pi / 1.5 + 50
    t2 = t2 - (.25 + w / 10)
    x3 = (Sin(t3) * 20) * (_Pi * 2) + 400
    y3 = (Cos(t3) * 10) * (_Pi / 2) + 200
    r3 = (Cos(t3) * 180) / _Pi / 1.5 + 50
    t3 = t3 - (.25 + w / 10)
    For S = .25 To r Step .1
        cc = cc - .25
        Circle (x, y), S, _RGB32(cc, cc, 100 + cc)
    Next S
    cc = 200
    For S = .25 To r2 Step .1
        cc = cc - .25
        Circle (x2, y2), S, _RGB32(cc, 100 + cc, cc)
    Next S
    cc = 200
    For S = .25 To r3 Step .1
        cc = cc - .25
        Circle (x3, y3), S, _RGB32(100 + cc, cc, cc)
    Next S
    cc = 200
    Line (400, 200)-(x, y), _RGB32(255, 255, 255)
    Line (400, 200)-(x2, y2), _RGB32(255, 255, 255)
    Line (400, 200)-(x3, y3), _RGB32(255, 255, 255)
    x4 = (Sin(t4) * 20) * (_Pi * 2) + 400
    y4 = (Cos(t4) * 10) * (_Pi / 2) + 400
    r4 = (Cos(t4) * 180) / _Pi / 1.5 + 50
    t4 = t4 + (.25 + w / 10)
    x5 = (Sin(t5) * 20) * (_Pi * 2) + 400
    y5 = (Cos(t5) * 10) * (_Pi / 2) + 400
    r5 = (Cos(t5) * 180) / _Pi / 1.5 + 50
    t5 = t5 + (.25 + w / 10)
    x6 = (Sin(t6) * 20) * (_Pi * 2) + 400
    y6 = (Cos(t6) * 10) * (_Pi / 2) + 400
    r6 = (Cos(t6) * 180) / _Pi / 1.5 + 50
    t6 = t6 + (.25 + w / 10)
    For S = .25 To r4 Step .1
        cc4 = cc4 - .25
        Circle (x4, y4), S, _RGB32(cc4, cc4, 100 + cc4)
    Next S
    cc4 = 200
    For S = .25 To r5 Step .1
        cc4 = cc4 - .25
        Circle (x5, y5), S, _RGB32(cc4, 100 + cc4, cc4)
    Next S
    cc4 = 200
    For S = .25 To r6 Step .1
        cc4 = cc4 - .25
        Circle (x6, y6), S, _RGB32(100 + cc4, cc4, cc4)
    Next S
    cc4 = 200
    Line (400, 400)-(x4, y4), _RGB32(255, 255, 255)
    Line (400, 400)-(x5, y5), _RGB32(255, 255, 255)
    Line (400, 400)-(x6, y6), _RGB32(255, 255, 255)
    cc2 = 100
    For sz = .1 To 100 Step .25
        cc2 = cc2 - .25
        Circle (400, 550), sz, _RGB32(100 + cc2, 100 + cc2, cc2), , , .5
    Next sz
    Line (400, 200)-(400, 550), _RGB32(255, 255, 255)
    _Display
    Cls
Loop Until InKey$ = Chr$(27)
Reply
#2
Cool stuff. I like the scroll-wheel control.
Reply
#3
Thanks Smile
Reply
#4
Great! It's even movable. What are the routines that create the movement?

I once designed a rocket with CorelDraw, but I couldn't get it moving. It's supposed to look like it's flying up.

[Image: Nicks-Rakete-C-All.jpg]
Reply
#5
(08-23-2022, 03:02 PM)Kernelpanic Wrote: Great! It's even movable. What are the routines that create the movement?

I once designed a rocket with CorelDraw, but I couldn't get it moving. It's supposed to look like it's flying up.

[Image: Nicks-Rakete-C-All.jpg]

For each of the lights, it does the following, where X and Y is the middle of the circle and w is the wheel of the mouse. r is the radius of the circle light. It's in a loop where t keeps changing making it go a full orbit. But t starts out outside of the loop with this: t = (_Pi / 2) * 100, which is just the radian of where the location of the orbit will be. I timed it by 100 to make it easier to understand. 
To get the mouse wheel, do this:   While _MouseInput: wheel = wheel + _MouseWheel: Wend     
Then I make w = wheel so I could also add the random mode. 

Code: (Select All)
    x = (Sin(t) * 20) * (_Pi * 2) + 400
    y = (Cos(t) * 10) * (_Pi / 2) + 200
    r = (Cos(t) * 180) / _Pi / 1.5 + 50
    t = t - (.25 + w / 10)
Reply




Users browsing this thread: 2 Guest(s)