// Update is called once per frame
    void Update()
    {
        if (theBall == null)
        {
            //hint: if your game UI never displays, you might want to check this condition somehow...
            return;
        }

        switch (theGameState)
        {
        case GameStates.GS_INITIALIZATION:
            Restart();                          //needed to avoid a race condition with the ball's Start() function
            break;

        case GameStates.GS_USER_INPUT:

            //increase or decrease the launch velocity at a rate of 2 meters per second
            if (Input.GetKey(KeyCode.UpArrow))
            {
                //Time.deltaTime tells me how much time has passed in seconds since the last frame.
                theBall.launchSpeed = Mathf.Min(MAX_LAUNCH_VEL, theBall.launchSpeed + 2.0f * Time.deltaTime);
            }
            if (Input.GetKey(KeyCode.DownArrow))
            {
                theBall.launchSpeed = Mathf.Max(0.0f, theBall.launchSpeed - 2.0f * Time.deltaTime);
            }

            //increase or decreate the cannon's angle by a rate of 10 degrees per second
            if (Input.GetKey(KeyCode.LeftArrow))
            {
                theCannon.localPivotAngle = Mathf.Min(90.0f, theCannon.localPivotAngle + 10.0f * Time.deltaTime);
            }
            if (Input.GetKey(KeyCode.RightArrow))
            {
                theCannon.localPivotAngle = Mathf.Max(0.0f, theCannon.localPivotAngle - 10.0f * Time.deltaTime);
            }

            //check for game start and spawn the ball
            if (Input.GetKeyDown(KeyCode.Space))
            {
                theCannon.SpawnBall();
                theGameState = GameStates.GS_GAME_IN_PROGRESS;
            }
            break;

        case GameStates.GS_GAME_IN_PROGRESS:
            break;

        case GameStates.GS_ENDGAME_VICTORY:

            //check for new game
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Restart();
            }
            break;

        case GameStates.GS_ENDGAME_DEFEAT:

            //check for new game
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Restart();
            }
            break;
        }
    }