Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a little tutorial STEP by STEP on scrolling in 2D graphic mode
#9
Now let's see a SCREEN 0 example!!!

Actually that's the one thing I haven't yet coded in SCREEN 0, a lateral scroll routine. The IDE uses one, which I presume is written in SCREEN 0.

Hmm, with arrays it's pretty easy...

Use arrow left and right keys to laterally scroll the text on the screen.
Code: (Select All)
ReDim l$(20)
For h = 1 To 20
    For i = 1 To Rnd * 50 + 60
        j = Int(Rnd * 10 + 48)
        l$ = l$ + Chr$(j)
        If Int(Rnd * 7) = 1 And Right$(l$, 1) <> " " Then l$ = l$ + " "
    Next
    l$(h) = l$: l$ = ""
Next
k = 1
Do
    For i = 1 To 20
        Locate i, 1:
        a$ = Space$(_Width)
        Mid$(a$, 1) = Mid$(l$(i), k, _Width)
        Print a$;
    Next
    Do
        _Limit 60
        b$ = InKey$
        Select Case b$
            Case Chr$(27): End
            Case Chr$(0) + "K"
                If k > 0 Then k = k - 1: Exit Do
            Case Chr$(0) + "M"
                k = k + 1: Exit Do
        End Select
    Loop
Loop

Now if the text is a single variable with line breaks, that would require a slightly different approach.
Code: (Select All)
Width 80, 25
_ScreenMove _Middle
For h = 1 To 20
For i = 1 To Rnd * 50 + 60
j = Int(Rnd * 10 + 48)
a$ = a$ + Chr$(j)
If Int(Rnd * 7) = 1 And Right$(a$, 1) <> " " Then a$ = a$ + " "
Next
a$ = a$ + Chr$(13) + Chr$(10)
Next
Rem a$ = _Clipboard$
Do
seed = 1
For i = 1 To 20
Locate i, 1
a1$ = Mid$(a$, seed, _Width + k)
If k < InStr(a1$ + Chr$(13), Chr$(13)) Then a1$ = Mid$(a1$, k + 1) Else a1$ = ""
If InStr(a1$, Chr$(13)) Then a1$ = Mid$(a1$, 1, InStr(a1$, Chr$(13)) - 1)
x$ = Space$(_Width)
Mid$(x$, 1) = a1$
Print x$;
seed = InStr(seed, a$, Chr$(13)) + 2
Next
Do
_Limit 60
b$ = InKey$
Select Case b$
Case Chr$(27): End
Case Chr$(0) + "K"
If k > 0 Then k = k - 1: Exit Do
Case Chr$(0) + "M"
k = k + 1: Exit Do
End Select
Loop
Loop

Anyway, not goof proofed so if you remove the remark at the _clipboard option just be sure you copy enough text to cover 20 or more lines. This is just what I would start out with a s way of displaying and horizontally scrolling text in SCREEN 0.

Pete
Shoot first and shoot people who ask questions, later.
Reply


Messages In This Thread
RE: a little tutorial STEP by STEP on scrolling in 2D graphic mode - by Pete - 12-02-2024, 07:27 PM



Users browsing this thread: 8 Guest(s)