Welcome to OStack Knowledge Sharing 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...