HI Everyone,
I want to remove image when it is hit.
I have 2 methods:
[code]
public void DrawLive(Graphics g)
{
for (int i = 0; i <= GameConstants.gameLives; i++)
{
Bitmap image = Properties.Resources.paxship_02;
Font drawFont = new Font("Arial", 14);
int scaledWidth = image.Width / 2;
int scaledHeight = image.Height / 2;
g.DrawImage(image, 1100 /*boundaries.Right - scaledWidth*/, 30f, scaledWidth, scaledHeight);
g.DrawImage(image, 1150 /*boundaries.Right - scaledWidth*/, 30f, scaledWidth, scaledHeight);
g.DrawImage(image, 1200 /*boundaries.Right - scaledWidth*/, 30f, scaledWidth, scaledHeight);
string livesString = lives.ToString() + " x ";
SizeF stringWidth = g.MeasureString(livesString, drawFont);
g.DrawString(livesString, drawFont, Brushes.Red, /*boundaries.Right - scaledWidth - stringWidth.Width*/1200, 5f); //top left
}
//g.DrawImage(image, 1100, 30);
// }
}
private bool UpdateLive()
{
bool LivesLeftNo = false;
//playerShip.Alive = false;
//Form1.Fm1.lbUpdateScore.Text = lives.ToString();
//lives = lives - 1;
//lives= GameConstants.gameLives - 1;
//DrawLive--;
if (lives == 0)
{
//GameOver(this, null);
//GameOverTime = DateTime.Now;
LivesLeftNo = true;
}
return LivesLeftNo;
}
[/code]
and this is the hole project.
THX.
Loading
FroglegPosted Apr 11, 2011, 4:36 PM
CrishPosted Apr 11, 2011, 8:29 AM
albert albertPosted Apr 10, 2011, 5:54 PM
[code]
public void DrawLive(Graphics g)
{
for (int i = 0; i <= GameConstants.gameLives; i++)
{
Bitmap image = Properties.Resources.paxship_02;
Font drawFont = new Font("Arial", 14);
int scaledWidth = image.Width / 2;
int scaledHeight = image.Height / 2;
g.DrawImage(image, 1100 /*boundaries.Right - scaledWidth*/, 30f, scaledWidth, scaledHeight);
//Form1.Fm1.picExplode.Location = image; // add to score and show explosion
//Form1.Fm1.picExplode.Visible = false; // add to score and show explosion
//Form1.Fm1.explosionTimer.Start();
g.DrawImage(image, 1150 /*boundaries.Right - scaledWidth*/, 30f, scaledWidth, scaledHeight);
g.DrawImage(image, 1200 /*boundaries.Right - scaledWidth*/, 30f, scaledWidth, scaledHeight);
string livesString = lives.ToString() + " x ";
SizeF stringWidth = g.MeasureString(livesString, drawFont);
g.DrawString(livesString, drawFont, Brushes.Red, /*boundaries.Right - scaledWidth - stringWidth.Width*/1050, 5f); //top left
}
//g.DrawImage(image, 1100, 30);
// }
}
[/code]
I have this. U can see it in the project upper corner right - thee little ships. But if 1 one dies it have to remove . I mean 1 of the lives have to remove.
FroglegPosted Apr 10, 2011, 5:21 PM