best guilib for games, not apps

Blitz3D Forums/Blitz3D Userlibs/best guilib for games, not apps

ryan scott(Posted 2005) [#1]
a similar question was just asked, but this is different -


what is the best way to make game interfaces? i'm assuming a gui lib? if so what's the best one for the menus you make in games? i'm not looking to have a whole windowing system, that's overkill. but i don't want to code the whole thing myself either - so i think i need very customizable labels, mouseover areas, things like that.

When I looked at BlitzUI, we've got this very attractive windows-like interface, which isn't very game like. xlnt has zero screen shots which i found very peculiar.

any suggestions? sprite candy?


QuickSilva(Posted 2005) [#2]
Personally I`d go for Sprite Candy. It has some neat game GUI style effects built in and a host of other cool features that you can use in your game. Check out the demo for a good idea of its features.

Jason.


sswift(Posted 2005) [#3]
My GUI system is designed for games. It isn't a GUI system with windows and stuff.

It is a GUI system which lets you overlay sprites on the screen, and create text of any resolution using as few textures and surfaces as possible.

The text can wrap automatically.

What makes it a GUI system is that there are functions that tell you when you are over these sprites or text objects. There are functions that tell you when the mouse has entered one, or exited one.

And there are two animation systems that come with it that support animationg motion and the brush properites, using linear naimation or sine waves, and the animations can be one shot, looped, or ping pong.

AND it will tell you when an animation is finished.

So you can make a sprite for each menu item on your main menu, and make them zoom in from off screen, slow down, and come to a stop in the desired location. AND you an make them become prgressively less transparent while doing this. AND you can query the system to tell when the animation is done so you can start checking for input. AND you can check to see if the mosue has entered a sprite. And when you detect this you can set the animation to a glowing image animation. And you can detect when the mouse exits a sprite. And set the animation back to normal.

Not only can you do all that, but the system also has basic life bars which are linear or circular. You set the value and the bar's length changes.

Also, the system supports groups, so you can specify that all the menu sprites are in group 1, and hide group 1 to hide all those sprites at once.

Click the link below in my sig for a demo.


MadJack(Posted 2005) [#4]
Sswifts Gui system does have some nice features - particularly the customisable progress bars, groups and animation.

But he could add a few more options out-of-the-box when it comes to text formatting (e.g. centred, right aligned, full justification, adjustable kerning, leading). Obviously the user could alter the supplied code to allow for those things, but still...

I also use a lot of functions and as the GUI objects are referenced by a type, I have to declare a GUI object as a global in order to get at it within a function (or am I missing something here? - I do have an aversion to types)

Also no extended features such as drop-down lists etc.. although that could be said to be not within the scope of of a 'game gui'.

And no supplied GUI editor (although it'd be easy enough to write one yourself) that allows the user to move/scale/add elements to build up an interface interactively and then perhaps spits out a data list.


N(Posted 2005) [#5]
I vote for sswift's.


sswift(Posted 2005) [#6]
"I also use a lot of functions and as the GUI objects are referenced by a type, I have to declare a GUI object as a global in order to get at it within a function (or am I missing something here? - I do have an aversion to types)"


I don't really understand the question.

Of course you have to declare them as global if you create them outside a function, or in a function, and want to access them from inside function. There is no way around that. How else would you access them?

If you do this:

Function Blah()
    MySprite.whatever = GUI_Functionblah()
End function


Then you have created a gui object, bue the variable you use to reference is is only accessable from within that function. It doesn't matter whether I used types or whether I return an index into an array. You still won't have that data outside the function.

Now, if you have a sepcial case and you want to get that data from in the function without a global variable, and yuou only need one value, then you can do this:

ThisSprite.whatever = Blah()

Function Blah.whatever()
    MySprite.whatever = GUI_Functionblah()
End function



There's nothing wrong with how I coded my GUI system. :-)


As for drop down lists, buttons, and other GUI elements that you can easily create with the supplied functions, I chose not to code those for you because there's too many different ways people might want them to look and behave.

And there is no gui editor because most of the look of a gui like this is defined by the graphics you stick on the sprites. I'm not going to force you to load your art a certain way, and there's too many options for how you might want things to move or animate anyway.

I design my systems for maximum flexibility. No useless stuff most people won't use because it does not fit their needs exactly. :-)


Caff(Posted 2005) [#7]
Sswift, how do your text functions handle variable width fonts (e.g. the width between 'i' and 'W')? And also can you adjust the kerning?

Also, with the increasing number of widescreen TFT's on display, how well would the scaling work on non-standard aspect ratios?

I'm currently using Fontext to both generate bitmap fonts and also display GUI objects such as a mouse cursor, just interested to know whether sswift GUI could handle it a bit better.


BlitzSupport(Posted 2005) [#8]
Quite a few here... the BCF ones are pretty good looking.


Shifty Geezer(Posted 2005) [#9]
Regards GUI, sswift's is good if you don't want text. I bought sswift's system but found the text blurs out a bit. This is because the text is rendered as a texture so you don't get perfect pixel to pixel mapping.

For my needs, a simple set of buttons (non animated at the mo') and text, I combine 2D drawing with 3D in my ToodeeGooey lib. This works very well, but not on older cards that can't mix 2D and 3D. So on my Ti4200 it has no impact. On a test machine with GeForce 2 (I think) the 2D cripples the 3D. I can get round this by disabling the 2D drawing (mouse) while the 3D is being drawn, but that's far from ideal for most games.

If you need graphics in/over 3D, sswift's is probably a good buy, but realise you won't get perfect clarity on text, especially small text, or bitmaps, because of the limitations of combining 2D and 3D (which aren't his fault!). If you need clarity (text based RPG for example) and can freeze out the 2D aspect when drawing in 3D, or if you're only targetting better spec'd cards, use 2D drawing functions, but I don't think there's any library out there to help. At least I didn't find any so wrote my own!


sswift(Posted 2005) [#10]
"Sswift, how do your text functions handle variable width fonts (e.g. the width between 'i' and 'W')? And also can you adjust the kerning?"

Each letter must be in a square of a fixed size in the texture, and the the program scans the image to determine the actual width of each letter when you load the font.

And yes, you can adjust the kerning.


"I bought sswift's system but found the text blurs out a bit. This is because the text is rendered as a texture so you don't get perfect pixel to pixel mapping."


What he means here is that in my GUI lib the text will be the same size in any screen resolution.

Only if you use a system where the text will be smaller in higer resolutions can you get perfect pixel to pixel matching. And only perfect pixel to pixel will be perfectly sharp.

The size of the text you use obviously makes a difference too whether it is sharp enough for your needs. A very tiny font might not look good in a low resolution.

But if what you want is your GUI to look exactly the same in all resoltions as they do in many games, then the way my GUI system works is right for you.


"Also, with the increasing number of widescreen TFT's on display, how well would the scaling work on non-standard aspect ratios?"

Well, when you use a resolution like 1280x1024, the pixels are not square. My GUI system has a function you call to correct for this change in pixel aspect ratio. As far as I know, it should work fine with any resolution, BUT, a display designed to be viewed on a 640x480 screen is not going to be able to be viewed properly on a wide screen anyway. Either the graphics would have to be stuck in the middle of the screen to keep the same layout, or they would be stretched wider than normal to keep the same layout. As far as I know, my system would stretch them as you might expect it to. I'm sure you could adjust this so it crops the top and bottom instead, and then have a different position for each GUI element based on whether you have a widescreen view or not.


Ezbe(Posted 2005) [#11]
SpriteControl has a Text3D -function, which basically makes a texture and writes the text to it. This texture is then applied to a mesh, which is positioned so that the texture can be seen pixel-perfect on any resolution (of course the size of the text gets smaller the bigger resolution you use).


Caff(Posted 2005) [#12]
Only if you use a system where the text will be smaller in higer resolutions can you get perfect pixel to pixel matching. And only perfect pixel to pixel will be perfectly sharp.


Yes I totally understand this. It makes sense to have multiple bitmap fonts to cater for certain scales of resolution. I don't see how else you can get around this.

As regards to my widescreen query, I was talking not just of 5:4 and 4:3 but also of 1920x1200 screens and other such strange shapes.


Shifty Geezer(Posted 2005) [#13]
"I bought sswift's system but found the text blurs out a bit. This is because the text is rendered as a texture so you don't get perfect pixel to pixel mapping."


What he means here is that in my GUI lib the text will be the same size in any screen resolution.

Only if you use a system where the text will be smaller in higer resolutions can you get perfect pixel to pixel matching. And only perfect pixel to pixel will be perfectly sharp.

No, what I mean it's 'blurred' ;).

As you say, small fonts aren't sharp. This is because 3D textures aren't rendered pixel to pixel with the screen, even if of the same resolution. You can't get perfectly clear 10pt text, especially in some fonts, by writing to a texture and displaying this on a 3D sprite/plane. It's a limitation of using textures to display text.

I did a lot of testing in Blitz3D with a texture mapped plane, white pixels on black background, and never could I get it to display as that in 3D. There were greyscale pixels, a sort of fuzziness around the edges (antialiasing even!), and slight moire interference patterns, caused by interpolating texels for pixels. eg. Create a 128 pixel square chequered bitmap of alternating black and white pixels, map it to a square mesh, and display it at 128x128 pixels on screen. You won't get the same pixel clarity as the original.

So it's a tradeoff between 3D performance and pixel clarity. For what most games want, where the text will be fairly large, your system works fine. Even some small text looks okay. But if you want pixel perfect clarity only a 2D system works. I don't think it's at all possible on any 3D hardware to get perfect pixel clarity when drawing in 3D.

As a point of note I've just realised, does the sswift system use a powers of 2 interface texture (such as 512x256 or 1024x1024)? If I remember right the texture you draw to is set to 800x600. Graphics cards work ideally on powers of 2 textures. I found this out with some crazy artefacts when scaling a background bitmap that disappeared when I scaled it to 256x256. You might get better quality from the sswift system if you change the interface resolution to 1024x1024 and only show part of it.


sswift(Posted 2005) [#14]
"No, what I mean it's 'blurred' ;)."

It's not any blurrier than text which stays the same size in any resolution in any other GUI system will be though. So it's not something that should be unexpected.

Only GUI systems with fonts that are smaller at higher res can be sharper. Unless you want to make hundreds of differnt bitmap fonts for every possible resolution. :-)


"You can't get perfectly clear 10pt text, especially in some fonts, by writing to a texture and displaying this on a 3D sprite/plane. It's a limitation of using textures to display text.

I did a lot of testing in Blitz3D with a texture mapped plane, white pixels on black background, and never could I get it to display as that in 3D."


Just because you failed to do it doesn't mean it is not possible. It most certainly is possible. There are many 3D GUI's which use this method, and the code archives has code for displaying stuff pixel perfect with a texture.

But the limitation of that is that the text will be smaller in higher resolutions.

It's hard to get it to match up. You have to do it just right. But it can be done.

"Create a 128 pixel square chequered bitmap of alternating black and white pixels, map it to a square mesh, and display it at 128x128 pixels on screen. You won't get the same pixel clarity as the original."

You will if you align it properly with the pixels. You need to get the top left corner of the texture in the CENTER of the top left pixel. The corners of all the texels must be aligned to the pixel centers. And if you have an old card they sometimes screw with this, which is why Mark had that Blitzmax test a week or so ago to see if he could fix that problem.


Mustang(Posted 2005) [#15]
I use (heavilu) modified "pixel-perfect" Bitmap-GUI system made by Chroma for my game startup menu together with Sswifts GUI-stuff for game HUD info (graphical and text). Sprite Candy ( http://www.x-pressive.com/SpriteCandy/ ) looks neat too, but I already have what I need I think.


Shifty Geezer(Posted 2005) [#16]
Hmmm, maybe I wasn't doing things right? But certainly when I ran the sswift demos, there wasn't pixel-perfect imagery. I tired using a small font with it's display, Comic Sans, and it was at small size 'blurred' quite heavily.

I havent the sswift system installed at the moment, but i might fire it up again. If it DOES do pixel-perfect 3D I'll be all over it!


sswift(Posted 2005) [#17]
My GUI system isn't pixel perfect. It keeps the font the same size regardless of resolution, which is what many games do.

Some games use pixel perfect fonts. You should in theory be able to get those out of my system if you change a few minor things, or maybe just set the font size right. I'm not sure. It's not really that hard to get pixel perfect fonts, and the system was based on a pixel perfect setup when I started it so the camera and objects should be set up right to handle it if the scale is set to be smaller in higher resolutions and such. But I wouldn't support this sort of endeavor much.

If I was gonna try it, I would first try getting 640x480 working. Then from there once I got that working adjust the scale of the entity that contains the text mesh. Positioning the entity half a pixel to top left might align the texel centers properly on the left side, and scaling the entity might align the right and bottom sides and everyhting in the middle.

My system though is not designed for games heavy on text. It is designed for games with some text where you want the interface to look the same in all resolutions.