My atemt at Number Wizard

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("Ey wanne try my geusing game, NumberWizard?");
    Debug.Log("Think of a nuber and tell me if im close.");
    Debug.Log("Your highest guess can be: " + max);
    Debug.Log("And your lowest: " + min);
    Debug.Log("you can tell me by pressing:");
    Debug.Log("UpArrow for higher, Down for lower, And Enter if im correct.");
    Debug.Log("And Enter if im correct.");
    Debug.Log("So how about 500?");
    
    max = max + 1;
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("higher!");
        min = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("Lower!");
        max = guess;
        guess = (max + min) / 2;
        Debug.Log(guess);
    }
    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("Ha totaly guessed it first try... hehe wanne go again?");
    }
}

}

1 Like

Awesome job! :love_you_gesture:

Privacy & Terms