Exemplo n.º 1
0
        /// <summary>
        /// Tick event controller
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            // Calculate game state
            GameState state = game.Logic();

            // Update score after logic
            label2.Text = "Score: " + game.Score;
            // Update current frame
            UpdateFrame();
            // Verify game state
            if (state != GameState.Running)
            {
                if (state == GameState.Won)
                {
                    label1.Text = "";
                    label2.Text = "You won this level, get ready for the next one!";
                    if (++game.Level == 6)
                    {
                        label1.Text = "";
                        label2.Text = "You finished the game!";
                    }
                }
                else
                {
                    label2.Text = "You've lost the game. Try again!";
                    label1.Text = "";
                    game.Level  = 1;
                }
                pictureBox1.Image = null;
                timer1.Stop();
                button1.Visible = true;
                button1.Enabled = true;
            }
        }