xxxxxxxxxx
85
let serial;
let portName = "COM3"; // Change this to the correct port name
let latestData = "waiting for data";
let level = 0;
let clicked = false;
let mainmenu;
function mouseClicked() {
if (!clicked) {
clicked = true; // set the clicked variable to true
}
}
function preload() {
// mainmenu = loadImage("mainmenu.png");
}
function setup() {
preload();
createCanvas(400, 500);
// // Initialize the serial communication
// serial = new p5.SerialPort();
// serial.open(portName);
// serial.on("data", serialEvent);
}
function draw() {
if (level == 0) {
background(0);
// image(
// mainmenu,
// 0,
// 0,
// width,
// height,
// 0,
// 0,
// mainmenu.width,
// mainmenu.height,
// CONTAIN,
// LEFT
// );
fill(255);
textSize(24);
textAlign(CENTER, CENTER);
fill(100, 100, 230, 1);
stroke(0);
if (
mouseX > width / 2 - 75 &&
mouseX < width / 2 + 75 &&
mouseY > height / 2 - 25 &&
mouseY < height / 2 + 25
) {
stroke(100, 100, 230);
rect(width / 2 - 45, height / 2 - 15, 87, 30);
if (clicked) {
level = 0;
}
}
if (
mouseX > width / 2 - 97 &&
mouseX < width / 2 + 97 &&
mouseY > height / 2 - 25 + 45 &&
mouseY < height / 2 + 25 + 45
) {
stroke(100, 100, 230);
rect(width / 2 - 97, height / 2 + 45, 193, 30);
if (clicked) {
level = 3;
}
}
} else if (level == 1) {
print("level 1");
} else if (level == 2) {
clicked = false; // reset the clicked variable
}
}