My Number wizard code

Hey first off, your guys are awesome and the content in your videos is both informative and super interesting. Keep up the great work, and I look forward to learning more from you guys.
Now my code…

    Debug.Log("PLease select a number, between" + max + " and " + min);
    Debug.Log("Was your number higher or lower?");
    Debug.Log("Up arrow = higher, Down arrow = lower and Enter = correct guess.");
    max = max + 1;

}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("Up arrow has been pressed, you have guessed higher.");
        min = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);
    }
    // a trial commnet
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("Down arrow has been pressed, you have selected lower.");
        max = guess;
        guess = (min + max) / 2;
        Debug.Log(guess);

    }
    else if(Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
    {
        Debug.Log("You have pressed enter, the guess was correct.");
    }

Privacy & Terms