
Animation is integral to many parts of GUIs, including both the fancy effects when things change used in window managers, and of course games.   The core of any animation system is a scheme for periodically changing the display while still remaining responsive to the user.   This task demonstrates this.



Task

Create a window containing the string "Hello World! " (the trailing space is significant).

Make the text appear to be rotating right by periodically removing one letter from the end of the string and attaching it to the front.

When the user clicks on the (windowed) text, it should reverse its direction.




 
1 rem rosetta code
2 rem task: animation
10 t$="hello world! ":d=-1
20 print chr$(147);:rem clear screen
30 print "*****************"
35 print "*               *"
40 print "*               *"
45 print "*               *"
50 print "*****************"
60 print "{HOME}{DOWN}{DOWN}{RIGHT}{RIGHT}"t$
70 get k$
75 if k$=" " then d=not d
80 on (abs(d))+1 gosub 1000,1010
90 if k$="q" then print chr$(147):end
95 rem 
100 rem between line 80 and line 999
110 rem check for other user input
120 rem and process accordingly
130 rem
999 for i=1 to 100:next:goto 60
1000 t$=right$(t$,len(t$)-1)+left$(t$,1):return
1010 t$=right$(t$,1)+left$(t$,len(t$)-1):return
 