top of page

using UnityEngine;
using System.Collections;

public class NumberWizard : MonoBehaviour {

    int max = 1000;
    int min = 1;
    int guess;

    // Use this for initialization
    void Start () {
        guess = (max + min) / 2;

        print ("Welcome to NumberWizard");
        print ("Pick a number in your head, but don't tell me");
        print ("The highest number you can pick is " + max);
        print ("The lowest number you can pick is " + min);
        print ("up = higher down = lower enter = correct");
        print ("My guess is " + guess);
    
    }
    
    // Update is called once per frame
    void Update () {
        if (Input.GetKeyDown (KeyCode.UpArrow)) {
            
            //print ("You press the up arrow, good job");
            min=guess;
            guess = (max + min) / 2;
            print("Is your number " + guess);
        }

        if (Input.GetKeyDown (KeyCode.DownArrow)) {
                
            //print ("You press the down arrow, good job");
            max = guess;
            guess = (max + min) / 2;
            print ("Is your number " + guess);
        }

            if (Input.GetKeyDown(KeyCode.Return)){
                
                //print ("You press the down arrow, good job");

                print ("I guess your number is " + guess);
        }

}
}
 

This was the coding for game. We made a guessing the number game with this code.

© 2023 by Graphic Design Porfolio. Proudly created with Wix.com

bottom of page