My Code for a Number Wizzard

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

public class NumberWizzard : MonoBehaviour
{

int max = 1000;
int min = 1;
int guess = 500;


// Start is called before the first frame update
void Start()
{
    Debug.Log("Howzit... Welcome to The 'Number Wizard'");
    Debug.Log("Please pick a number Between 1 and 1000, dont Tell Me");
    Debug.Log("I SAID DONT TELL ME :-)");
    Debug.Log("Display Highest Number you can pick is: " + max);
    Debug.Log("Display Lowest Number you can pick is: " + min);
    Debug.Log("Tell Me If you Number is Higher or Lower than:" + guess);
    Debug.Log("Push The UP-ARROW for 'Higher Guess' and Push The DOWN-ARROW for 'Lower Guess'");
    max = max + 1;
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        min = guess;
        guess = (max + min) / 2;
        Debug.Log("Is it HIGHER or LOWER than:" + guess);
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        max = guess;
        guess = (max + min) / 2;
        Debug.Log("Is it HIGHER or LOWER than:" + guess);
    }
    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("You WON!");
    }
}

}

1 Like

Great job for sharing your code!

Privacy & Terms