gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Graphic overlay

#165680 - iainprice - Sat Jan 03, 2009 2:37 pm

I want a power bar to be drawn over a screen, but it is not a solid block of colour, any ideas of how to mask or draw only sections of a screen?

#165681 - dovoto - Sat Jan 03, 2009 2:43 pm

There are several options:

Any paletted graphic (background, sprite) will not render any pixels with a palette ID of 0.

16 bit bmp backgrounds and sprites have an alpha bit which can cause pixels not to be rendered.

Windows can be used to cause rectangular sections of the screen to be unaffected by certain operations (drawing of backgrounds and such).

The 3D engine has alpha blending so you could overlay a quad.

Any of these methods could be used for an overlay and probably a few more that havnt come to mind.

The most common is to either use a sprite or a background layer for your overlay graphic.
_________________
www.drunkencoders.com

#165683 - iainprice - Sat Jan 03, 2009 4:27 pm

i want to be able to display it in little bits so only show a hundreth of a shaped block each time.....

#165684 - dovoto - Sat Jan 03, 2009 4:33 pm

iainprice wrote:
i want to be able to display it in little bits so only show a hundreth of a shaped block each time.....


Sorry, not sure what that means.
_________________
www.drunkencoders.com

#165687 - iainprice - Sat Jan 03, 2009 8:39 pm

If I use

http://www.freewebs.com/ravenware/halods.JPG

then the power bar at the top is not a rectangle, it is shaped. I want to be able to fill 1% or 52% or 100% of the bar.

I could create another image of full power to put over the empty background but I am not sure how to copy a chunk of an image over the top....

dmaCopy(powerBitmap, BG_GFX, 256*?);

would copy ? far down a screen but I want to copy just a small chunk.....

#165767 - JonH - Tue Jan 06, 2009 11:35 am

I was thinking about this situation the other day...

Maybe 1 solution could be to have your main graphics in a background layer (with an empty, transparent area for where the power bar should go). Then underneath that have either a bg or sprite layer that contains the graphics for the filled power bar. You'd then only be worrying about dealing with a rectangle then.

Must be loads of ways to achieve this effect on the DS.

#165777 - DiscoStew - Tue Jan 06, 2009 5:18 pm

These are two of my ideas using JonH's hole-in-the-BG idea.

Have a BG underneath that's constructed with 1-pixel vertical strips, and assign a 256 color palette to it, so each strip has one palette color (actually less that 256 colors with your screen design). Then just edit the palette depending on the health level from the end to the start of the palette entries.

Or, there is also just making a whole BG (or what parts are needed) a single color, and as an affine BG (not text because of wrap-around), just change it's horizontal positioning. Be sure that the back-plane color is set to the color you want.
_________________
DS - It's all about DiscoStew

#165778 - JonH - Tue Jan 06, 2009 5:50 pm

DiscoStew wrote:

Or, there is also just making a whole BG (or what parts are needed) a single color, and as an affine BG (not text because of wrap-around), just change it's horizontal positioning. Be sure that the back-plane color is set to the color you want.


Yeah, this is essentially what I was thinking of doing for a position slider bar on a media player type screen :)

#165862 - iainprice - Fri Jan 09, 2009 11:15 pm

Like the idea but really having problems putting it into practice....

anyone got some time for some snippets?

I can make 2 BGs, one with palette 0 colour for the window, one a solid colour

I can display one but how do you write to another graphic layer with a lower priority so its behind?

#165866 - DiscoStew - Sat Jan 10, 2009 3:52 am

Check the 2D graphic example called "BackgroundAllInOne". It has a simple example of using multiple backgrounds with priorities under the "advanced.cpp" file.
_________________
DS - It's all about DiscoStew

#165882 - iainprice - Sun Jan 11, 2009 11:00 am

Oh poo. Needed to update to 1.4.9 from 7 to get new example etc.... lots of other things changed and caused lots of background, sin, cos problems...hmmmmmm

#165887 - ritz - Sun Jan 11, 2009 3:53 pm

Looks like you did the upgrade to the new devkitARM release 24... which is good. You'll have to make just a few changes to your code to get back up to speed and, in my opinion, it is worth it. The libnds examples were upgraded to support the new release. Here's my post of the things I had to do to upgrade: http://forum.gbadev.org/viewtopic.php?p=165221#165221

#165892 - iainprice - Sun Jan 11, 2009 7:09 pm

I'm still having problems with EFS...... :(

#165895 - ritz - Sun Jan 11, 2009 9:20 pm

What are the problems you're having? I had this issue when I upgraded.

#165904 - iainprice - Mon Jan 12, 2009 7:23 pm

Having problems finding/opening the file.....

#165906 - Miked0801 - Mon Jan 12, 2009 7:41 pm

I've usually done power bars as multi frame sprites. Each frame as 1 more pixel filled/removed that the last from full to empty. Then just due some div/mod ratio math to convert from your number system to the number of frames you have to work with.

#165910 - ritz - Mon Jan 12, 2009 9:07 pm

iainprice wrote:
Having problems finding/opening the file.....

If by "finding/opening the file" you mean the actual .nds file seems not to be found by EFS and not starting, then that's what happened to me (see my previous post). If you mean individual files within your .nds via EFS, then I don't think I can help :P

#166035 - iainprice - Sat Jan 17, 2009 7:28 pm

EFS sorted.... double layer graphics ok... power bar working now :) thanks.

My last problem is the new sound functions don't seem to let my tune get to the end before looping, it loops part way through......