Anonymous user
Launch rocket with countdown and acceleration in stdout: Difference between revisions
Launch rocket with countdown and acceleration in stdout (view source)
Revision as of 21:35, 6 August 2019
, 4 years ago→{{header|zkl}}: added code
m (→{{header|Rust}}: added zkl header) |
(→{{header|zkl}}: added code) |
||
Line 166:
=={{header|zkl}}==
{{trans|Go}}
<lang zkl></lang>▼
Uses ANSI terminal codes.
<lang zkl>var [const] rocket=
#<<<
0'~
/\
( )
( )
/|/\|\
/_||||_\
~, flame=" **";
#<<<
fcn cls { print("\x1B[2J") }
fcn cursorUp(n) { print("\e[%dA".fmt(n)) }
fcn cursorDown(n){ print("\e[%dB".fmt(n)) }
fcn cursor2Col(n){ print("\e[%dG".fmt(n)) }
fcn main{
tall,tall := rocket.counts(), tall[tall.find("\n")+1];
cls(); print(rocket); cursorUp(tall);
// count down to ignition
print("T minus: ");
foreach n in ([5..1, -1]){ print(n," "); Atomic.sleep(1); }
print(" Liftoff !"); cursorDown(tall); cursor2Col(1);
// liftoff
ms:=1.0; // 1 sec
foreach n in ([2..25]){
println(flame); Atomic.sleep(ms);
ms=(ms - 0.04).max(0); // 40 milliseconds faster than last time
}
{{out}}
<pre>
T minus: 5 4 3 2 1 Liftoff !
/\
( )
( )
/|/\|\
/_||||_\
**
**
**
**
</pre>
|