
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.




 
'here accordingly to the version, QB or QBX
REM $INCLUDE: 'QBX.BI'
 
DIM REGS AS REGTYPE
DIM C AS STRING, SIZ AS INTEGER
DIM I AS DOUBLE, DIRE AS INTEGER
C = "Hello World! "
SIZ = LEN(C)
 
SCREEN 12
'turn the cursor visible
REGS.AX = 1
INTERRUPT 51, REGS, REGS
 
DO
 I = TIMER
 LOCATE 1, 1
 PRINT C
 
 REGS.AX = 5            'read mouse's queue of occurred pressings
 REGS.BX = 0            'the left button
 INTERRUPT 51, REGS, REGS
 
 'BX is the selected button's quantity of occurred pressings
 IF REGS.BX <> 0 THEN
  IF REGS.CX >= 0 AND REGS.CX < SIZ * 8 AND REGS.DX >= 0 AND REGS.DX < 16 THEN
   DIRE = 1 - DIRE
  END IF
 END IF
 
 'AX is all buttons' status
 IF (REGS.AX AND 2) <> 0 THEN EXIT DO
 
 IF DIRE = 0 THEN
  C = RIGHT$(C, 1) + LEFT$(C, SIZ - 1)
 ELSE
  C = RIGHT$(C, SIZ - 1) + LEFT$(C, 1)
 END IF
 
 DO WHILE TIMER < I + .08
  IF TIMER < I THEN I = I - 86400       'midnight checking
 LOOP
LOOP