Spinning rod animation/Text: Difference between revisions

Content added Content deleted
(Added Java)
(Scala contribution added.)
Line 240: Line 240:
<br><br>
<br><br>


=={{header|Scala}}==
<lang Scala>object SpinningRod extends App {
val start = System.currentTimeMillis

def a = "|/-\\"

print("\033[2J") // hide the cursor

while (System.currentTimeMillis - start < 20000) {
for (i <- 0 until 4) {
print("\033[2J\033[0;0H") // clear terminal, place cursor at top left corner
for (j <- 0 until 80) print(a(i)) // 80 character terminal width, say
Thread.sleep(250)
}
}
print("\033[?25h") // restore the cursor

}</lang>
=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<lang ring>load "stdlib.ring"
load "stdlib.ring"
rod = ["|", "/", "-", "\"]
rod = ["|", "/", "-", "\"]
for n = 1 to len(rod)
for n = 1 to len(rod)
Line 248: Line 265:
sleep(0.25)
sleep(0.25)
system("cls")
system("cls")
next
next</lang>
</lang>
Output:
Output:
|
<pre>
/
|
-
/
\
-
\
</pre>


=={{header|zkl}}==
=={{header|zkl}}==