title: C# Visual Studio 2013 Windows Form App Taking Score
body: <p>Hi having issue adding ( + 10) to my score variable and displaying it, the variable is ScoreNum and is suppose to + 10 when picBigAlien1 is no longer visible (i.e. picBigAlien1.Visible = false) this might be an error due to putting the code in the wrong place. I've been working on this for hours and iv'e used the same method to display scores before on other programs and have never had this issue. It's probably something really simple I just can't spot it. Any help appreciated. Thank you. (C)</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace Space_Invadors
  {
      public partial class frmSpace : Form
      {
          //List of all barrier picture boxes and alien picture boxes
          PictureBox[] barriers;
          PictureBox[] Aliens;
          PictureBox[] Aliens2;
          int ScoreNum = 0;
          bool direction = false;
          public frmSpace()
          {
              InitializeComponent();
              this.barriers = new PictureBox[20];
              this.barriers[0] = picBlock1Part1;
              this.barriers[1] = picBlock1Part2;
              this.barriers[2] = picBlock1Part3;
              this.barriers[3] = picBlock1Part4;
              this.barriers[4] = picBlock2Part1;
              this.barriers[5] = picBlock2Part2;
              this.barriers[6] = picBlock2Part3;
              this.barriers[7] = picBlock2Part4;
              this.barriers[8] = picBlock3Part1;
              this.barriers[9] = picBlock3Part2;
              this.barriers[10] = picBlock3Part3;
              this.barriers[11] = picBlock3Part4;
              this.barriers[12] = picBlock4Part1;
              this.barriers[13] = picBlock4Part2;
              this.barriers[14] = picBlock4Part3;
              this.barriers[15] = picBlock4Part4;
              this.barriers[16] = picBlock5Part1;
              this.barriers[17] = picBlock5Part2;
              this.barriers[18] = picBlock5Part3;
              this.barriers[19] = picBlock5Part4;
  
              this.Aliens = new PictureBox[8];
              this.Aliens[0] = picBigAlien1;
              this.Aliens[1] = picBigAlien2;
              this.Aliens[2] = picBigAlien3;
              this.Aliens[3] = picBigAlien4;
              this.Aliens[4] = picBigAlien5;
              this.Aliens[5] = picBigAlien6;
              this.Aliens[6] = picBigAlien7;
              this.Aliens[7] = picBigAlien8;
  
              this.Aliens2 = new PictureBox[8];
              this.Aliens2[0] = picBigAlien9;
              this.Aliens2[1] = picBigAlien10;
              this.Aliens2[2] = picBigAlien11;
              this.Aliens2[3] = picBigAlien12;
              this.Aliens2[4] = picBigAlien13;
              this.Aliens2[5] = picBigAlien14;
              this.Aliens2[6] = picBigAlien15;
              this.Aliens2[7] = picBigAlien16;
  
              if(picBigAlien1.Visible == false)
              {
                  ScoreNum = ScoreNum + 10;
              }
              else
              {
                  ScoreNum = ScoreNum + 0;
              }
  
              String ScoreNumD = ScoreNum.ToString();
              ScoreBox1.Text = ScoreNumD;
          }
  
          private bool CheckBulletCollision()
          {
              //Check if the players bullet collides with the barriers
              foreach (PictureBox barrier in this.barriers)
              {
                  if ((barrier != null) &amp;&amp; (barrier.Visible))
                  {
                      if (picLaser.Bounds.IntersectsWith(barrier.Bounds))
                      {
                          barrier.Visible = false;
                          picLaser.Visible = false;
                          return true;
                      }
                  }
              }
              foreach (PictureBox Alien in this.Aliens)
              {
                  if ((Alien != null) &amp;&amp; (Alien.Visible))
                  {
                      this.picLaser.Top -= 1;
                      Rectangle picLaserBounds = picLaser.Bounds;
  
                      picLaserBounds = new Rectangle(picLaserBounds.Left - panAliens.Left,
                          picLaserBounds.Top - panAliens.Top, picLaserBounds.Width, picLaserBounds.Height);
                      if (picLaserBounds.IntersectsWith(Alien.Bounds))
                      {
                          Alien.Visible = false;
                          picLaser.Visible = false;
                          return true;
                      }
                  }
              }
              foreach (PictureBox Alien in this.Aliens2)
              {
                  if ((Alien != null) &amp;&amp; (Alien.Visible))
                  {
                      this.picLaser.Top -= 1;
                      Rectangle picLaserBounds = picLaser.Bounds;
  
                      picLaserBounds = new Rectangle(picLaserBounds.Left - panAlien2.Left,
                          picLaserBounds.Top - panAlien2.Top, picLaserBounds.Width, picLaserBounds.Height);
                      if (picLaserBounds.IntersectsWith(Alien.Bounds))
                      {
                          Alien.Visible = false;
                          picLaser.Visible = false;
                          return true;
                      }
                  }
              }
              return false;
          }
  
          private void timUpdate_Tick(object sender, EventArgs e)
          {
              //Moves the aliens
              if (this.direction)
              {
                  panAliens.Left -= 1;
                  if (panAliens.Left &lt; 10)
                  {
                      panAliens.Left = 10;
                      this.direction = false;
                  }
              }
              else
              {
                  panAliens.Left += 1;
                  if (panAliens.Right &gt; this.Width - 10)
                  {
                      panAliens.Left = this.Width - 10 - panAliens.Width;
                      this.direction = true;
                  }
              }
              if (this.direction)
              {
                  panAlien2.Left -= 1;
                  if (panAlien2.Left &lt; 10)
                  {
                      panAlien2.Left = 10;
                      this.direction = false;
                  }
              }
              else
              {
                  panAlien2.Left += 1;
                  if (panAlien2.Right &gt; this.Width - 10)
                  {
                      panAlien2.Left = this.Width - 10 - panAlien2.Width;
                      this.direction = true;
                  }
              }
              //Moves the users bullet
              if (this.picLaser.Visible)
              {
  
                  this.picLaser.Top -= 3;
                  if (this.picLaser.Bottom &lt; 0)
                      this.picLaser.Visible = false;
                  else
                      this.CheckBulletCollision();
              }
          }
  
          private void timUpdateRow_Tick(object sender, EventArgs e)
          {
              //Moves the aliens towards the player
              panAliens.Top++;
              //Moves the aliens towards the player
              panAlien2.Top++;
          }
  
          protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
          {
              //Process the key presses off the user
              switch (keyData)
              {
                  //User moves left
                  case Keys.Left:
                  case Keys.A:
                      this.picPlayer.Left -= 5;
                      if (this.picPlayer.Left &lt; 10)
                          this.picPlayer.Left = 10;
                      return true;
                  //User moves right
                  case Keys.Right:
                  case Keys.D:
                      this.picPlayer.Left += 5;
                      if (this.picPlayer.Right &gt; this.Width - 10)
                          this.picPlayer.Left = this.Width - this.picPlayer.Width - 10;
                      return true;
                  //Allows the player to shoot
                  case Keys.Space:
                      if (!this.picLaser.Visible)
                      {
                          this.picLaser.Top = this.picPlayer.Top;
                          this.picLaser.Left = this.picPlayer.Left + (this.picPlayer.Width / 2);
                          this.picLaser.Visible = true;
                      }
                      return true;
              }
              return base.ProcessCmdKey(ref msg, keyData);
          }
  
          private void frmSpace_Load(object sender, EventArgs e)
          {
              this.WindowState = FormWindowState.Maximized;
          }
  
      }
  }
  </code></pre>
  
  <p>(C)</p>