energy bar : drawrect alternative

BlitzMax Forums/BlitzMax Beginners Area/energy bar : drawrect alternative

hub(Posted 2007) [#1]
Hi !
At this time i use drawrect into my game to draw the 'energy' bar used by the player space ship beam :



Is there another method to not use drawrect (slow) for this energy bar ? (when the player shoot the beam energy bar decrease by one pixel)

Thanks for your ideas !


tonyg(Posted 2007) [#2]
A rect image with setscale?
<edit>
Setviewport?
<edit2>
drawimagerect?


GfK(Posted 2007) [#3]
I draw 'progress' bars with three images. One stretched horizontally for the center part, then a rounded image at either end.


Grey Alien(Posted 2007) [#4]
Is draw rect slow then? I'd have thought it was very fast.

Yeah basically make an image which is your bar and only draw a portion of it.

Don't use setviewport because it's unreliable on some PCs.

You've got my framework haven't you? Use ccDrawImageArea instead.


JazzieB(Posted 2007) [#5]
I do what Gfk does. Three images, although you could just do it with one if you don't want rounded ends. Just make use of the normal DrawImage and SetScale commands.


hub(Posted 2007) [#6]
Yeah basically make an image which is your bar and only draw a portion of it.

i did this with blitzplus. With bmax your ccDrawImageArea could be a solution (for 'graphics' bars as colors gradient). Hope it's work on all the PC. (before this my first attemps with setviewport was awfull !!!). Is it really fast ?

I draw 'progress' bars with three images

i hope that setscale is not a 'too slow' command ! it's a good idea too !

Thanks for your ideas !


GfK(Posted 2007) [#7]
SetScale is fast. You'll use it a lot.


Grey Alien(Posted 2007) [#8]
Yeah I use setscale all the time for like hundreds of spinning particles.