howdy, i looked and looked but could not find a post that would help me with making an HP Bar Sprite thingamajig.
I have created a simple full-green sprite bar. I deduct an oriented float variable called "damage". Damage is any amount and is then subtracted from 100. I have used dbStretchSprite () where dbStretchSprite ( 10, 100 - (damage++), 100 ); 100 is the regular size of the sprite of X and Y.
void HUD()
{
dbCreateAnimatedSprite ( 10, "hpgreen.png", 1, 1, 10 );
dbPlaySprite ( 10, 1, 1, 0 );
dbSprite ( 10, HPx, HPy, 10 );
if ( CheckSpace() )//damage == 1
{
damage = 0.5;
dbStretchSprite ( 10, 100 - (damage++), 100 );
//Y = 100 and is normal size, 0-200
//dbPasteSprite ( 10, HPx--, 0 );
}
//dbSprite ( 10, HPx, HPy, 11 );
}
CheckSpace() is supposed to represent a boolean check whether or not any damage was dealt. I will change the function later when i have created a running damage class.
My main problem is it will only perform the block of code once, and only calculate the X length shrinking operations once. So the green bar only shrinks by that amount of code once even when i press the space bar multiple times, or even hold it. Which brings me to another problem:
My checkSpace() function is of bool type and it is supposed to check to see if the space bar has been pressed without holding it. Take like a pseudocode where dbKeyOld or something like that... Say if I tapped the A button on a game controller it may shoot a bullet once for every click. (I know this is extensive but im just trying to explain myself)
bool CheckSpace ( void )
{
if ( dbSpaceKey( ) == true )
return true;
return false;
}
That is an example of the shooting function i got from DGDK Dark Invaders.
So y'all, thank you so much.
Don't Clap, Just Throw Money!