Number Wizard Greeting From South Africa

1 Like

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("Awe, bru! Welcome to Number Wizard.");
    Debug.Log("Pick a number.");
    Debug.Log("Highest number is: " + max);
    Debug.Log("Lowest number is: " + min);
    Debug.Log("Tell me if your number is 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()
{
    //Detect when the up arrow key is pressed down
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        min = guess;
        guess = (max + min) / 2;
        Debug.Log("Is your number higher or lower than: " + guess + "?");
    }
    //Detect when the down arrow key is pressed down
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        max = guess;
        guess = (max + min) / 2;
        Debug.Log("Is your number higher or lower than: " + guess + "?");
    }
    //Detect when the Return key is pressed down
    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("Awesome-sauce!");
    }
}

}

Privacy & Terms