Greeting and my Number Wizard

Hello everyone :+1:t3:

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!");
        }
    }
}
2 Likes

How did you feel about your code? Was it exciting writing it?

Haven’t felt so passionate about something in years, wish I had more free time to practice!

I have to agree. I am very passionate about this. I have been trying to learn for a while now, but with these new teachers on Udemy, I think I am starting to understand it.

1 Like

Privacy & Terms