This is my code for the NW

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

public class NumberWizard : MonoBehaviour
{
//Variable
int maX = 1000;
int miN = 1;
int guess = 500;

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

    //Rule of game
    
    Debug.Log("Welcome to the wizard of number, i can gues what you are thinking...."); 
    Debug.Log("OK first lets begin, think of a number , com'on you can do it: ");
    Debug.Log("Don't pick lower then: " + miN + "it's not possbile for me to do the math.");
    Debug.Log("Don't pick Higher then: " + maX + "to hard");
    
    maX = maX + 1;

    //First guess operation
    Debug.Log("Now let's begin, let me rub my head, Mmmmmmmmmh is it higher then 500?");
    Debug.Log("Ok now your turn to work.");
    Debug.Log("If it's higher press the Up key.");
    Debug.Log("Now if it's lower well down key.");
    Debug.Log("If i won just Press Enter and start to cry.");
}

// Update is called once per frame
void Update()
{
    //Player input Up arrow / when press only
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("Oh it's higher, ok ok.");
        miN = guess;
        guess = (maX + miN) / 2;
        Debug.Log(guess);
    }

    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("So it's lower, am getting there");
        maX = guess;
        guess = (maX + miN) / 2;
        Debug.Log(guess);

    }

    else if (Input.GetKeyDown(KeyCode.Return)) 
    {
        Debug.Log("I am the champion, you are the loser....");
    }


}

}

2 Likes

Good looking code :sunglasses:

1 Like

Thanks dude.

1 Like

You’re welcome!

Privacy & Terms