Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Program Announcements / My BMP Font Engine - FREE FOR ALL TO USE!

Author
Message
Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 15th Dec 2005 09:31
I've been working on a decent BMP font engine for the last week, using DBP.

It's pretty flexible. It can draw any kind of String which is passed to it (including the STR$() strings).

I've attached the full project to this post.

You may use part or all of the code how you want in your games, you dont have to give credit to me.

Attachments

Login to view attachments
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 15th Dec 2005 10:20
Your load font and get character functions are a bit inefficient - should be a better way than a whole load of IF statements...

adr
21
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 15th Dec 2005 10:57
I've got something similar called "SPR_pasteString". It loops through each letter in the string and grabs the ASCII integer, so 64 for 'A' etc... the ASCII value is then processed subtracting an offset (depending on the ASCII value).

Basically - try and find a mathematical way of determining which image to use, rather than 50 or so ifs.

New 'n' Improved sig details how little I accomplish
Torrey
20
Years of Service
User Offline
Joined: 20th Aug 2004
Location: New Jersey
Posted: 15th Dec 2005 11:19
What's wrong with using IF statements? When it works down to machine code it's simply a CMP instruction with a conditional jump instruction afterwards. The only bad part is the readability of some code if lots of them are used. Depending on how many function calls are made and also data conversions made will determine whether or not the program will be slow or fast.

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 15th Dec 2005 11:21
I tend to use an array, like just chars(256) and use a text string with each character I'm using, so you can cross reference the ascii value with the array to check out the image number to use. It's nice and fast and it's easy to add extra characters.

Bitmap font scrollers will always have a place in my heart .


Van-B

Put away, those fiery biscuits!
adr
21
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 15th Dec 2005 11:42
Quote: "What's wrong with using IF statements?"

I have nothing against IF statements - some of my best friends are IF statements. All that's being said is that doing 50xlen(s$) per sync is a little wasteful. Nobody said it was bad, just that there are lighter ways of acheiving the same result.

New 'n' Improved sig details how little I accomplish
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Dec 2005 14:49 Edited at: 15th Dec 2005 15:28
Feel free to enhance it with the following code. the first function takes one image containing all of your bitmap font characters, and splits it into individual bitmaps. You just specify the base image, how many characters it contains horizontally and vertically, and the image number you want it to start writing them out to. It will do the rest, AND it retains the alpha channel! GET IMAGE loses it, so I did it using memblocks.



Secondly, if you want to get rid of the large number of IFs, just use an offset value. To change a character to a value between 1 and 26, for example, just use

a = asc(myChar$)-32

You can then use this value to pick your image number.

Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 15th Dec 2005 17:43
Im working On it, thanks for the feedback guys

Login to post a reply

Server time is: 2024-11-22 18:47:10
Your offset time is: 2024-11-22 18:47:10