Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cursor avec typewriter effect
#1
Big Grin 
Hello world, hm, my name is Alain, i'm French (sorry if my english can be weird), so i would like to make the same display like this with a cursor :

[Image: AncientHonorableHog-size_restricted.gif]

And i can do this "bas" file, now :

Code:
_FULLSCREEN: SCREEN 9

DIM Text AS STRING
DIM Count AS INTEGER
DIM Start AS SINGLE

Text$ = "GREATINGS PROFESSOR FALKEN."
Curs$ = "Û"

COLOR 11, 0
CLS

gogo:
COLOR 11, 0
PRINT: PRINT
PRINT "";: INPUT "", A$

hop:
TIMER ON
FOR Count = 1 TO LEN(Text$)
    Start = TIMER
    COLOR 11, 0: PRINT MID$(Text$, Count, 1);
    DO
    LOOP UNTIL TIMER > Start + .01
NEXT Count
TIMER OFF
GOTO gogo


But, i don't know, how to diplay 'Curs$', after each letter of 'Text$', that the program display. And disappear at the end, to let the place for the cursor of the user...

Any idea to do that, please?

Thanks for your advice, and have a nice week Wink

Alain.
Reply
#2
Photo 
Hello Alain! Both your English and your taste in movies are excellent.

I'm not sure how to get the cursor there automatically, but you can fake it by printing the cursor, and then writing over it each iteration of the loop. You do this by using CSRLIN to find the current row, POS to find the current column, and LOCATE to move the print location.

Before the loop, print the cursor so the screen will be at a non-zero horizontal position
Code:
PRINT Cur$

Then, inside the loop each iteration, move the screen one space back, and print the cursor after each character:
Code:
LOCATE CSRLIN, POS(0) - 1
PRINT MID$(Text$, Count, 1); Cur$;

Finally, after the loop, "erase" the cursor by printing space over it:
Code:
LOCATE CSRLIN, POS(0) - 1
PRINT " "

That gives me the desired effect:
[Image: wargames.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)