Number wizard

// Start is called before the first frame update
void Start()
{
Debug.Log(“Welcome to number wizard, yo”);
Debug.Log(“Pick a number”);
Debug.Log("The highest number you can pick is " + max);
Debug.Log("The lowest number you can pick is " + min);
Debug.Log("Tell me if your number is higher or lower than " + guess);
Debug.Log(“Push Up = higher, Push Down = lower, Push Enter = Correct”);
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))
    {
        Debug.Log("Up Arrow key was pressed.");
        min = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);
    }

    //Detect when the down arrow key is pressed down
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("Down Arrow key was pressed.");
        max = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);
    }

    //Detect when the return key is pressed down
    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("Return key was pressed.");
    }
}

Privacy & Terms