Exemplo n.º 1
0
        private void btnStartPause_Click(object sender, EventArgs e)
        //changes game state
        {
            width  = int.Parse(txtWidth.Text);
            height = int.Parse(txtHeight.Text);

            if (gameState == GameState.RUNNING)
            //if running, pause. change button text
            {
                timer.Stop();
                gameState          = GameState.PAUSED;
                btnStartPause.Text = "Start";
            }
            else
            {
                if (gameState == GameState.ENDED)
                //if not running. if ended, reset
                {
                    engine.Reset(width, height);
                }
                timer.Start();
                gameState          = GameState.RUNNING;
                btnStartPause.Text = "Pause";
                //^^^whether ended or not
            }
        }