Text Scroller

Blitz3D Forums/Blitz3D Beginners Area/Text Scroller

RetroRusty(Posted 2004) [#1]
How do you create a smooth text scroller with a bitmap font to go from right to left? Anyone got any example code for this?

Thanks


WolRon(Posted 2004) [#2]
How about something like this:
Graphics 640, 480, 0, 1
SetBuffer BackBuffer()

Global bmpFont = LoadAnimImage("bitout.bmp", 8, 10, 0, 90)
;ScaleImage bmpFont, 2, 2

textstr$ = "This is sample text that scrolls across the screen."

xpos = 640

Repeat
	Cls

	Text xpos, 400, textstr$
	BMText xpos, 440, textstr$

	xpos = xpos - 1
	If xpos < -400 Then xpos = 640

	Flip
Until KeyHit(1)
End


Function BMText(x, y, txt$)
	For iter = 1 To Len(txt$)
		letter = Asc(Mid$(txt$, iter, 1)) - 33
		If letter > -1 And letter < 90 Then DrawImage(bmpFont, x+(iter-1)*8, y, letter)
	Next
End Function



WolRon(Posted 2004) [#3]
And this will create the font file used in the code above.
This is the first part...



WolRon(Posted 2004) [#4]
And the rest of it (since only so many characters are allowed per post...):



RetroRusty(Posted 2004) [#5]
This is great and works a treat :) Thanks WolRon :)


CS_TBL(Posted 2004) [#6]
Whoa, overkill :) .. There are WAAAAAAY shorter methods to create a mono-color image ^___^


BlackD(Posted 2004) [#7]
Yeah.. like this:


Simple program, which outputs a function which draws the text hehe. Of course you'd have to change the font name, the oldfile$ (where its being saved to, minus the .bb extension - it just overwrites the file if it exists) and the text itself to print. Not quite what you're looking for.. but here's a really cool example for people with nothing to do:

(slightly altered, so its standalone, not a function)


+BlackD


CS_TBL(Posted 2004) [#8]
I made my own font-creator-tool last week, in which I store a complete font (all ASCII chars) in something like 10 strings of 128 chars each. That amount heavily depends on the complexity of the font. But as it's partly RLE, it's not much.. this way I can store a complete font (or any mono-color image for that matter) in my exe without having to load anything. For now I use my own font-editor that supports all sizes up to 16x16.


WolRon(Posted 2004) [#9]
Whoa, overkill :) .. There are WAAAAAAY shorter methods to create a mono-color image ^___^
I know, I was being lazy...


DNielsen(Posted 2004) [#10]
@WolRon
Lazy or not, you provided a solution that worked :-) And when it all comes down to it, isn't that what matters?


Andy_A(Posted 2004) [#11]
Veering off topic, there are some RLE routines to store images in data statments.

http://www.blitzbasic.com/codearcs/codearcs.php?code=973

http://www.blitzbasic.com/codearcs/codearcs.php?code=974


Here's BlackD's image stored as RLE data statements. Example shows rotated images and curved text.



BlackD(Posted 2004) [#12]
Ooooh I like.. must learn how to do that. :)


WolRon(Posted 2004) [#13]
Now remember boys and girls. Copy and paste is not allowed. True programmers type in all of the above code by hand...


DNielsen(Posted 2004) [#14]
@WolRon
You are wrong. You convert it all to BINARY before you type it in! :-D


BlackD(Posted 2004) [#15]
I feel a compression competition coming on.. ;)