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 11:26, 7 July 2021
, 2 years ago→{{header|Nim}}
m (→{{header|Phix}}: added syntax colouring the hard way) |
|||
Line 252:
/_\/_\
</pre>
=={{header|Nim}}==
{{trans|Julia}}
Using <code>terminal</code> module from standard library rather the escape codes.
<lang Nim>import os, math, terminal
proc rocket() =
echo " /..\\\n |==|\n | |\n | |\n",
" | |\n /____\\\n | |\n |SATU|\n | |\n",
" | |\n /| | |\\\n / | | | \\\n /__|_|__|__\\\n /_\\/_\\\n"
proc exhaust() =
echo " *****"
proc countDown(secs: Natural) =
stdout.write "Countdown...T minus "
stdout.flushFile
for i in countdown(secs, 1):
stdout.write i, "... "
stdout.flushFile
os.sleep(1000)
stdout.write "LIFTOFF!"
stdout.flushFile
proc engineBurn(rows: Natural) =
echo '\n'
for i in 1..rows:
exhaust()
sleep (0.9^i * 1000).toInt
proc testRocket() =
eraseScreen()
rocket()
cursorUp(16)
countDown(5)
cursorDown(13)
engineBurn(30)
testRocket()</lang>
{{out}}
Same as Julia program output.
=={{header|Perl}}==
|