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.

AppGameKit Classic Chat / Text object to sprite

Author
Message
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 12th Jun 2013 13:35
Hi guys.

Just a quick post. Correct me if I am wrong, but text objects in agk are essential sprites of the letters built into words, then grabbed as a sprite, yes? However can I ask, how do you work the size command? Is this in pixels, or as a percentage based system? In essence, can you explain what the default size is for a text object in comparison to the image used for a font?

Also, if your looking for a new command request, would it be possible to have a makeimagefromtext or makespritefromtext functions to auto turn a text object into an image or sprite?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Jun 2013 16:38
Yes you are right, that's how the text objects are created. The size is the height of the text which depends on how much empty space the font has at the top and bottom so the actual letters may be smaller than that. Text objects are sized the same as sprites IE if you are using the percentage system then they will too.

It would not be too hard to make a sprite from a text object using the getTextTotalWidth, getTextTotalHeight, getImage commands. I don't know how the text objects are handled internally so I'm not sure how easy a command would be to add to the current command set.


this.mess = abs(sin(times#))
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jun 2013 17:19
Hmmmm, is that for certain Baxslash?

See, I was thinking that the text objects in AppGameKit are vertex arrays, so kinda like a mesh, but comprised of 2D plains. I'm led into this way of thinking because it's possible to change the position of individual characters. I just can't imagine how they'd go for a big, single image sprite when it could just be a vertex array, which avoids the problem of having big areas of empty space. Know what I mean? - the way text works right now screams vertex array, not rendered image.

Heck, if it is a rendered image then I want access to it!

I kinda like the ideal that I have made around the text objects... like they'd make pretty good tiled map systems, in fact it would be possible to write a whole game just using a single text object - just moving the pieces/characters around. If it turns out that it's just a single image, then I'll be disappointed.

Currently I'm adding item usage numbers to an inventory screen - drawing all the text, then using a special character to signify a tab or split, then changing the position of the characters, so the text will be repositioned all over the inventory screen, but it'll still be just a single text object. If it's just making a big image, then I'd be better off just making several text objects instead - due to the amount of white space.

Ideally, we'd have both - like a vertex array text, plus a command to render it onto an image - then we could make all sorts of cool text effects.

I got a fever, and the only prescription, is more memes.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Jun 2013 18:15
I misread actually, I thought they were individual sprites personally but not rendered into a single sprite.


this.mess = abs(sin(times#))
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 12th Jun 2013 18:18
What we need is a draw to image command or something.

Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 12th Jun 2013 19:45
Thanks for the feedback guys. Pretty sure they are made by grabbing the font letters as a series of sprites, then pasting these into an empty buffer to build the sentence and grabbing it as an image that we then manipulate like a sprite. I made a font and the end of my letter "a" ran slightly into the next letter, and every instance of that showed a little dot where the end of the "a" would have been. That's why changing them is a bit slow.

@baxslash,
I had the same idea, but as the clear screen commands don't work, to do that would result in the having to identifythe every sprite you had visible, hide it, set up your text, ggrab it delete it, then show all your ssprites. I go through a similar process to build my mini map in my civ clone, and it's a pain. In theory, and I never right it is stored as a reserved sprite, it shod be as simple as the clone sprite command but giving the source as the text object??
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Jun 2013 04:58
I made this snippet recently. Maybe you can make some use of it for whatever it is you want to try to do.
http://forum.thegamecreators.com/?m=forum_view&t=205111&b=6

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 14th Jun 2013 09:34
I emailed Paul, and apparently I called it right - the text is made from sprites that are grouped together and use a single draw call.

Now the question I have... is it faster to have a tile map as several sprites, or as a single text entity.

I got a fever, and the only prescription, is more memes.
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 15th Jun 2013 00:58 Edited at: 15th Jun 2013 00:59
@Van B,

Sorry, I'm not 100% sure what a vertex array is. So, are you saying that in essence every time AppGameKit draws a text object, it's pasting a sprite for every letter within the text object? That's surely GOT to be slower than rendering it once and grabbing the complete text object as an image, surely? DBPro never had text commands like that (that I remember) and that's the exact system I used to create custom message boxes in that and it was pretty quick.

I may have to have a play around, see which way is quicker - using AppGameKit to render the text objects, or building and storing them myself then just using them like a sprite. I guess if it was stored as a single sprite then you could size it however you wanted too, which may be beneficial.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 15th Jun 2013 01:17
Well it's not quite as bad as that, every sprite is basically a vertex array, it's just that sprites typically have just 4 vertexes. With text, the array would contain 4 vertexes per character, but the whole text is drawn in 1 draw call.

Once the text is updated, the render should be really quick, because the vertexes don't need to be calculated again until something changes. Changing the text string would be the biggest concern in terms of speed - but changing the position of a character should be pretty fast.

For example, if you had a progress bar with a row of dots that grows depending on progress - well most people would just use a left or mid...

t$=left("................",prog#*16)

Then set t$ to a text object. Well I'm thinking that this would be quite a slow method - it would actually be faster to add all those dots, then just position the characters off screen instead of changing the string. Probably a slim example, but with a screen full of text, something as simple as a flashing cursor done the 'obvious' way might really hamper performance.

I got a fever, and the only prescription, is more memes.

Login to post a reply

Server time is: 2024-04-28 19:23:46
Your offset time is: 2024-04-28 19:23:46