Quote: "I need a Bitmap Fonts tutorial for dummies."
The bitmap font itself needs to be in the same order as the ASCII list to make it easier to paste the right images for each letter/number/symbol using the ASC() command.
The images should be in this order:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
The first character is space which is number 32 on the ASCII chart, the explanation point is number 33, quote is number 34 and so on till number 126 which is ~. Sometimes (like in this example) there are only higher case letters so the whole list isn't needed. We grab each letter with a different image number so each individual character is saved by itself. We generally start the image number higher so we don't have the first bitmap image starting at 32 (giving us some room for other images in our program). In the following code snip 100 is added to the image number so the space is 132.
When you use the ASC() command with text it returns the ASCII chart number of that character... so if your string is "HELLO" it returns (looking at each character separately), 72, 69, 76, 76, 79. Add 100 to each of those and you know that pasting image numbers 172, 169, 176, 176, 179 will show HELLO with the bitmap font.
` Load bitmap font
load bitmap "knight6.png",1
` Get images
CImage=132 ` Set the starting image number
for y=0 to 125 step 25
for x=0 to 290 step 32
` Grab each character
get image CImage,x,y,x+32,y+25
` Go to next image number
inc CImage
next x
next y
` Change to the main view
set current bitmap 0
` Call the text writing function
WriteText(20,100,"HELLO, HOW ARE YOU?")
wait key
end
function WriteText(x,y,Tex$)
` Go through each character of Tex$
for t=1 to len(Tex$)
` Get the ASCII value of the current character and add 100
a=asc(mid$(Tex$,t))+100
` Show the characters image
paste image a,x,y
` Space over for next letter
inc x,32
next t
endfunction