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.

DarkBASIC Professional Discussion / Scraggle's BMP Font tutorial - Image number illegal

Author
Message
Chris Franklin_
19
Years of Service
User Offline
Joined: 21st Dec 2006
Location: Home
Posted: 17th Mar 2010 03:56
Been following Scraggle's tutorial from one of the old 08 newsletters, downloaded the source code and ran the example floorlessly, however when copying the functions over into my own project and using the same syntax I end up with a Image Number Illegal error, the only difference from mine to the tutorial is that I'm using FreeImg(), FreeSprite() functions for my media.

My code:



The error is on line:



Been having an attempt to fix it but all day, if anyone needs I can attach the media as well.

Thanks in advanced.

Coding.....again, back to the basics xD
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Mar 2010 09:29
I think it might be freesprite, or freeimg, confusing the example code.

I mean:

FontImg = FreeIMG()
Rem Font stuff
FontImg = LoadBMfont("LED Red.png")

You assign FontImg to a free image, then use LoadBMfont to load it's own temporary image, which in turn uses it's own image referencing.

I suggest figuring out the image and sprite referencing that the bitmap fonts use, like what range of images and sprites does it use - then get rid of the freeimg and freesprite stuff. Thing is, it could easily cause issues as the bitmap fonts don't care about freesprites, they take however many sprites they need, in sequence. Your bitmap fonts are at war with the rest of the code! - your code says please, but the bitmap fonts just take (they have to).

Easy solution, is to make your own FreeImg and FreeSprite functions, so you can accommodate the ranges that bitmap fonts use. For instance, if bitmap font sprites start at 100, and you might need over 100 characters on screen at one time, then I would just start my own sprites at 500, giving 400 sprites to the font system, which should be plenty. If you made an image and sprite global to store the current ID, use an image, increment the ID, and you'll never re-use an image. Same goes for sprites. And with set ranges, say 100 to whatever the current sprite is, you can make quite neat clearing functions and then can reset the sprite ID.


Health, Ammo, and bacon and eggs!

Login to post a reply

Server time is: 2026-07-26 21:12:22
Your offset time is: 2026-07-26 21:12:22