Number Wizard game

I’m really liking this so far :smile: I’m not that creative story wise but I’m treating this as my first game

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, Dan here! Welcome to my first C# game - Number Wizard!");
        Debug.Log("To start off, please pick a number");
        Debug.Log("The highest number you can pick is " + max);
        Debug.Log("The lowest number you can pick is " + min);
        Debug.Log("Could you tell me if your number is higher or lower than " + guess);
        Debug.Log("Controls: 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))
        {
            min = guess;
            guess = (max + min) / 2;
            Debug.Log(Time.frameCount + "Is the guess higher or lower than..." + guess);
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            max = guess;
            guess = (max + min) / 2;
            Debug.Log(Time.frameCount + "Is the guess higher or lower than..." + guess);
            Debug.Log(guess);
        }
        else if (Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log(Time.frameCount + "Awesome!");
        }
    }
}
1 Like

Hey Daniel, glad you are having fun with it!

Not to shoot you down, but I recommend getting through this part of the course asap, the following tutorials are a lot more fun in my opinion with more room for your own customisation.

It is good to teach you the basics though!

Privacy & Terms