xxxxxxxxxx
44
let title;
let begin;
let beginHover;
let exit;
let exitHover;
let pressed = 0;
function preload() {
title = loadImage("assets/titleImg0.jpg");
begin = loadImage("assets/begin.PNG");
beginHover = loadImage("assets/beginHover.PNG");
exit = loadImage("assets/exit.PNG");
exitHover = loadImage("assets/exitHover.PNG");
}
function setup() {
createCanvas(windowWidth, windowHeight);
// console.log(windowWidth/2 - 300)
}
function draw() {
background(20);
titleScreen();
if (pressed == 1) {
gameScreen();
}
// console.log(mouseX, mouseY)
}
function titleScreen() {
image(title, 0, 0,windowWidth, windowHeight);
image(begin, windowWidth/2 - 120, windowHeight/2 - 100, 400, 300);
if (mouseX > windowWidth/2 - 70 && mouseX < windowWidth/2 + 40 && mouseY > windowHeight/2 + 100 && mouseY < windowHeight/2 + 150) {
image(beginHover, windowWidth/2 - 120, windowHeight/2 -100, 400, 300);
if (mouseIsPressed) {
pressed = 1;
gameScreen();
}
}
}
function gameScreen() {
background(200);
}