Text Scroller
Blitz3D Forums/Blitz3D Beginners Area/Text Scroller
| ||
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 |
| ||
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 |
| ||
And this will create the font file used in the code above. This is the first part... |
| ||
And the rest of it (since only so many characters are allowed per post...): |
| ||
This is great and works a treat :) Thanks WolRon :) |
| ||
Whoa, overkill :) .. There are WAAAAAAY shorter methods to create a mono-color image ^___^ |
| ||
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 |
| ||
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. |
| ||
Whoa, overkill :) .. There are WAAAAAAY shorter methods to create a mono-color image ^___^ I know, I was being lazy... |
| ||
@WolRon Lazy or not, you provided a solution that worked :-) And when it all comes down to it, isn't that what matters? |
| ||
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. |
| ||
Ooooh I like.. must learn how to do that. :) |
| ||
Now remember boys and girls. Copy and paste is not allowed. True programmers type in all of the above code by hand... |
| ||
@WolRon You are wrong. You convert it all to BINARY before you type it in! :-D |
| ||
I feel a compression competition coming on.. ;) |