Greetings From India

This is my code:-

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!!");
    Debug.Log("You have come to a place of great Magic. Here we read Mind and Soul.");
    Debug.Log("You don't believe!! You will.");
    Debug.Log("Choose a number in your mind but don't tell anyone even your soul.");
    Debug.Log("The highest number can be: " + max);
    Debug.Log("The lowest number can be: " + min);
    Debug.Log("Ommmm!! Your number is " + guess + ".");
    Debug.Log("Tell me if your number is " + guess + " or higher or lower than " + guess + ".");
    Debug.Log("Push Up Arrow for higher, push Down Arrow for lower, push Enter for correct.");
    max = max + 1;
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("I am wrong!! Don't worry, you can't resist me.");
        min = guess;
        guess = (max + min) / 2;
        Debug.Log("Ommmm!! Your number is " + guess + ".");
        Debug.Log("Tell me if your number is " + guess + " or higher or lower than " + guess + ".");
        Debug.Log("Push Up Arrow for higher, push Down Arrow for lower, push Enter for correct.");
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("I am wrong!! Don't worry, you can't resist me.");
        max = guess;
        guess = (max + min) / 2;
        Debug.Log("Ommmm!! Your number is " + guess + ".");
        Debug.Log("Tell me if your number is " + guess + " or higher or lower than " + guess + ".");
        Debug.Log("Push Up Arrow for higher, push Down Arrow for lower, push Enter for correct.");
    }
    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("Now that you have witnessed the Great Magic, bow before it or it will destroy you.");
    }
}

}

2 Likes

Hello how are you? Awesome job with your code!

1 Like

Thanks Bro!!

1 Like

Heyyy, that’s some nice and tidy looking code :slight_smile:

2 Likes

Thanks!! :star_struck: :star_struck:

1 Like

Privacy & Terms