我试图弄清楚如何将这些矩形坐标放入一个数组中(使用循环),但我无法让它们正确。数组中的值默认为“false”。例如,如果坐标为 0,则 24 blockCoords[0][1] 应该为“true”。对不起我的英语,我不是母语:P
boolean[ ][ ] blockCoords = new boolean[20][10];//the array
//added the code to create the array
private void createArray() {
for(int i=0;i<20;i++) {
for(int j=0;j<10;j++) {
blockCoords[i][j]=false;
}
}
}
//b is the block
int y1 = b.getY();//get the coordinates of the top of a block
int y2 = b.getHeight();//the height of a block
int x1 = b.getX();
int x2 = b.getWidth();
int numHorizontal = 10-((240-x2)/24);//calculates how many blocks there are - 24 is the width and the height of a block - 240/480 are the dimensions
int numVertical = 20-((480-y2)/24);
int col=10-((240-x1)/24);//in which column does the block's coordinates start in
int row=((480-y1)/24)-1;// same for the row