Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class NumberWizard : MonoBehaviour {
- int max = 1001;
- int min = 1;
- int guess = 500;
- // Use this for initialization
- void Start () {
- StartGame ();
- }
- void StartGame() {
- int max = 1001;
- int min = 1;
- int guess = 500;
- print ("============");
- print ("Welcome to Number Wizard!");
- print ("Pick a number in your head, but don't tell me!");
- print ("Highest number that you can go for is, " + max);
- print ("Lowest number that you can go for is, " + min);
- print ("Is your number above or under " + guess + "?");
- print ("Press up arrow for Above, Down arrow for Under and return for equals.");
- }
- void NextGuess() {
- guess = (min + max) / 2;
- print ("Higher or lower than " + guess);
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetKeyDown (KeyCode.UpArrow)) {
- // print ("Above 500!");
- min = guess;
- NextGuess ();
- } else if (Input.GetKeyDown (KeyCode.DownArrow)) {
- //print ("Under 500!");
- max = guess;
- NextGuess();
- } else if (Input.GetKeyDown (KeyCode.Return)){
- print ("I got it! You lost!");
- StartGame();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement