Hello everyone
My name is Anton, I am a 22 yo Russian guy who lives in Poland.
This is my first code after 3 years, I am very excited about this course!
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using Debug = UnityEngine.Debug;
public class NumberWizard : MonoBehaviour {
int max = 1000;
int min = 1;
int guess = 500;
void Start() {
Debug.Log("You have entered the realm of number guessing.");
Debug.Log("Please, guess a number in your mind and I will tell you what it is ;)");
Debug.Log("The number has to be between " + min + " and " + max + ".");
Debug.Log("Use Arrow Up if your number is higher, use Arrow Down if it is lower.");
Debug.Log("And finally press enter if it is correct!");
Debug.Log("Is it " + guess + "?");
max += 1;
}
void Update() {
if (Input.GetKeyDown(KeyCode.UpArrow)) {
min = guess;
guess = (max + min) / 2;
Debug.Log("It is higher you say? Is it: " + guess + "?");
} else
if (Input.GetKeyDown(KeyCode.DownArrow)) {
max = guess;
guess = (max + min) / 2;
Debug.Log("Lower it is, huh? Is it: " + guess + "?");
} else
if (Input.GetKeyDown(KeyCode.Return)) {
Debug.Log("That's what I am talking about!");
}
}
}