Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Glow Bug
#7
(8 hours ago)SierraKen Wrote: WOW I DID IT! Thanks guys, I used both of your examples to fix mine. I can use this with so many games I can't even imagine. Smile
Steve, I fixed the SUB name, yeah that was a bit strange lol and your recommendation on arrays and I put the main loop outside of the SUB and I removed that SUB. 

B+, I'm keeping with my math, but you did a great example for me on arrays, which fixed everything, although my arrays are nothing like yours. I really like the Num variable where you can change it anytime for as many bugs as you want, or do what you want with it. Smile

I hope everyone likes it.  

Code: (Select All)

_Title "Glow Bugs - by SierraKen"

Screen _NewImage(800, 600, 32)

Randomize Timer

num = 50

Dim oldx(num), oldy(num)
Dim d1(num), d2(num), s(num), d(num), t(num)
Dim x(num), y(num), xx(num), yy(num), si(num), red(num), green(num), blue(num)


oldx = 400
oldy = 300

For size = 1 To num
    si(size) = Rnd * 10
Next size

For colors = 1 To num
    red(colors) = Int(Rnd * 100) + 155
    green(colors) = Int(Rnd * 100) + 155
    blue(colors) = Int(Rnd * 100) + 155
Next colors


Do
    _Limit 200
    For n = 1 To num
        If d1(n) > d2(n) Then s(n) = s(n) + .1
        If d2(n) > d1(n) Then s(n) = s(n) - .1
        d(n) = d(n) + 1
        If d(n) > t(n) Then
            oldx(n) = oldx(n) + x(n)
            oldy(n) = oldy(n) + y(n)
            bugchange d1(n), d2(n), d(n), t(n)
        End If
        x(n) = Cos(s(n) * _Pi / 180) * d(n)
        y(n) = Sin(s(n) * _Pi / 180) * d(n)
        xx(n) = x(n) + oldx(n)
        yy(n) = y(n) + oldy(n)
        If xx(n) > 750 Then oldx(n) = 50: Cls: bugchange d1(n), d2(n), d(n), t(n)
        If xx(n) < 50 Then oldx(n) = 750: Cls: bugchange d1(n), d2(n), d(n), t(n)
        If yy(n) > 550 Then oldy(n) = 50: Cls: bugchange d1(n), d2(n), d(n), t(n)
        If yy(n) < 50 Then oldy(n) = 550: Cls: bugchange d1(n), d2(n), d(n), t(n)
        fillCircle xx(n), yy(n), si(n), _RGB32(red(n), green(n), blue(n))
        fillCircle xx(n) - (si(n) * .3), yy(n) - (si(n) * .3), si(n) * .2, _RGB32(100, 100, 100)
        fillCircle xx(n) + (si(n) * .3), yy(n) - (si(n) * .3), si(n) * .2, _RGB32(100, 100, 100)
        For sz = .1 To si(n) * .5 Step .1
            Circle (xx(n), yy(n) + (si(n) * .4)), sz, _RGB32(100, 100, 100), , , .5
        Next sz
    Next n
    Line (0, 0)-(800, 600), _RGB32(0, 0, 0, 10), BF
    _Display
Loop Until InKey$ = Chr$(27)
End


Sub bugchange (d1, d2, d, t)
    d1 = Rnd * 360
    d2 = Rnd * 360
    d = 0
    t = Int(Rnd * 360) + 1
End Sub


'from Steve Gold standard
Sub fillCircle (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
    Dim Radius As Integer, RadiusError As Integer
    Dim X As Integer, Y As Integer
    Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
    If Radius = 0 Then PSet (CX, CY), C: Exit Sub
    Line (CX - X, CY)-(CX + X, CY), C, BF
    While X > Y
        RadiusError = RadiusError + Y * 2 + 1
        If RadiusError >= 0 Then
            If X <> Y + 1 Then
                Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
    Wend
End Sub
Wow! Looks like Corona's back!
Looks great, Ken. Persistence (and a lot of perspiration, I bet) pays off! Nice work.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply


Messages In This Thread
Glow Bug - by SierraKen - Today, 01:23 AM
RE: Glow Bug - by SierraKen - Today, 02:16 AM
RE: Glow Bug - by SierraKen - Today, 02:31 AM
RE: Glow Bug - by SMcNeill - 11 hours ago
RE: Glow Bug - by bplus - 11 hours ago
RE: Glow Bug - by SierraKen - 8 hours ago
RE: Glow Bug - by PhilOfPerth - 5 hours ago



Users browsing this thread: 7 Guest(s)