xxxxxxxxxx
42
function setup() {
createCanvas(windowWidth, windowHeight);
background(color(253, 209, 24));
textStyle(BOLD);
textAlign(CENTER);
textSize(200);
}
const connectedCubeArray = [];
function draw() {
const cubeP = connectedCubeArray[0];
switch (cubeP?.magnet) {
default:
case P5tCube.magnetId.noMagnet:
background(color(253, 209, 24));
break;
case P5tCube.magnetId.pattern3:
showText('👁️');
break;
case P5tCube.magnetId.pattern4:
showText('🦶');
break;
case P5tCube.magnetId.pattern6:
showText('🐛');
break;
}
}
const showText = (t) => {
text(t, windowWidth / 2, windowHeight / 2);
}
function mouseClicked() {
P5tCube.connectNewP5tCube().then(cube => {
connectedCubeArray.push(cube);
cube.turnLightOn('white');
});
}