Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Screen Savers
#48
Ken's Spashes reminded of this:

Splats


Code: (Select All)
_Title "Splats" 'b+ 2020-01-12
' from eRATication/cheese wedge tests/ multiple explosions.bas 2018-07-28 translated from
'bomb.bas for SmallBASIC 0.12.2 [B+=MGA] 2016-05-09 from explosion study

Const xmax = 1300, ymax = 760, pi2 = 6.283185
Type particle
    x As Single
    y As Single
    dx As Single
    dy As Single
    size As Single
    spread As Single
    'tf AS INTEGER
End Type
ReDim Shared dots(1) As particle
Screen _NewImage(xmax, ymax, 32)
_FullScreen
Randomize Timer
Dim kolor As _Unsigned Long

While Not _KeyDown(27)
    Color , _RGB32(Rnd * 255, Rnd * 255, Rnd * 255)
    Cls
    stopit = (Rnd * 100) \ 1 + 15
    For i = 1 To stopit
        dx = Rnd * 60 - 30: dy = Rnd * 60 - 30: a = 7 * (Rnd * 10 - 5): b = 7 * (Rnd * 10 - 5)
        x = xmax * Rnd: y = ymax * Rnd
        r = Rnd * 255
        If InKey$ = " " Then toggle = 1 - toggle
        If toggle Then
            kolor = _RGB32(r, r, r)
        Else
            kolor = _RGB32(Rnd * 255, Rnd * 255, Rnd * 255)
        End If
        While x > -100 And x < xmax + 100 And y > -100 And y < ymax + 100
            splat x, y, kolor
            x = x + dx: y = y + dy
            dx = dx + a: dy = dy + b
            _Display
        Wend
    Next
    _Delay 5
Wend
System

Sub splat (x, y, kolor As _Unsigned Long)
    round = 5
    nRounds = (Rnd * 10) \ 1 + 1
    nDots = nRounds * round

    ReDim dots(1 To nDots) As particle
    For i = 1 To round
        NewDot i, x, y
    Next
    rounds = round
    For loopCount = 0 To 20
        If _KeyDown(27) Then End
        For i = 1 To rounds
            dots(i).x = dots(i).x + dots(i).dx
            dots(i).y = dots(i).y + dots(i).dy
            dots(i).dx = dots(i).dx * dots(i).spread
            dots(i).dy = dots(i).dy * dots(i).spread
            fcirc dots(i).x, dots(i).y, dots(i).size / 2, kolor
            dots(i).size = dots(i).size * dots(i).spread
        Next
        If rounds < nDots Then
            For i = 1 To round
                NewDot i, x, y
            Next
            rounds = rounds + round
        End If
        _Display
    Next
End Sub

Sub NewDot (i, x, y)
    angle = Rnd * pi2
    r = Rnd * 5
    dots(i).x = x + r * Cos(angle)
    dots(i).y = y + r * Sin(angle)
    dots(i).size = Rnd * 15 + 5
    r = Rnd * 3
    dots(i).dx = r * (15 - dots(i).size) * Cos(angle)
    dots(i).dy = r * (15 - dots(i).size) * Sin(angle)
    dots(i).spread = Rnd * .3 + .2
End Sub

Sub fcirc (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

   
b = b + ...
Reply


Messages In This Thread
Screen Savers - by bplus - 04-27-2022, 12:29 AM
RE: Screen Savers - by Dav - 04-27-2022, 02:26 PM
RE: Screen Savers - by bplus - 04-27-2022, 02:33 PM
RE: Screen Savers - by bplus - 04-30-2022, 11:55 PM
RE: Screen Savers - by Dav - 05-01-2022, 07:22 PM
RE: Screen Savers - by bplus - 05-01-2022, 08:26 PM
RE: Screen Savers - by bplus - 05-02-2022, 12:00 AM
RE: Screen Savers - by Coolman - 05-02-2022, 09:42 AM
RE: Screen Savers - by bplus - 05-03-2022, 02:13 AM
RE: Screen Savers - by bplus - 05-09-2022, 01:32 PM
RE: Screen Savers - by bplus - 05-19-2022, 07:22 PM
RE: Screen Savers - by bplus - 05-21-2022, 11:22 PM
RE: Screen Savers - by Pete - 05-21-2022, 11:27 PM
RE: Screen Savers - by bplus - 05-21-2022, 11:38 PM
RE: Screen Savers - by Pete - 05-22-2022, 04:39 AM
RE: Screen Savers - by bplus - 06-17-2022, 01:10 PM
RE: Screen Savers - by johnno56 - 06-18-2022, 12:23 AM
RE: Screen Savers - by Kernelpanic - 06-18-2022, 11:48 AM
RE: Screen Savers - by bplus - 06-18-2022, 01:47 AM
RE: Screen Savers - by bplus - 06-18-2022, 12:33 PM
RE: Screen Savers - by SierraKen - 06-20-2022, 09:50 PM
RE: Screen Savers - by bplus - 06-21-2022, 12:15 AM
RE: Screen Savers - by bplus - 06-29-2022, 04:52 PM
RE: Screen Savers - by SierraKen - 06-29-2022, 06:10 PM
RE: Screen Savers - by vince - 07-01-2022, 10:32 PM
RE: Screen Savers - by bplus - 07-01-2022, 11:05 PM
RE: Screen Savers - by bplus - 07-04-2022, 06:54 PM
RE: Screen Savers - by Kernelpanic - 07-04-2022, 09:11 PM
RE: Screen Savers - by bplus - 07-04-2022, 09:54 PM
RE: Screen Savers - by Kernelpanic - 07-05-2022, 02:14 PM
RE: Screen Savers - by bplus - 07-19-2022, 08:28 PM
RE: Screen Savers - by bplus - 08-28-2022, 12:55 AM
RE: Screen Savers - by TempodiBasic - 08-29-2022, 09:26 AM
RE: Screen Savers - by bplus - 09-06-2022, 12:35 AM
RE: Screen Savers - by SierraKen - 09-08-2022, 07:37 PM
RE: Screen Savers - by bplus - 09-09-2022, 02:22 AM
RE: Screen Savers - by SpriggsySpriggs - 09-15-2022, 04:38 PM
RE: Screen Savers - by bplus - 09-15-2022, 05:20 PM
RE: Screen Savers - by bplus - 01-31-2023, 04:21 PM
RE: Screen Savers - by vince - 02-01-2023, 07:27 AM
RE: Screen Savers - by bplus - 02-01-2023, 05:05 PM
RE: Screen Savers - by bplus - 03-13-2023, 10:51 PM
RE: Screen Savers - by vince - 03-31-2023, 11:09 PM
RE: Screen Savers - by bplus - 04-01-2023, 12:09 AM
RE: Screen Savers - by bplus - 05-14-2024, 03:00 PM
RE: Screen Savers - by PhilOfPerth - 05-15-2024, 08:24 AM
RE: Screen Savers - by bplus - 05-15-2024, 11:15 PM
RE: Screen Savers - by bplus - 08-20-2024, 12:00 AM



Users browsing this thread: 6 Guest(s)