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.

Coding > Draw part of a sprite

#91069 - jee - Tue Jul 04, 2006 11:40 am

I'm trying to make some sort of health bar that needs to be precise to the pixel.
I'm using sprites to do this. I was wondering if theres a way to draw only part of a sprite?

#91102 - DrkMatter_ - Tue Jul 04, 2006 4:39 pm

I think you're looking for the object window.

http://user.chem.tue.nl/jakvijn/tonc/gfx.htm#sec-win

#91111 - tepples - Tue Jul 04, 2006 5:36 pm

Many games for 8- and 16-bit platforms had nine pre-rendered sprite tiles for 0, 1, 2, 3, 4, 5, 6, 7, and 8 pixels full. I know at least Tetяis (by Tengen) had all 8 for its tetromino frequency display, and the Mega Man series used states 0, 2, 4, 6, and 8. Games would either load all nine tiles into sprite VRAM and then use OAM to select one, or they would load empty, full, and middle cels and overwrite the middle tile with partially full tile data as needed.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#91126 - MrD - Tue Jul 04, 2006 6:58 pm

If the bar is a solid coloured rectangle, then consider using an affine sprite for it.
_________________
Not active on this forum. For Lemmings DS help see its website.

#91129 - tepples - Tue Jul 04, 2006 7:17 pm

Or consider sliding a "full" tile slowly to one side as the energy bar depletes.

The best method depends on how you want the bar to appear. Screenshops please.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#91553 - Palamon - Fri Jul 07, 2006 9:56 pm

Any ideas on how to do a Pictorial health bar like the one in Primal Rage.

[Images not permitted - Click here to view it]


I was thinking of loading the entire bar into the sprite/bg tiles and just have a function redraw the correct sprite to the correct fill level as the health changes.

#91566 - tepples - Fri Jul 07, 2006 11:12 pm

Palamon wrote:
I was thinking of loading the entire bar into the sprite/bg tiles and just have a function redraw the correct sprite to the correct fill level as the health changes.

That's pretty much the idea.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.