Skip to content

Instantly share code, notes, and snippets.

Created June 17, 2017 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/ec958c4e9d8a5db25937ff543ec03270 to your computer and use it in GitHub Desktop.
Save anonymous/ec958c4e9d8a5db25937ff543ec03270 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class NUmberWizards : MonoBehaviour {
int max;
int min;
int guess;
// Use this for initialization
void Start () {
StartGame();
}
void StartGame() {
max = 1000;
min = 1;
guess = 500;
print("========================");
print("Welcome to Number Wizard");
print("1");
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 = higher,down = lower,return = equal");
max = max + 1;
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.UpArrow))
{
min = guess;
NextGuess();
} else if (Input.GetKeyDown(KeyCode.DownArrow))
{
max = guess;
NextGuess();
} else if (Input.GetKeyDown(KeyCode.Return))
{
print("I won");
StartGame();
}
}
void NextGuess() {
guess = (max + min) / 2;
print("higher or lower than" + guess);
print("Up = higher,down = lower,return = equal");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment