#173359 - kavka1983 - Fri Apr 02, 2010 5:51 pm
Hi,
I'm trying to make a healthy meter bar using sprite, whenever the enemy ship hits it will narrow down, how to do this?
#173361 - Miked0801 - Fri Apr 02, 2010 7:09 pm
So many ways. Here's a subset of normal or more exotic ways:
You could:
1. Have 1 frame of animation per pixel of the sprite bar and show the frame the most closely matches the amount of health remaining.
2. Scale a sprite in the X direction if its uniform color or you don't mind the picture on it stretching.
3. Create a 9 frame sprite going from a blank 8xN rectangle to full and display that multiple times
4. Setup the bar in multiple palette ramps and change the palette over time to make the bar disappear (palette animation)
5. Make sure the background behind the bar is a uniform color and place 2 sprites - 1 being the HUD bar, the other on top of it and slide it back to reveal the bar (or hide it).
6. Use the hardware windowing registers to obscure sprites in that region of the screen to control visibility.
7. Align the bar vertically and use HBlank interrupts to turn the sprite on and off (or move it) depending on the scanline. Reset in VBlank.
8. Create a sprite with multiple frames and have each frame change in 8 pixels in the X. Have a second sprite under it that is an 8x8 sprite. Slide the smaller sprite under the larger for animation.
9. Forego sprites completely and update the BG instead with most of the above methods. With scroll registers and windowing, you can do a lot of tricks with BGs.
You get the idea. I would strongly suggest looking at other people's code for in-game solutions to this very common task.
#173364 - kavka1983 - Fri Apr 02, 2010 7:42 pm
thanks for your reply. it's realy enlightening, way 2 is just what I wanted, could you tell me more about that?
#173366 - Miked0801 - Fri Apr 02, 2010 9:12 pm
Not in a way that you could use. I'll let others chime in on this.
#173368 - gauauu - Fri Apr 02, 2010 9:25 pm
It sounds like your question is specifically how you'd go about stretching a sprite?
Have you read Tonc on the subject? Read the following 2 pages and then let us know whether you understand (great!), have a few specific questions (great!) or don't understand at all (uh oh), so we know where to start helping.
http://www.coranac.com/tonc/text/affine.htm
http://www.coranac.com/tonc/text/affobj.htm