Number Wizard

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

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

    // Use this for initialization
    void Start()
    {
        Debug.Log("Welcome to Number Wizard everyone!");
        Debug.Log("Please pick a number to begin the game and I'll be sure to guess it!");
        Debug.Log("The highest number you can pick is: " + max + " and the lower number is: " + min + " ;) ");
        Debug.Log("Tell me if your number is higher or lower than: " + guess);
        Debug.Log("Push Up = Higher, Down = Lower and Enter = Correct");
        max = max + 1;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            min = guess;
            guess = (min + max) / 2;
            Debug.Log("Is your number: " + guess);
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            max = guess;
            guess = (min + max) / 2;
            Debug.Log("Is your number: " + guess);
        }
        else if (Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("Yay! I found your guess!!!." + guess);
        }
    }
}

Privacy & Terms