albert albert

albert albert

  • NA
  • 524
  • 0

Removing image when hit

Apr 10 2011 9:43 AM
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.


Answers (4)