albert albert

albert albert

  • NA
  • 524
  • 0

to keep up a score

Mar 27 2011 1:10 PM
Hi

I want to keep up a score in the game.

I have this:

[code]

  public int Score { get; private set; }

 public Invader(Type invaderType, Point location, int score)
  {
 
  //this.image = StarInvader2.Properties.Resources.bug1; 
  this.InvaderType = invaderType;
  this.Location = location; 
  this.Score = score;
  this.Score = GameConstants.BugScore;
  this.Score = GameConstants.SatelliteScore;
  this.Score = GameConstants.SaucerScore;
  this.Score = GameConstants.SpaceshipScore;
  this.Score = GameConstants.StarScore;
  //image =  InvaderImageBlock(0);
  //SetupImage();
  //InvaderImage();

 
  //this.image =  InvaderImageBlock[(int)invaderType][0];  //Object is null.
  this.image = InvaderImage(0);

 
 
  }//End constructor.
[/code]

And this are the constants:

[code]
 //Invader scores
  public const int BugScore = 25;
  public const int SaucerScore = 20;
  public const int SatelliteScore = 15;
  public const int SpaceshipScore = 10;
  public const int StarScore = 5;
[/code]

And I have this in the class Game:

[code]
public void gameScore(Graphics g)
  {

  Font drawfont = new Font("Arial", 16);
  g.DrawString(score.ToString(), drawfont, Brushes.White, 10f, 15f);
  }
[/code]

I see a white zere in the upper left corner. But If I shoot an invader out of the sky the counter doesn't count.

Thx for helping me.

Answers (21)