A 'port' of this YouTube video that appeared on my timeline: https://www.youtube.com/watch?v=0yKwJJw6Abs
http://www.proggies.uk/misc/OneLineWaves.txt
Copy and paste into BB4W or a BBSDL IDE.
I'm sure others here can come up with a cleverer/shorter method.
One-liner wave animation
Re: One-liner wave animation
Cute use of reprogramming characters, and "TRUE=-1, FALSE=0"!
I guess you can make it a little more compact by reprogramming (say) the characters A-G (by changing 130 to 65), and then you can just print the string "ABCDEFGGFEDCB"
I'm trying to think how to get the colours cycle, without using an IF....
I guess you can make it a little more compact by reprogramming (say) the characters A-G (by changing 130 to 65), and then you can just print the string "ABCDEFGGFEDCB"
I'm trying to think how to get the colours cycle, without using an IF....
Re: One-liner wave animation
Good point - I must have thought of that myself, but perhaps considered it "better practice" to redefine only the top-bit-set (> 127) chars instead.
Anyway, this one's shorter than the original, but still not as short as it would be if going with your suggestion:
Code: Select all
MODE19:OFF:A=-255:COLOUR128,72,58,170:COLOUR7,134,122,222
c$="":FORI%=1TO13:c$+=CHR$(130+VALMID$("0123456654321",I%,1)):NEXT
FORI%=0TO6:VDU23,130+I%,A*(I%=0),A*(I%=1),A*(I%=2),A*(I%=3),A*(I%=4),A*(I%=5),A*(I%=6),0:NEXT
REPEAT:PRINTc$;:WAIT 1:UNTILFALSE
A little curious why the space is required in the 'WAIT 1' statement? There will be a reason for it, of course.
Re: One-liner wave animation
It's a 1-line demo - I'm not sure it's too important to preserve the other characters!
I looked at using the VDU equivalents of the COLOUR statements, but it's barely shorter. Can you save a few characters by using I rather than I%? It'll run a fraction slower, but that won't matter.
Am I right that IF statements will fail in a one-liner, or can you get away with it, if only by adding an ENDIF?

I looked at using the VDU equivalents of the COLOUR statements, but it's barely shorter. Can you save a few characters by using I rather than I%? It'll run a fraction slower, but that won't matter.
Am I right that IF statements will fail in a one-liner, or can you get away with it, if only by adding an ENDIF?
Re: One-liner wave animation
Yes, I spotted that one a few minutes after I posted. Always annoying when that happens!
You could try the trick employed in the famous one-line Tetris game 'Rheolism':Am I right that IF statements will fail in a one-liner, or can you get away with it, if only by adding an ENDIF?
Code: Select all
<statement> : <statement> : <statement> : IF <condition> <statement> : IF 0 ELSE : (continue with rest of program) : <statement> : <statement>
Code: Select all
MODE8:OFF:N=250:DIMa(N),r(N):FORI=1TON:a(I)=I/N:r(I)=RND(800):NEXT:OSCLI"REFRESH OFF":REPEAT:CLS
FORI=1TON:GCOL1+(I MOD15):CIRCLEFILL640+r(I)*COSa(I),512+r(I)*SINa(I),12:a(I)+=0.025*(1-r(I)/800)
IFa(I)>2*PI a(I)-=2*PI:IF0ELSE:NEXT:OSCLI"REFRESH":UNTILFALSE
Re: One-liner wave animation
Here's what I was trying to do, with the IF replaced by a truth test:
That trick with the IF looks evil: aren't you piling up nested IFs on the stack, or something?
You could probably replace the integer variables with variants, and save a few more characters....
Code: Select all
MODE19:OFF:A%=-255:FORI=0TO6:VDU23,65+I,A%*(I=0),A%*(I=1),A%*(I=2),A%*(I=3),A%*(I=4),A%*(I=5),A%*(I=6),0:NEXTI:b%=0:s%=1:REPEAT:COLOUR128,72,58,b%:COLOUR7,134,b%,222:PRINT"ABCDEFGGFEDCB";:b%+=s%:s%*=1+2*((b% MOD 254)=0):WAIT 1:UNTILFALSE
You could probably replace the integer variables with variants, and save a few more characters....
Re: One-liner wave animation
Code: Select all
VDU22,17,19,128,16,72,58,170,19,7,16,134,122,222,23,128,192,224,112,56,28,14,7,3,23,129,3,7,14,28,56,112,224,192,12
OFF:REPEAT:PRINTCHR$(128.5+RND(1));:WAIT 1:UNTILFALSE