The challenge is this :
- Create a scrolling text bar like a stock ticker.
- It can display any text you want.
Something like this?
' E.K.Virtanen; Public Domain ' FreeBASIC stuff Option Explicit ' Location stuff. Center of screen. Const MinY = 10 Const MaxY = 30 Const X = 15 Const Black = 0 Const Yellow = 14 Const Delay = 100 ' milliseconds. Const Empty = (CHR$(32) + CHR$(32) + CHR$(32) + CHR$(32) + CHR$(32)) Screen 14 Color Yellow, Black : CLS DIM Text AS String INPUT "Write text to scroll "; Text IF LEN(Text) < 1 THEN Text = "Default Text..." Text = (Text + Empty) DIM ScrollText(LEN(Text)) AS String DIM Counter AS Integer ' Lets create an array of text For Counter = 0 TO LEN(Text) ScrollText(Counter) = MID(Text, Counter, 1) Next Counter Color Yellow, Black : CLS DO ' from start of array to end of array For Counter = 0 TO UBOUND(ScrollText, 1) ' if we are on first letter, we need to move it as last one. IF Counter = 0 THEN ScrollText(UBOUND(Scrolltext, 1)) = ScrollText(Counter) END IF ' and if its not first letter, we go normally IF Counter > 0 THEN ScrollText(Counter - 1) = ScrollText(Counter) END IF ' if it's on screen, we display it. IF Counter > MinY AND Counter < MaxY THEN LOCATE X, (MinY + Counter) Print ScrollText(Counter) END IF Next Counter ' short delay SLEEP Delay, 1 ' and we continue until user does press some button. LOOP Until INKEY$ <> "" END
Hmm.. this challange is practically undoable in Brutus2D… craps! I have to create my own font-object using images just so i can get the width of the characters of a string. It's not worth the hazzle :)