Wizardzard

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("Knock knock!");
    Debug.Log("Who's here? A number!");
    Debug.Log("Which number?? Well you tell me!");
    Debug.Log("Highest: " + max);
    Debug.Log("Lowest: " + min);
    Debug.Log("Tell me if your number is higher or lower than 500");
    Debug.Log("Up = Higher, Down = Lower, Enter = Correct Number");
    max = max + 1;
        

}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("hm?");
        min = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);

    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("hmm?");
        max = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);
    }
    else if (Input.GetKeyDown(KeyCode.Return))
    {    
        Debug.Log("AHA!");   
    }
}

}

1 Like

Great! Sounds like good knock-knock joke! :smiley:
You can even write some funny end when player click Enter!
Also I courage all to put guess when player click Enter, so he can actually see
the number. Even if it’s not his own number, it would be still interesting I think! :slight_smile:

Privacy & Terms