class BoardCell
{
private SurfaceImage mySurface;
private ImageLayer myLayer;
public BoardCell(float left, float top, float width, float height, GroupLayer parent)
{
this.left = left;
this.top = top;
this.width = width;
this.height = height;
mySurface = graphics().createSurfaceImage(width, height);
myLayer = graphics().createImageLayer(mySurface);
parent.add(myLayer);
myLayer.setTranslation(left, top);
}
public void setImage(Image image)
{
mySurface.surface().clear();
mySurface.surface().drawImage(image, 0, 0, mySurface.surface().width, mySurface.surface().
height);
}
}
class ChessBoard
{
private BoardCell[][] cells;
private GroupLayer boardLayer;
public ChessBoard()
{
float cellSize = graphics().height() / 8f; //Assuming landscape orientation and square cells
boardLayer = graphics().createGroupLayer();
cells = new BoardCell[8][8];
for(int y = 0; y < cells.length; y++)
{
for(int x = 0; x < cells[0].length; x++)
{
cells[y][x] = new BoardCell(x * cellSize, y * cellSize, cellSize, cellSize, boardLayer);
}
}
}
}