Number Wizard Code from Ohio!

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("Hi from the state of Ohio! Be amazed by my C# POWERS!");
    Debug.Log("Welcome to Guessing Your Number Game!");
    Debug.Log("Pick a number, don't tell me what it is...");
    Debug.Log("The highest number you can pick is:" + max);
    Debug.Log("The lowest number you can pick 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))
    {
        Debug.Log("Darn... I thought I had it this time...");
        min = guess;
        guess = (max + min) / 2;
        Debug.Log("Is it higher or lower than..." + guess);
    }
   else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("Darn... I thought I had it this time...");
        max = guess;
        guess = (max + min) / 2;
        Debug.Log("Is it higher or lower than..." + guess);
    }
   else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("I am a GENIUS! Be at awe of my amazing C# skills!!");
    }
} 

}

1 Like

This is really good! Great job :smiley:

Thank you!

Privacy & Terms