Numboo Wizzy

public class NumberWizard : MonoBehaviour
{
    int min = 1;
    int max = 1000;
    int guess = 500;
    
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Welcome to number wizard, my man.");
        Debug.Log("Pick a number between " + min + "-" + max + ", don't tell me what it is...");
        Debug.Log("Push Up = tell wizard to guess higher| Push Down = tell wizard to guess lower | Push Enter = tell wizard they guessed correctly!");
        Debug.Log("my first guess is " + guess + "!");
        max = max + 1;
    }

    // Update is called once per frame
    void Update()
    {
        // Detect when the up arrow key is pressed down
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            min = guess;
            guess = (max + min) / 2;
            Debug.Log("I'll guess higher, how about " + guess + "?");
        }
        // Detect when the down arrow key is pressed
        else if (Input.GetKeyDown(KeyCode.DownArrow)) 
        {
            max = guess;
            guess = (max + min) / 2;
            Debug.Log("I'll guess lower, how about " + guess + "?");
        }
        // Detect when the return key is pressed down
        else if(Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("I guessed the correct number, idiot!");
        }
    }
}

Privacy & Terms