Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a little tutorial STEP by STEP on scrolling in 2D graphic mode
#13
From Tempo's SCREEN 0 code...

Code: (Select All)
Width 80, 25 ' screen 0 only text 80 columns for 25 rows
_ControlChr Off
_Title "Scrolling text in SCREEN 0 with arrow keys"
Dim Row As String, Text(1 To 40) As String, cText(1 To 255, 1 To 40) As Integer, a As Integer, b As Integer, R As Integer, C As Integer
' initialization

' it builds a string of 255 characters
For a = 1 To 255
    Row = Row + Chr$(a)
Next a
' it builds  40 rows of 255 characters for row
For a = 1 To 40
    Text(a) = Right$(Row, a + 10) + Left$(Row, 255 - a - 10)
    For b = 1 To 255
        cText(b, a) = (b * a) Mod 7
    Next b
Next a

R = 1
C = 1
While -1
    _Limit 30
    Row = UCase$(InKey$)
    If Len(Row) = 2 Then
        Select Case InStr("HPKM", Mid$(Row, 2, 1))
            Case 1: R = R - 1
            Case 2: R = R + 1
            Case 3: C = C - 1
            Case 4: C = C + 1
        End Select
    End If
    If R = oldr And C = oldc Then _Continue
    oldr = R: oldc = C
    Cls , 0
    For a = 0 To 24
        Locate a + 1, 1
        If (a + R) < 41 And (a + R) > 0 Then
            For b = 1 To 80
                If (C + b - 1 < 256) And (C + b - 1 > 0) Then
                    Color , cText(C + b - 1, a + R)
                    Print Mid$(Text(a + R), C + b - 1, 1);
                Else
                    Color , 0
                    Print " ";
                End If
            Next b
        End If
    Next
    _Display
Wend
End

Minor modifications made for my purposes, only. I like this. From the old days, we couldn't get away with printing each character at a time. Too slow and you had to use PCOPY to remove flickering. In QB64 it's fast enough and _Display kills the flickering.

I'll give it a +2 because 1, it was made by another Italian, and 2, well it's in SCREEN 0!

Pete Big Grin
Reply


Messages In This Thread
RE: a little tutorial STEP by STEP on scrolling in 2D graphic mode - by Pete - 12-04-2024, 05:26 AM



Users browsing this thread: 15 Guest(s)