Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.1k views
in Technique[技术] by (71.8m points)

I can't assign every position to true in boolean 2D array with for loops in Processing 3.5.4

Hi I am making a small game (frogger), and I'm trying to make all of the water lethal to walk on. Anyways, I made a 2D boolean array called deathCoords[][] and i want to make all rows from row 7 to row 14 return true. This is what I've written to fill the array from row 7 to row 14 with true.

deathCoords = new boolean[height][15];
for (int i = 7; i > 14; i++) {
  for (int n = 0; n > height; n++) {
    deathCoords[n][i] = true;
  }
}

When i walk on top of the water it still returns false. If i do this and walk on top on that spot it works:

deathCoords[0][0] = true;

Any way to fix this? Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...