[Challenge] Number Wizard Welcome from the UK

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("Watcha Mate! Welcome to the Hypnotic, Marvel, that is - Number Wizard");
    Debug.Log("Please Pick a Number and keep it to Yourself");
    Debug.Log("Highest Number is: " +max);
    Debug.Log("Lowest Number is: " +min);
    Debug.Log("Is your number Higher, or Lower, than: " + guess);
    Debug.Log("Push Up = Higher, Push Down = Lower, Push Enter = Correct");
    max = max + 1;
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        min = guess;
        guess = (max + min) / 2;
        Debug.Log("Ok, now is it higher or lower than " + guess);
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        max = guess;
        guess = (max + min) / 2;
        Debug.Log("Ok, now is it higher or lower than " + guess);
    }
    else if (Input.GetKeyUp(KeyCode.Return))
    {
        Debug.Log("I guessed Correct? Wow! It hardly ever works.");
    }
}

}

Privacy & Terms