XONIX
#1
? xonix ? ... XoniX ... !!! XONIX !!!

Code: (Select All)
Randomize Timer: b = Int(Rnd*15+5): a = Int(Rnd*15+5): ' xonix.bas
y = Int(Rnd*(b-3)+3): x = Int(Rnd*(a-3)+3): d=Int(Rnd*4+1)
'y = 5: x = 5: b = 10: a = 20: d=1 ' xonix.bas

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 .03: Locate y, x: Print " "

    If d=1 Then If (y-1 = 1) And (x+1 = a) Then d=3
    If d=1 Then If (y-1 > 1) And (x+1 = a) Then d=4
    If d=1 Then If (y-1 = 1) And (x+1 < a) Then d=2
    If d=1 Then y = y-1: x = x+1

    If d=2 Then If (y+1 = b) And (x+1 = a) Then d=4
    If d=2 Then If (y+1 < b) And (x+1 = a) Then d=3
    If d=2 Then If (y+1 = b) And (x+1 < a) Then d=1
    If d=2 Then y = y+1: x = x+1

    If d=3 Then If (y+1 = b) And (x-1 = 1) Then d=1
    If d=3 Then If (y+1 < b) And (x-1 = 1) Then d=2
    If d=3 Then If (y+1 = b) And (x-1 > 1) Then d=4
    If d=3 Then y = y+1: x = x-1

    If d=4 Then If (y-1 = 1) And (x-1 = 1) Then d=2
    If d=4 Then If (y-1 > 1) And (x-1 = 1) Then d=1
    If d=4 Then If (y-1 = 1) And (x-1 > 1) Then d=3
    If d=4 Then y = y-1: x = x-1

    Locate y, x: Print "@"
Next

qbasic qb64 xonix
gif 45 kB
   

https://en.wikipedia.org/wiki/Xonix
en.wikipedia.org/wiki/Xonix
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
#2
What in the world is this?
Reply
#3
I have long dreamed of creating a sketch
about a flying balloon from scratch
and created it in an hour

I suppose locals could have composed
much shorter than my program in past

Program create a random area
and in a random place ball starts and flies

There was an idea to apply "screen(y-1, x+1) =35"
however a non-optimal program would become longer

My program is universal:
creating an array of coordinates
there will be a lot of flying balls
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
Wasn't Xonix the company who made those "double ender" cartridges for the Atari 2600 back in the '80s?
Reply
#5
I'm a fan of ZX spectrum 48k

https://rosettacode.org/wiki/Category:ZX_Spectrum_Basic
rosettacode.org/wiki/Category:ZX_Spectrum_Basic

behind post is better:

_Font 17 ' biger
...
Color 0, RND*15
...
Color RND*15, 0
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
#6
Expanding on the subject of WTH?
Code: (Select All)
_Font 8
m = 3: n = 2
restart:
_Title Str$(m) + " x" + Str$(n): Cls
x = 1: y = 1: dx = 1: dy = 1: c = 0
move:
Locate y + 1, x + 1: Print Chr$(219);
If x + dx < 1 Or x + dx > m Then dx = -dx
x = x + dx
If y + dy < 1 Or y + dy > n Then dy = -dy
y = y + dy
Color 0, 15
Locate y + 1, x + 1: Print "X";
Color 15, 0
_Limit 30
c = c + 1
If c > (m * n) Then
    toggle = 1 - toggle
    If toggle Then n = n + 2 Else m = m + 2

    _Delay 1
    GoTo restart
Else
    GoTo move
End If
b = b + ...
Reply
#7
interesting mod, B+
Reply
#8
Xonix Multi Balls

   

Animation 66 kB

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

For i = 1 To N
    y(i) = Int(Rnd*(b - 3)+3): x(i) = Int(Rnd*(a - 3)+3): d = Int(Rnd*4+1)
    d(i) = Int(Rnd*4)+1: c(i) = Int(Rnd*5+1)
Next 'y(i)=5: x(i)=5: b=10: a=20: d=1 ' xonix.bas DANILIN

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 d(i)=1 Then If (y(i)-1=1) And (x(i)+1=a) Then d(i)=3
        If d(i)=1 Then If (y(i)-1>1) And (x(i)+1=a) Then d(i)=4
        If d(i)=1 Then If (y(i)-1=1) And (x(i)+1<a) Then d(i)=2
If d(i)=1 Then y(i)=y(i)-0.5*(1+i mod 2): x(i)=x(i)+0.5*(1+i mod 2)

        If d(i)=2 Then If (y(i)+1=b) And (x(i)+1=a) Then d(i)=4
        If d(i)=2 Then If (y(i)+1<b) And (x(i)+1=a) Then d(i)=3
        If d(i)=2 Then If (y(i)+1=b) And (x(i)+1<a) Then d(i)=1
If d(i)=2 Then y(i)=y(i)+0.5*(1+i mod 2): x(i)=x(i)+0.5*(1+i mod 2)

        If d(i)=3 Then If (y(i)+1=b) And (x(i)-1=1) Then d(i)=1
        If d(i)=3 Then If (y(i)+1<b) And (x(i)-1=1) Then d(i)=2
        If d(i)=3 Then If (y(i)+1=b) And (x(i)-1>1) Then d(i)=4
If d(i)=3 Then y(i)=y(i)+0.5*(1+i mod 2): x(i)=x(i)-0.5*(1+i mod 2)

        If d(i)=4 Then If (y(i)-1=1) And (x(i)-1=1) Then d(i)=2
        If d(i)=4 Then If (y(i)-1>1) And (x(i)-1=1) Then d(i)=1
        If d(i)=4 Then If (y(i)-1=1) And (x(i)-1>1) Then d(i)=3
If d(i)=4 Then y(i)=y(i)-0.5*(1+i mod 2): x(i)=x(i)-0.5*(1+i mod 2)

        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




Users browsing this thread: 2 Guest(s)