Number Wizard Code

// Start is called before the first frame update
    void Start()
    {
        Debug.Log("Welcome to number wizard, the script that guesses YOUR NUMBER! Just so long as it's whole...");
        Debug.Log("Anyway, please pick a number....");
        Debug.Log("Oh and the highest number you can pick is: " + max);
        Debug.Log("The lowest is: " + min);
        Debug.Log(" Here are the instructions :Push the 'Up' arrow if your number is higher, \nPush 'Down' arrow if your number is lower, and Push 'Enter' key if my guess is correct.");
        Debug.Log("Ready? Press 's' to start");
        max = max + 1;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            Debug.Log("Alright, so is your number 500?");
            max = 1001;
            min = 1;
            guess = 500;
        }
        else if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            Debug.Log("You said your number was higher.");
            min = guess;
            guess = (max + min) / 2;
            Debug.Log("My Guess is" + guess);
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            Debug.Log("You saud your number was lower.");
            max = guess;
            guess = (max + min) / 2;
            Debug.Log("My guess is" + guess);
        }
        else if (Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("Return key was pressed.");
            Debug.Log("I GUESSED IT!");
        }
    }
}
1 Like