Code Snippet for custom counters font?

Posted By: MegaMarioDeluxe

Code Snippet for custom counters font? - 06/26/09 07:23

Hey all,

I'm working on a Mario 64 clone (as you possibly know) but anyway I was wondering if it's possible to make a counter display for the amount of lives remaining and coins my character is holding.

The file that holds the 16x16 numbers is located in my 'resources/' folder that is in my project's root folder.

This is the numbers in question:

I was wondering if anyone could do me a code snippet so that I could use the said digits in my game. The purple/magenta is transparent. I use A6 (3DGS v6.x) so if it's A6 compatible, that would be great.

Thanks! smile
~MegaMarioDeluxe
Posted By: EvilSOB

Re: Code Snippet for custom counters font? - 06/26/09 07:43

Add a "space" to the end of your image and you can just define it as a font.
FONT* H_Digits = "filename.bmp"; (assuming PRAGMA_PATH'ed)

Originally Posted By: from the manual FONT entry
...The bitmap must either contain 11 characters - numbers 0..9 and space - for numerical displays...

Posted By: MegaMarioDeluxe

Re: Code Snippet for custom counters font? - 06/26/09 07:49

Alright. So, how would you define a counter? I'm good with panels, but a rookie with counters. Sorry! :P
Posted By: EvilSOB

Re: Code Snippet for custom counters font? - 06/26/09 08:06

You know your panels? good.
Make a panel (or two) that contain "digits" elements (check the manual under DIGITS).
Make the digits the digits "Var" be global variables, and just tweak your player
action keep updating the global vars with the current health/coins scores.
Posted By: MegaMarioDeluxe

Re: Code Snippet for custom counters font? - 06/26/09 08:14

Well, I did define the font (I took the * out after the FONT) like so:

FONT NormDigits = <resources\mpldigits.bmp>,16,16;

But now it says: Error (164) Range over/underrun odd font size.

Did I do something wrong? I added a 1x16 pixels at the end of the image, but that seemed to have no effect...
Posted By: EvilSOB

Re: Code Snippet for custom counters font? - 06/26/09 08:19

Did you add the spacing to the end of the mpldigits.bmp file?
It should be 176 x 16.

(plus I have no idea on the transparency issue)

[EDIT] I noticed your PNG you posted above is oversized.
You have 10 characters of 16x16, so it should by 160x16.
But it is 168x16. Thats bad.
Your finished font-image NEEDS to be 176x16 including the space.
PS and the "transparent" color of a font is TRUE black. (RGB = 0,0,0)

Posted By: MegaMarioDeluxe

Re: Code Snippet for custom counters font? - 06/26/09 10:43

OK, I'll try that. Thanks! smile
Posted By: MegaMarioDeluxe

Re: Code Snippet for custom counters font? - 06/27/09 00:45

Got it working now for my coins and lives display! I just modded the example in the manual under "PANEL { name... }", now it's working fine.

Thanks again, EvilSOB! smile
Posted By: EvilSOB

Re: Code Snippet for custom counters font? - 06/27/09 07:30

Anytime.
© 2024 lite-C Forums