간단한 업다운 게임 하나 만들고 있는데 ..
min
max
guess 변수를 선언하고
max +min = guess 가 되는식으로
프로그램을 짰는데
아무리 실행해도 guess 변수가 0 에서 변하질 않습니다 ..ㅠㅠ
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NW : MonoBehaviour{
int max ;
int min;
int guess ;
void Start()
{
StartGame();
}
public void StartGame()
{
int max = 1000;
int min = 1;
int guess = 500;
max = max + 1;
print("==============================");
print("welcome");
print("highest N>" + max);
print("lowest N >" + min);
print(" h or l than " + guess + "?");
print("Up , down , equal");
}
// Update is called once per frame
void Update(){
if (Input.GetKeyDown(KeyCode.UpArrow)){
this.min = guess;
NextGuess();
}
else if (Input.GetKeyDown(KeyCode.DownArrow)){
this.max = guess;
NextGuess();
}
else if (Input.GetKeyDown(KeyCode.Return)){
print("i won!");
StartGame();
}
}
void NextGuess()
{
this.guess = (max + min)/2;
print("higher of Lower than" + guess + "?");
print ("Up , down , equal");
}
}
스타트게임 함수에서 첨에 변수에 값넣을때 앞에 int 빼야하지 않나여
ㄴ 으어어 그런거같아여 감사합니데이!