|
-
Jun 13th, 2024, 11:49 AM
#1
Thread Starter
PowerPoster
Timing auto-scrolling text
I'm trying to find the best way to auto-scroll text at a speed that's suitable for the user. I don't think using my own experience is the right way to go about it because of some of the same reasons you need an editor when you write - you think you know what you wrote and you skim it without actually reading it in real time.
So the problem is how long to delay text before the next thing is added.
What I landed on is letting the user enter a number in milliseconds (per character of text) that the text is displayed.
Also, important things have a built-in pause that happens no matter what.
So if you get a point then it pauses for a second PLUS whatever time the user has entered.
Because the text-length can vary and changes get made that make the text longer or shorter, whatever I think is an appropriate pause may be way too long or way too short for any given user.
In the below, you can ignore it all to the very end where this is implemented. I think it's a good system but if there's a better way I'd love to hear about it.
So how it works is that it's ms/character.
If the setting is 2 and the length of the text is 100 characters then it will pause for 200 ms before the next thing.
Make sense?
This is the code:
Code:
Public Sub AddPlayerMessage(ByRef TextToAdd As String, Optional ByRef AdditionalPauseInMS As Long = 0, Optional ByRef ShowInAuxWindow As Boolean = False)
Dim m_CallStacker As New cCallStacker
Dim nDieSides As Long
m_CallStacker.Add NAME & ".AddPlayerMessage(Public Sub)"
If fLoading Then Exit Sub
If SeeMoreDieRolls Then
nDieSides = 10000
Else
nDieSides = 2000
End If
If Int(Rnd * nDieSides) + 1 = 1 Then Flicker frmCallstackGame.txtMessage, Int(Rnd * 2000) + 1
If (ShowInAuxWindow Or fGamePaused) And frmAuxilliaryMessage.Visible Then
frmAuxilliaryMessage.AddPlayerMessage TextToAdd
Exit Sub
End If
If fGamePaused Then Exit Sub
With frmCallstackGame.txtMessage
If Len(.Text) >= 30000 Then
.Text = Right$(.Text, 500)
End If
.SelStart = Len(.Text)
.SelText = vbCrLf & TextToAdd
.SelStart = Len(.Text)
End With
If GameDelay + AdditionalPauseInMS > 0 Then
Sleep (GameDelay * Len(TextToAdd)) + AdditionalPauseInMS
End If
End Sub
-
Jun 13th, 2024, 12:09 PM
#2
Thread Starter
PowerPoster
Re: Timing auto-scrolling text
Some call examples:
The auxilliary window ignores timing. It displays stuff as fast as the system allows.
This really doesn't matter that much until there's a whole bunch of text. For example, the app is like an old text-based game where it gives you a prompt and a bunch of numbered choices. I want the user to have time to read all the choices before it scrolls.
In this case that matters because the user isn't actually playing. The game randomly chooses one of the choices and moves along. If I were writing a real game it would just stop until the user made a choice. But this isn't that.
Code:
AddPlayerMessage s, 0, True ' < - this goes to the aux window (true). Thus the 0 is irrelevant. It could be 10000 and would be ignored.
AddPlayerMessage AddAsterisks("A Rival Developer Stole Your Code!"), 2000 ' < this goes to the main window with a pause of 2000 ms PLUS whatever time the user entered per character.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|