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("Buna ziua! I'm the Number Wizard and with my magical c# powers I'm going to guess what are you thinking about...");
Debug.Log("Please pick a number. Shhhhh! Don't tell me, it's a secret.");
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("Instructions: 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("Hmmm.. The number you chose is higher than my guess.");
min = guess;
guess = (min + max) / 2;
Debug.Log("Is it higher or lower than " + guess);
// Debug.Log(guess);
}
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
Debug.Log("Oh! The number you chose is lower than my guess.");
max = guess;
guess = (min + max) / 2;
Debug.Log("Is it higher or lower than " + guess);
//Debug.Log(guess);
}
else if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("The number you picked is ... " + guess);
Debug.Log("Haha! The Nuber wizard is always correct!");
}
}
}
1 Like
Awesome looking code!