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 / Sprites Versus Text... Images instead of letters?

Author
Message
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 18th Jan 2011 06:07 Edited at: 18th Jan 2011 07:23
I'm looking for a method for using sprite images (of letters) to replace entry text / screen text. I've created a "sprite font" and wondered if anyone else has done this... I'm looking for a function. I can gather the info (text) entered in the entry buffer and grab the character via string len() and mid$(String$, Pos) but how do I "remember" what the first sprite letter is so that the other sprites can align with it?

-Daryn

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 18th Jan 2011 08:39 Edited at: 18th Jan 2011 08:40
Yeah, we make bitmap fonts all the time. Generally though we use pasted images instead of sprites and use ASC() to get the ascii code for each character to make the character/image number conversion easier.



Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 18th Jan 2011 09:13
Well actually I was using this method until I needed anti aliasing... so I can't grab the image from the screen, in fact the only option I have at the moment is sprites.

I'm trying to store all the sprite values in an array (which sprite = what letter) but for the moment I am stuck. Let me fiddle a bit more and then I'll post an exe.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 18th Jan 2011 10:31
I've managed smooth (anti-aliased) letters using Png Fonts. (It's basically just bitmap fonts but grabbing the transparency as well.)

And paste sprite generally works pretty much the same as paste image in my experience, if you exclude all the fancy things sprites do like rotation, diffuse alteration and alpha mapping.

Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 18th Jan 2011 11:12 Edited at: 18th Jan 2011 11:15
I am also using png fonts... the issue was "get image" and needing the display mode to be x,y,depth,vsync,2,0 - since we all know that returns "Illegal Surface" when grabbing an image from an anti-alias screen.

My question however is this...
Say that the word is "Doooooooo"
Since we're using more than one "o", we can't just associate the asc() and image number with the sprite number and likewise for any other duplicated letter. So how do I use the entry$(1) command and duplicate a sprite while being able to return the correct sprite number when more than one letter ("Oooooooo") is used?

BETTER YET (lol) - If I want the text centered how would I do that? Since were using sprites and I would need to know the first sprite's to position the next sprite's and then gather the width of both of them and divide by two....

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 18th Jan 2011 17:59
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Jan 2011 06:49
Quote: "My question however is this...
Say that the word is "Doooooooo"
Since we're using more than one "o", we can't just associate the asc() and image number with the sprite number and likewise for any other duplicated letter. So how do I use the entry$(1) command and duplicate a sprite while being able to return the correct sprite number when more than one letter ("Oooooooo") is used?
"


You can use different sprite numbers rather than the same sprite number for one letter... the only number that should be used in the ASC() command is the image number the sprite uses. Make the sprite letters a range of sprite numbers 1000 to 2000 (or more). Just do a check to see if the sprite already exists before creating a new sprite letter.

Quote: "BETTER YET (lol) - If I want the text centered how would I do that? Since were using sprites and I would need to know the first sprite's to position the next sprite's and then gather the width of both of them and divide by two...."


It's SCREEN WIDTH() divided by 2 minus the LEN() of the string times the IMAGE WIDTH() of one character divided by 2. Basically you start in the center of the screen and subtract the number of pixels from the center of the sprite string.

Same code above with sprites instead and centering:


Login to post a reply

Server time is: 2026-07-18 07:18:44
Your offset time is: 2026-07-18 07:18:44