xxxxxxxxxx
51
let gameOver = false;
function setup() {
createCanvas(660, 460);
sound_background.loop();
}
function draw() {
background(0);
image(img, 30, 30, 600, 400);
playerDraw();
car();
playerCollide();
playerPoints();
carController();
setupScreen();
gameOverScreen();
}
function setupScreen() {
fill(0);
rect(0, 30, 30, 400);
rect(630, 30, 30, 400);
image(player, 30, 8, 20, 18);
fill(255);
textAlign(CENTER);
textSize(18);
text(" x " + playerSCORE, 65, 23);
}
function gameOverScreen() {
if (gameOver === true) {
fill(0);
rect(180, 130, 300, 200);
fill(255);
textAlign(CENTER);
textSize(24);
textStyle(BOLD);
text("GAME OVER", 330, 180);
textSize(18);
textStyle(NORMAL);
image(player, 225, 216, 16, 15);
text("Melhor Pontuação: " + playerM, 330, 230);
textSize(14);
text("Pressione R para reiniciar", 330, 280);
}
}