Ejemplo n.º 1
0
        private void TmrOx_Tick(object sender, EventArgs e)

        {
            int timeLeft = int.Parse(lblOx.Text); //getting the last value (the one from the label)

            timeLeft  -= 1;                       //subtracting 1
            lblOx.Text = timeLeft.ToString();     //adding it back to the label.

            lblOx.ForeColor     = Color.White;
            TxtLives.ForeColor  = Color.White;
            LblScore1.ForeColor = Color.White;
            lblOx.ForeColor     = Color.White;
            player = Image.FromFile("player.png");

            if (int.Parse(lblOx.Text) == 5)
            {
                lblOx.ForeColor = Color.Red;
            }
            if (int.Parse(lblOx.Text) == 4)
            {
                lblOx.ForeColor = Color.Red;
            }
            if (int.Parse(lblOx.Text) == 3)
            {
                lblOx.ForeColor = Color.Red;
            }
            if (int.Parse(lblOx.Text) == 2)
            {
                lblOx.ForeColor = Color.Red;
            }
            if (int.Parse(lblOx.Text) == 1)
            {
                lblOx.ForeColor = Color.Red;
            }
            if (int.Parse(lblOx.Text) == 0)  //if the countdown reaches '0', we stop it
            {
                TmrOx.Stop();
                TmrPlanet.Enabled = false;
                TmrShip.Enabled   = false;
                MessageBox.Show("Game Over \n \n Body of Astronaut #237 found in the emptiness of space. \n Cause of death: Suffocation. ");
            }
        }
Ejemplo n.º 2
0
 private void MnuStart_Click(object sender, EventArgs e)
 {
     score             = 0;                //when game starts set the score to 0
     LblScore1.Text    = score.ToString(); //display the score on the form
     TmrPlanet.Enabled = true;             //start the timer to move the planets
     TmrShip.Enabled   = true;             //start the timer to move the spaceship
     TmrAnim.Enabled   = true;             //start the timer to animate the planets
     lblOx.Text        = "10";             //start from 10 seconds
     TmrOx.Start();
     title.Visible      = false;           //hide title card when play is clicked
     title.Visible      = false;           //hide title card when play is clicked
     pressplay.Visible  = false;           //hide title card when play is clicked
     titlesmall.Visible = true;            //show small title card when play is clicked
     heart.Visible      = true;
     TxtLives.Visible   = true;
     LblScore1.Visible  = true;
     label4.Visible     = true;
     circle.Visible     = true;
     lblOx.Visible      = true;
     label2.Visible     = true;
 }
Ejemplo n.º 3
0
 private void MnuStop_Click(object sender, EventArgs e)
 {
     TmrShip.Enabled   = false;
     TmrPlanet.Enabled = false;
     TmrOx.Stop();
 }