Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class NumberWizard : MonoBehaviour {
  5.  
  6. // Use this for initialization
  7. int max;
  8. int min;
  9. int guess;
  10.  
  11. void Start () {
  12. StartGame();
  13. }
  14.  
  15. void StartGame () {
  16.  
  17. max = 1000;
  18. min = 1;
  19. guess = 500;
  20.  
  21. print ("========================");
  22. print ("Welcome to Number Wizard");
  23. print ("========================");
  24. print ("Pick a number in your head, but don't tell me!");
  25.  
  26. print ("The highest number you can pick is " + max);
  27. print ("The lowest number you can pick is " + min);
  28.  
  29. print ("Is the number higher or lower than " + guess + "?");
  30. print ("Up = higher, down = lower, or return = equal");
  31.  
  32. max = max + 1;
  33. }
  34.  
  35.  
  36.  
  37.  
  38. // Update is called once per frame
  39. void Update () {
  40. if (Input.GetKeyDown(KeyCode.UpArrow)) {
  41. //print("Up arrow pressed");
  42. min = guess;
  43. NextGuess ();
  44. } else if (Input.GetKeyDown(KeyCode.DownArrow)) {
  45. //print("Down arrow pressed");
  46. max = guess;
  47. NextGuess ();
  48. } else if (Input.GetKeyDown(KeyCode.Return)) {
  49. print("I got yo mothafuckin' digletts biatch!");
  50. StartGame ();
  51. }
  52. }
  53. void NextGuess () {
  54. guess = (max + min) / 2;
  55. print ("Is your number higher or lower than " + guess + "?");
  56. print ("Up = higher, down = lower, or return = equal");
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement