Number wizard : Guess the variable

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

public class NumberWizard : MonoBehaviour
{
int max = 5000;
int min = 50;
int guess = 2525;

// Start is called before the first frame update
void Start()
{
    

    Debug.Log("Jay Jagannath. Namaste");

    Debug.Log("Pick a number and wait for the magic to happen");
    
    Debug.Log("Highest number you can pick is: " + max);

    Debug.Log("Lowest number you can pick is: " + min);

    Debug.Log("Press up = Higher, Press down = Lower, Press Enter = Correct");

    max = max + 1;
}

// Update is called once per frame
void Update()
{

    if (Input.GetKeyDown(KeyCode.UpArrow))
    { 
        Debug.Log("Higher");
        min = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);

    }

    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("Lower");
        max = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);
    }

    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("Hereby the magic happened");
    }
}

}

Privacy & Terms