Launch rocket with countdown and acceleration in stdout: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: Add a Perl 6 example)
Line 262: Line 262:
fcn cursor2Col(n){ print("\e[%dG".fmt(n)) }
fcn cursor2Col(n){ print("\e[%dG".fmt(n)) }


fcn main{
fcn __main__{
tall,tall := rocket.counts(), tall[tall.find("\n")+1];
tall,tall := rocket.counts(), tall[tall.find("\n")+1];
cls(); print(rocket); cursorUp(tall);
cls(); print(rocket); cursorUp(tall);
Line 273: Line 273:
// liftoff
// liftoff
ms:=1.0; // 1 sec
ms:=1.0; // 1 sec
foreach n in ([2..25]){
do(25){
println(flame); Atomic.sleep(ms);
println(flame); Atomic.sleep(ms);
ms=(ms - 0.04).max(0); // 40 milliseconds faster than last time
ms=(ms - 0.04).max(0); // 40 milliseconds faster than last time
}
}
}();</lang>
}</lang>
{{out}}
{{out}}
<pre>
<pre>