xxxxxxxxxx
52
var tempo = 0;
var tela = 1;
function setup() {
createCanvas(400,400);
frameRate(30);
}
function draw() {
if (tela == 1) {
// Incio do Jogo
background(0);
textSize(32);
fill(235,106,15);
text("Tela 1", 50, 110);
// tecla para começar o jogo
if (keyIsDown(ENTER) ) {
tela = 2;
}
}
if (tela == 2) {
// Execução do Jogo
tempo++;
background(0);
textSize(32);
fill(135,206,235);
text("Tela 2", 50, 160);
text("Segundos: "+(Math.floor(tempo/30)), 50, 260);
// Situação que acaba o jogo
if ( tempo == 90 ) {
tela = 3;
}
}
if (tela == 3 ) {
// Fim do jogog
background(0);
textSize(32);
fill(135,206,235);
text("Tela 3 - FIM", 50, 210);
// voltar para a tela 1
if (keyIsDown(32) ) {
tela = 1;
tempo = 0;
}
}
}