using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizard : MonoBehaviour
{
int max = 1000;
int min = 1;
int guess = 500;
// Start is called before the first frame update
void Start()
{
Debug.Log("Hej, witaj w zgadywaczu liczb!");
Debug.Log("Wybierz swoja liczbe! Pamietaj, ze:");
Debug.Log("Maksymalna liczba to: " + max);
Debug.Log("Minimalna liczba to: " + min);
Debug.Log("Powiedz, czy Twoja liczba to wiecej czy mniej niz " + guess);
Debug.Log("Strzalka w gore = wiecej, strzalka w dol = mniej, enter = to moja liczba");
max = max + 1;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
min = guess;
guess = (max + min) / 2;
Debug.Log("Twoja liczba jest mniejsza czy wieksza od " + guess);
}
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
max = guess;
guess = (max + min) / 2;
Debug.Log("Twoja liczba jest mniejsza czy wieksza od " + guess);
}
else if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("Ha! ZGADLEM!.");
}
}
}
1 Like
Awesome code!