Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
XONIX
#8
Xonix Multi Balls

   

Animation 66 kB

Code: (Select All)
Randomize Timer: b = Int(Rnd * 10 + 15): a = Int(Rnd * 10 + 15): ' xonix135.bas
N = Int(Rnd * 5 + 3): Dim dx(N), dy(N), y(N), x(N), q$(N), c(N): _Font 17
For e = 1 To N: q$(e) = Mid$(Str$(e), 2, 1): Next ' XONIX fly color collision

For i = 1 To N
    If Rnd < .5 Then dx(i) = -1 Else dx(i) = 1
    If Rnd < .5 Then dy(i) = -1 Else dy(i) = 1
    y(i) = Int(Rnd * (b - 3) + 3): x(i) = Int(Rnd * (a - 3) + 3)
    d(i) = Int(Rnd * 4) + 1: c(i) = Int(Rnd * 5 + 1)
Next

For i = 1 To a: Print "#";: Next: Print ' area
For j = 1 To b - 2: Print "#";: For k = 1 To a - 2: Print ".";: Next: Print "#": Next
For i = 1 To a: Print "#";: Next

For q = 1 To 1000: _Delay .08
    For i = 1 To N: Locate y(i), x(i): Print " "

        If y(i) + dy(i) < 2 Or y(i) + dy(i) > b - 1 Then dy(i) = -dy(i)
        y(i) = y(i) + dy(i)
        If x(i) + dx(i) < 2 Or x(i) + dx(i) > a - 1 Then dx(i) = -dx(i)
        x(i) = x(i) + dx(i)

        For k = 1 To N - 1: For m = k + 1 To N
            If y(k) = y(m) And x(k) = x(m) Then c(k) = Int(Rnd*5+1): c(m) = Int(Rnd*5+1)
        Next: Next
        Locate y(i), x(i): Color c(i): Print q$(i)
Next: Next

If balls are collision: both balls change colors
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


Messages In This Thread
XONIX - by DANILIN - 06-04-2022, 04:35 PM
RE: XONIX - by triggered - 06-04-2022, 05:16 PM
RE: XONIX - by DANILIN - 06-04-2022, 05:33 PM
RE: XONIX - by madscijr - 06-04-2022, 05:57 PM
RE: XONIX - by DANILIN - 06-04-2022, 06:07 PM
RE: XONIX - by bplus - 06-04-2022, 07:04 PM
RE: XONIX - by vince - 06-06-2022, 11:41 PM
RE: XONIX - by DANILIN - 06-07-2022, 07:55 PM
RE: XONIX - by DANILIN - 09-13-2024, 07:08 PM



Users browsing this thread: 3 Guest(s)