#58566 - thegamefreak0134 - Mon Oct 24, 2005 5:07 pm
How do you do the (yes cheap, but useful) fading effect of images commonly used at the start of games for logos and such? It seems simple, but I get the feeling it's either a piece of the programming puzzle I don't have (ate it accidentaly in my cereal) or it's something you learn w/ expirience.
It seems like there should be an easy way to alpha blend your image with a black image to produce the effect. However, I do not know the math required to do this. Is there a simple way?
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#58579 - strager - Mon Oct 24, 2005 6:28 pm
thegamefreak0134 wrote: |
It seems like there should be an easy way to alpha blend your image with a black image to produce the effect. However, I do not know the math required to do this. Is there a simple way? |
Palette fading.
#58580 - Fatnickc - Mon Oct 24, 2005 6:33 pm
Search.
Loads of people have asked before, and the answers are there to be found.
#58581 - DekuTree64 - Mon Oct 24, 2005 6:37 pm
Or the blend register.
Palette fading is harder to do, and takes a lot more CPU time. It's good for when you're already using the blend register for alpha blending, or if you only want to fade one thing like to make a sprite flash.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku
#58582 - Cearn - Mon Oct 24, 2005 6:43 pm
The easiest way would be to use the hardware fading registers. Blend mode 3 (well, 3<<6) would fade to black.
If you're already using the fading registers for something else, you'll have to use palette fading. Ther are many ways to do this, but the easiest would be to do a linear interpolation (you know lines? y= a*x+b) from the current color component values down to 0.
#58593 - thegamefreak0134 - Mon Oct 24, 2005 7:42 pm
OK, I've seen the whole (x<<y) thing, what does it mean and what does it do?
Am I correct in guessing that it stores the specified number to the specified bit? (and if so, which is which?)
Does this mean that I can simply write a while loop that changes the blending register so often every frame to produce the effect? If so, what are the max/min values of the register?
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#58596 - Cearn - Mon Oct 24, 2005 7:55 pm
thegamefreak0134 wrote: |
OK, I've seen the whole (x<<y) thing, what does it mean and what does it do? |
Bit-shift operators. Part of Bit operations, a class of the elementary set of C operators. Does anyone have a link to a "C for programmers" tutorial or something? I've seen other people have difficulty with some C-specific constructs as well.
thegamefreak0134 wrote: |
Does this mean that I can simply write a while loop that changes the blending register so often every frame to produce the effect? If so, what are the max/min values of the register? |
Something like that, yeah. Min/max values are at the links given earlier. (it's 17 btw. Well, 0 to 1 in 1.4 fixed point notation, that's 17 steps total). You'll have to divide by the number of steps you have. Or multiply with its reciprocal because division is slow on the GBA.