FastImage HUD

Blitz3D Forums/Blitz3D Programming/FastImage HUD

GIB3D(Posted 2009) [#1]
How would you make a HUD using FastImage in a game that allows a changing resolution? Or should I just use regular sprites (I don't have SpriteCandy)


Rroff(Posted 2009) [#2]
Most games either use a virtual 640x480 grid and scale the coordinates, or use align to left, right, top, bottom, center + offset to position element so it doesn't matter what resolution.


Kryzon(Posted 2009) [#3]
I can vouch for the proportional method, it's really good.

The offset method on the other hand would need some proportional care too, or else the bigger the resolution, the closer the sprites would get to the edges of the screen.

For the proportional one, start a 640x480 application, position your sprites until they look how you want them, and remember their coordinates. You need to get a quick app to test their position on screen and so you can write down their coordinates.

Then simply position them in-game at...
SpriteX * (GraphicsWidth()/640.0) ;ofc you can switch 640x480 to whatever native resolution you set up your interface in.
SpriteY * (GraphicsHeight()/480.0)

;The ".0" is so the number is a float.
If I recall correctly.


GIB3D(Posted 2009) [#4]
Ok so you're saying I should use Sprites instead of FastImage?


Naughty Alien(Posted 2009) [#5]
..FastImage will be better choice...simply because you can use projection grid and later regardles resolution or monitor ratio, your HUD will look same, automatically adjusted, so all you need is fit your projection grid on to new resolution...so, no matter how many HUD elements you have, all of them will be adjusted just by controling one value related to projection grid...thats how I use to do things with fastImage when i was dealing with B3D..


GIB3D(Posted 2009) [#6]
What I don't know how to do with FastImage is change whats on the image. With a regular image or texture all I have to do is

SetBuffer ImageBuffer(Image)
Color 0,0,0
Rect 0,0,ImageWidth(Image),ImageHeight(Image)
SetBuffer BackBuffer()

SetBuffer TextureBuffer(Texture)
Color 0,0,0
Rect 0,0,TextureWidth(Texture),TextureHeight(Texture)
SetBuffer BackBuffer()


But it didn't seem to work with FastImage images using SetBuffer ImageBuffer(Image).


Bobysait(Posted 2009) [#7]
Use GetImageProperty to get the texture used in your "FI" image (FI mean Fast Image ^^)
Then You can get the buffer with
Buffer=TextureBuffer( FI_ImageProperty\texture )

GetImageProperty(img)
Texture=FI_ImageProperty\texture

SetBuffer TextureBuffer(Texture)
Color 0,0,0
Rect 0,0,TextureWidth(Texture),TextureHeight(Texture)
SetBuffer BackBuffer()


But take care with the texture size . As It's originally a Texture, it's a power of 2 size and FastImage use a viewport on the texture to draw only the part specified when creating the image.
So the "real" image size should be FI_ImageProperty\width and FI_ImageProperty\height


GIB3D(Posted 2009) [#8]
Thanks!


Kryzon(Posted 2009) [#9]

Ok so you're saying I should use Sprites instead of FastImage?


"Sprite" is just a way of naming that graphical element. You can use whatever you feel like.


Chroma(Posted 2009) [#10]
Use Rob's Fast Hud from the archives. It's awesome.


GIB3D(Posted 2009) [#11]
I've already got snippet code for doing quads like Rob's Fast HUD. When I was working on one of my other games I was using the quads for HUD but something about it is just screwy sometimes. Like, one time I was simply turning the camera and the texture on the quad would deform depending on the angle of the camera. I had to change a bunch of code to get it to stop.