My Number Wizard code.......Rahul_Dev

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("Hey, Mates Welcome to the Number Guessing game! ");
    Debug.Log("Select a Secret Number at Your own Wish, within the limits ");
    Debug.Log("The Highest Number you can Assign is: " + max);
    Debug.Log("The Lowest Number you can Assign is: " + min);
    Debug.Log("Now, tell me if your code is Higher or lower than 500");
    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))
    {
        Debug.Log("Up Arrow key was pressed.");
        min = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
        
    {
        Debug.Log("Down Arrow key was pressed.");
        max = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);
    }
    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("Enter key was pressed.");
    }
}

}

1 Like

Nice looking code

Privacy & Terms