バーチャルペットゲームを作っています。この段階では、セーブ ファイルのロードは機能していますが、コア機能の組み込みを開始すると、プログラムが実行されません。
私はこれを見つけました:悪い形の文字(引用を期待して、私を手に入れました)〜処理 これは、ロード機能の問題だと思いますが、処理が初めてで、これをデバッグする方法がわかりません。
Creature creature;
String data[];
boolean gameInfo[];
int tempData[];
boolean food;
void setup() {
size(100,100);
String data[] = loadStrings("save.txt");
String[] tempData = split(data[0], ',');
gameInfo = int(tempData);
for (int i = 0; i < data.length; i++) {
creature = new Creature(gameInfo[0], gameInfo[1], gameInfo[2], gameInfo[3]);
}
food = false;
}
void draw() {
creature.think(food);
}
//creature class
class Creature {
boolean idle;
int hungry;
int age;
int gender;
int asleep;
Creature(int gender, int age, int hungry, int asleep) {
this.gender = gender;
this.age = age;
this.hungry = hungry;
this.asleep = asleep;
boolean idle = true;
}
void whatDo(boolean food) {
println('whatdo');
if (idle = true && hungry == true) {
if (food == true) {
creature.eat();
}
else
creature.ask();
}
}
void ask() {
if (hungry == true) {
println("HUNGRY");
}
}
void eat() {
println("EAT");
idle = false;
}
}