xxxxxxxxxx
220
var tela = 1;
var largura = 200;
var altura = 50;
var menux = 50;
var menuy1 = 85;
var menuy2 = 150;
var menux3 = 210;
//temporizador
let cont = 0
let contS = 0
//contafor de vidas
let vida = 0;
//tela de jogo
var mnx1 = 200;
var mny1 = 15;
//imagem de fundo
let img;
var dica = false;
function preload() {
img = loadImage("capa.png");
img2 = loadImage("Cley.png");
img3 = loadImage("qd01.jpg");
img4 = loadImage("GO.jpg");
img5 = loadImage("tfinal.jpg");
img6 = loadImage("garrafa.jpg");
img7 = loadImage("chaleira.jpg");
img8 = loadImage("qd02.jpg");
img9 = loadImage("Einstein.png");
img10 = loadImage("newton.png");
}
function setup() {
createCanvas(300, 300);
frameRate(30);
}
function dicas() {
if (tela == 5 ){
background(10);
text("Dica Tela 5!", 50, 200);
}
}
function draw() {
background(0);
image(img, 0, 0);
//tela inicial
textStyle(NORMAL);
if (tela == 1) {
textAlign(CENTER);
textSize(25);
//iniciar
if (mouseX > menux && mouseX < menux + largura && mouseY > menuy1 && mouseY < menuy1 + altura) {
strokeWeight(3);
stroke(255, 0, 0);
noFill();
rect(menux, menuy1, largura, altura, 50);
if (mouseIsPressed) {
tela = 2;
}
}
fill(255);
noStroke();
text("Iniciar", 150, 120);
//informações
if (mouseX > menux && mouseX < menux + largura && mouseY > menuy2 && mouseY < menuy2 + altura) {
strokeWeight(3);
stroke(0, 0, 255);
noFill();
rect(menux, menuy2, largura, altura, 50);
if (mouseIsPressed) {
tela = 3;
}
}
fill(255);
noStroke();
text("Informações", 150, 183);
//autor
text("Creditos", 150, 240);
if (mouseX > menux && mouseX < menux + largura && mouseY > menux3 && mouseY < menux3 + altura) {
strokeWeight(3);
stroke(0, 255, 0);
fill(0);
noFill();
rect(menux, menux3, largura, altura, 50);
if (mouseIsPressed) {
tela = 4;
}
}
}
//tela de fase 01
else if (tela == 2) {
if ( dica ) {
background(225);
if ( keyIsPressed ) {
dica = false;
}
} else {
background(0);
image(img3, 0, 30);
image(img6, 165, 225);
image(img7, 30, 240);
text("A)", 15, 280);
text("B)", 150, 280);
textSize(15);
noStroke();
cont = cont + 1
textSize(10);
contS = parseInt(cont / 30);
vida = parseInt(contS / 2);
if (cont % 60 == 0 ) {
dica = true;
}
text("TEMPO: " + contS, 35, 20);
text("VIDAS PERDIDAS: " + (3 - vida), 150, 20);
if (vida == 3) {
tela = 0;
}
}
} else if (tela == 3) {
background(0, 110, 170);
fill(255);
textSize(20);
noStroke();
textAlign(CENTER);
text("COMO JOGAR" + "\n" + "\n " + " Escolha a resposta certa para ganhar pontos." + "\n" + "Tente não passar mais de 30 segundos em cada pergunta ou erra-las, isso custará vidas.", 20, 20, 250, 250);
} else if (tela == 4) {
background(50, 20, 150);
textSize(20);
fill(255);
noStroke();
textAlign(CENTER);
image(img2, 10, 20);
text("Programador: Armstrong Cleydmen" + "\n" + "Turma 04D", 80, 30, 200, 200);
//tela de fase 02
} else if (tela == 5) {
background(0);
image(img8, 0, 30);
image(img9, 165, 225);
image(img10, 30, 220);
text("A)", 15, 280);
text("B)", 150, 280);
textSize(15);
noStroke();
/*cont = cont + 1
textSize(10);
contS = parseInt(cont / 30);
vida = parseInt(contS / 30);
text("TEMPO: " + contS, 35, 20);
text("VIDAS PERDIDAS: " + vida +"/3", 150, 20);
if(vida == 3){
tela = 0;
}
*/
if (mouseX > 180 && mouseX < 180 + altura && mouseY > 215 && mouseY < 215 < largura) {
noStroke();
if (mouseIsPressed && tela == 5) {
tela = 0;
}
}
//tela de fase 03
} else if (tela == 6) {
background(0);
textSize(50);
text("FASE 02", 100, 100);
//tela de GAME OVER
} else if (tela == 0) {
background(0);
image(img4, 0, 0);
}
}
function mouseReleased() {
if (mouseX > 55 && mouseX < 55 + altura && mouseY > 230 && mouseY < 230 + largura) {
noStroke();
if (tela == 5) {
tela = 6;
}
}
if (mouseX > 55 && mouseX < 55 + altura && mouseY > 230 && mouseY < 230 + largura) {
noStroke();
if (tela == 2) {
tela = 0;
}
}
if (mouseX > 180 && mouseX < 180 + altura && mouseY > 215 && mouseY < 215 < largura) {
noStroke();
if (tela == 2) {
tela = 5;
}
}
}