Local Greeting Challenge

My first post, hoping this puts my code in like the rest of yours did! :slightly_smiling_face:

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("Greetings and Welcome To the Number Wizard!");
        Debug.Log("For me to work my magic I need you to pick a number and 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 ()
    {
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            min = guess;
            guess = (max + min) / 2;
            Debug.Log("Is your number higher or lower than: " + guess); 
        }
    
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            max = guess;
            guess = (max + min) / 2;
            Debug.Log("Is your number higher or lower than: " + guess); 
        }
    
        else if (Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("Abra Cadabra!  Just like that!");
        }
	}
}

Hi and welcome to the community :slight_smile:

hoping this puts my code in like the rest of yours did

Almost :slight_smile:

Your code went in but you just need to apply the code formatting so that it displays more suitably on the forum. I have applied this for you.

Hope this helps :slight_smile:


See also;

Privacy & Terms