Greetings from India

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 Number Wizard");
    Debug.Log("Pick a number from within the Limits");
    Debug.Log("Highest Limits is: " + max);
    Debug.Log("Lowest Limit is: " + min);
    Debug.Log("Is your Number higher or lower than " + guess + "?");
    Debug.Log("Press Up:Higher,Press down:Lower,Press Enter:Correct");
    max = max + 1;

}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("No!?");
        min = guess;
        guess = (max + min) / 2;
        Debug.Log("Is it " + guess + "?");
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("No!?");
        max = guess;
        guess = (max + min) / 2;
        Debug.Log("Is it " + guess + "?");
    }
    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("The Wizard has shown his Powers...Applauds please");
    }
}    

}

2 Likes

Welcome to the community!

Your code looks great!

1 Like

Privacy & Terms