Howdy Y'all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

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("Hello y'all.  Welcome to number wizard");
        Debug.Log("Please pick a number");
        Debug.Log("The highest number available is: " + max);
        Debug.Log("The lowest number available is: " + min);
        Debug.Log("Please tell me if your number is higher or lower than 500");
        Debug.Log("To do this, push the up key if it is higher, the down key if it is lower, or the enter key if I have guessed correctly");
        max = max + 1;
        
    }

    // Update is called once per frame; put some things in void start and some things in void update
    void Update()
    {
        {
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                Debug.Log("Up Arrow key was pressed.");
                min = guess;
                guess = (max + min) / 2;
                Debug.Log(guess);
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                Debug.Log("Down Arrow key was pressed.");
                max = guess;
                guess = (max + min) / 2;
                Debug.Log(guess);
            }
            else if (Input.GetKeyDown(KeyCode.Return))
            {
                Debug.Log("Enter key was pressed.");
                Debug.Log("I have guessed your number!");
            }
        }
    }
}
2 Likes

I love the “Howdy Y’all.”

1 Like

Privacy & Terms