My Version Of Number WIzard!

public class NumberWizard : MonoBehaviour
{
int max = 1000;
int min = 1;
int guess = 500;

// Start is called before the first frame update
void Start()
{
    Debug.Log("Namaste!...Welcome to the number wizard.");
    Debug.Log("I am gonna guess the number you are thinking of....Be Ready!!!");
    Debug.Log("Please pick a number , Psst...dont tell me the number ;/");
    Debug.Log("The highest number you can pick is: " + max);
    Debug.Log("The lowest number you can pick is: " + min);
    Debug.Log("So, Tell me if your number is higher or lower than " + guess);
    Debug.Log("If its higher then push UpArrow key");
    Debug.Log("If its lower then push DownArrow key");
    Debug.Log("If the number i guessed is correct then press enter");
    max = max = 1;
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        min = guess;
        guess = (max +  min) / 2;
        Debug.Log(guess);
        Debug.Log("If the number i guessed is correct press enter");
        Debug.Log("If its higher then push UpArrow key");
        Debug.Log("If its lower then push DownArrow key");
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        max = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);
        Debug.Log("If the number i guessed is correct press enter");
        Debug.Log("If its higher then push UpArrow key");
        Debug.Log("If its lower then push DownArrow key");
    }
    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("Thank Your For Playing Number Wizard :)");
    }
}

}

1 Like

Awesome job! :smiley:

Privacy & Terms