Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


#ActualServant of the Lord

Posted 27 March 2013 - 09:04 PM

Try something like:
if( hit )
{
    health -= 1;

    if( health <= 0)
    {
        dead = true;
    }
}
Later, when it's time to draw:
//First draw the "Life" text or image.
DrawText("Life:", x, y);
//...or...
DrawImage(LifeTextImage, x, y);

for(int heart = 0; heart < health; heart++)
{
    heartOffsetX = (heart * (heartWidth + spaceBetweenHearts));
    DrawImageOnScreen(HeartImage, (distanceFromLeftOfScreen + heartOffsetX), distanceFromTopOfScreen);
}
Re-use the heart image and just draw it multiple times and shift the image over each time.

#5Servant of the Lord

Posted 27 March 2013 - 09:02 PM

Try something like:
if( hit )
{
    health -= 1;

    if( health <= 0)
    {
        dead = true;
    }
}
Later, when it's time to draw:
//First draw the "Life" text or image.
DrawText("Life:", x, y);
//...or...
DrawImage(LifeTextImage, x, y);

for(int heart = 0; heart < health; heart++)
{
    x = distanceFromLeftOfScreen + (heart * (heartWidth + spaceBetweenHearts));
    y = distance from top of screen;
    
    DrawImageOnScreen(HeartImage, x, y);
}
Re-use the heart image and just draw it multiple times and shift the image over each time.

#4Servant of the Lord

Posted 27 March 2013 - 09:01 PM

Try something like:
if( hit )
{
    health -= 1;

    if( health <= 0)
    {
        dead = true;
    }
}
Later, when it's time to draw:
//First draw the "Life" text or image.
DrawText("Life:", x, y);
//...or...
DrawImage(LifeTextImage, x, y);

for(int heart = 0; heart < health; heart++)
{
    x = distanceFromLeftOfScreen + (heart * (heartWidth + spaceBetweenHearts));
    y = distance from top of screen;
    
    DrawImageOnScreen(HeartImage, x, y);
}
Re-use the heart image and just draw it multiple times and shift the image over each time.

#3Servant of the Lord

Posted 27 March 2013 - 09:00 PM

Try something like:
if( hit )
{
    health -= 1;

    if( health <= 0)
    {
        dead = true;
    }
}[/code

Later, when it's time to draw:
[code]
//First draw the "Life" text or image.
DrawText("Life:", x, y);
//...or...
DrawImage(LifeTextImage, x, y);

for(int heart = 0; heart < health; heart++)
{
    x = distanceFromLeftOfScreen + (heart * (heartWidth + spaceBetweenHearts));
    y = distance from top of screen;
    
    DrawImageOnScreen(HeartImage, x, y);
}

#2Servant of the Lord

Posted 27 March 2013 - 08:58 PM

Try something like:
if( hit )
{
    health -= 1;

    if( health <= 0)
    {
        dead = true;
    }
}

//...later, when it's time to draw...
for(int heart = 0; heart < health; heart++)
{
    x = distanceFromLeftOfScreen + (heart * (heartWidth + spaceBetweenHearts));
    y = distance from top of screen;
    
    DrawImageOnScreen(HeartImage, x, y);
}

#1Servant of the Lord

Posted 27 March 2013 - 08:57 PM

Try something like:
if( hit )
{
    health -= 1;

    if( health <= 0)
    {
        dead = true;
    }
}

//...later, when it's time to draw...
for(int heart = 0; heart < health; heart++)
{
    x = distanceFromLeftOfScreen + (heart * (heartWidth + spaceBetweenHearts));
    y = distance from top of screen;
    DrawImageOnScreen(HeartImage, x, y);
}

PARTNERS