The Code Works FYI
I do not get this code at all. Could someone help me understand it in and out please. Please keep in mind I understand what an int is. I know what parameters are. I know what Booleans are. I know what addObject means. I just need to know more about the Arrays. I never really understood it in class.import greenfoot.*;
public class Tiles extends World{
private Tile[] tiles;
private int TRACKER;
public Tiles(){
this(4);
}
public Tiles(int SIZE){
super((SIZE+2)*50, (SIZE+2)*50, 1);
TRACKER = 0;
tiles = new Tile[(SIZE+2)*(SIZE+2)];
setUp(SIZE);
}
private void setUp(int SIZE){
for (int t = 0; t < tiles.length; t++){
if (t < SIZE + 2 || t > tiles.length - (SIZE + 2))
tiles[t] = new Tile(true); //true means the tile is flipped up
else {
if (TRACKER == SIZE + 1 || TRACKER == 0)
tiles[t] = new Tile(true);
else
tiles[t] = new Tile(false);
TRACKER++;
if (TRACKER == SIZE + 2)
TRACKER = 0;
}
}
int x = 25, y = 25, TRACKER = 0;
for (int m = 0; m < tiles.length; m++){
if (TRACKER == SIZE + 2){
x = 25;
y += 50;
TRACKER = 0;
}
addObject(tiles[m],x,y);
x += 50;
TRACKER = TRACKER + 1;
}
}
}

