Created
July 20, 2016 04:39
-
-
Save anonymous/98fe16a1bc2391d8bf421a39d5825337 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class NumberWizard : MonoBehaviour { | |
// Use this for initialization | |
int max ; | |
int min ; | |
int guess ; | |
void Start () { | |
StartGame (); | |
NextGuess (); | |
} | |
void StartGame () { | |
max = 1000; | |
min = 1; | |
guess = 500; | |
print("======================"); | |
print("welcome to Number Wizard"); | |
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("Is the number higher or lower than " +guess); | |
print("Up arrow for higher,down for lower,return for equal");} | |
void NextGuess (){ | |
guess = ( max + min ) / 2; | |
print ("Higher or lower than" + guess); | |
print("Up arrow for higher,down for lower,return for equal"); | |
max = max + 1;} | |
} | |
// Update is called once per frame | |
void Update () { | |
if(Input.GetKeyDown(KeyCode.UpArrow)){ | |
// print("Up arrow pressed"); | |
min = guess; | |
NextGuess (); | |
}else if(Input.GetKeyDown(KeyCode.DownArrow)){ | |
// print("Down Arrow pressed"); | |
max = guess; | |
NextGuess (); | |
} else if(Input.GetKeyDown(KeyCode.Return)){ | |
print("I won"); | |
StartGame ();} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment