xxxxxxxxxx
function setup() {
createCanvas(windowWidth, windowHeight);
background(220);
}
const connectedCubeArray = [];
function draw() {
const cube = connectedCubeArray[0];
if( cube?.x && cube?.y ){
// Set background color with touched colored tile on mat
const color = P5tId.ColorTileMat.getTileColor(cube?.x, cube?.y);
background(color);
}
}
function mouseClicked() {
P5tCube.connectNewP5tCube().then(cube => {
connectedCubeArray.push(cube);
cube.turnLightOn( 'white' );
});
}