xxxxxxxxxx
404
var xSelecionado = 68;
var ySelecionado = 133;
var opc = 1;
var opcPlay = 1;
var time = 120;
var tela = 0;
//perdeu
var gameOver;
var marioPerde;
var venceu;
var imgFundo;
var imgFundoS;
var logo;
var fontGeral;
var fontText;
//jogar
var imgFundoJ1;
//fase 1
var fundoF1;
//criando o mario
var mario = new personagem();
//inimigos
var inimigo;
//como jogar
var imgInter;
var entrar;
//setas
var imgSetaE;
var imgSetaC;
var imgSetaB;
var imgSetaD;
var imgPlay;
//vetor do mario
var contImgAtual=0;
var andar = true;
var mario_vetor = [];
function preload(){
//logo
logo = loadImage("logo.png");
imgFundo= loadImage("menu.jpg");
//imgPlay = loadImage("play.png")
imgFundoS = loadImage("fundoS.jpg");
//titulos
fontGeral=loadFont('fontes/SuperMario.ttf');
//textos
fontText=loadFont('fontes/computer.ttf');
//interrogação
imgInter = loadImage("comojogar/interrogacao.gif");
//seta esquerda
imgSetaE = loadImage('setas/esquerda.png');
//seta cima
imgSetaC = loadImage('setas/cima.png');
//seta baixo
imgSetaB = loadImage('setas/baixo.png');
//seta direita
imgSetaD = loadImage('setas/direita.png');
//play
imgPlay = loadImage('setas/play.png');
//jogar
//fundo da fase 1
fundoF1 = loadImage('fase1.png');
//inimigo
inimigo = loadImage('inimigo.gif');
//entrar
entrar = loadImage('setas/entrar.png');
marioPerde=loadImage('perdeu.gif');
for(i=0; i<3; i++){
mario_vetor[i] = loadImage('mario/a'+(i+1)+'.png');
}
}
function setup() {
createCanvas(400, 400);
frameRate(30);
}
function draw() {
background(220);
if(tela==0){
menu();
}
if(tela==1){
jogar();
}
if(tela==2){
comojogar();
}
if(tela==3){
creditos();
}
if ( tela == 4) {
gameOver();
}
}
function menu(){
image(imgFundo, 0,0);
fill(255,255,0);
stroke(0,0,0);
strokeWeight(2);
rect(xSelecionado, ySelecionado, 280, 50, 25);
image(logo, 2, -140,420, 420);
noStroke();
fill(50);
fill(255,255,0);
textSize(40);
textSize(32);
textFont(fontGeral);
stroke(0,0,0);
strokeWeight(4);
fill('#d50000');
text('Jogar', 145, 170);
text('Como jogar?', 85, 240);
text('Creditos', 120, 310);
}
function jogar(){
background(100);
translate(-mario.posX, -mario.posY);
image(fundoF1,0,0,700,500);
mario.movimento();
mario.imprimir();
time --;
if(key=="Escape"){
tela=0;
time = 30;
}
//inimigos
image(inimigo, 500, 405, 25,25);
image(inimigo, 410, 350, 25,25);
image(inimigo, 550, 405, 25,25);
//texto
noStroke();
textFont('Time New Roman');
textSize(21);
fill(0,0,0);
text('Quantos', 410, 280);
//inimigo
image(inimigo, 482, 260, 25,25);
//texto
text('temos no cenário?', 510, 280);
}
function personagem(){
this.posX = 100;
this.posY = 100;
this.tam = 25;
this.imprimir = function (){
image(mario_vetor[contImgAtual], this.posX +20, this.posY+300,this.tam, this.tam);
if(andar){
contImgAtual++;
if(contImgAtual>2){
contImgAtual = 0;
}
}
}
this.movimento = function(){
andar=false;
if (keyIsDown(LEFT_ARROW)) {
this.posX -= 3;
andar=true;
}
if (keyIsDown(RIGHT_ARROW)) {
this.posX += 3;
andar=true;
}
if(this.posY>100){
this.posY=100;
}
if(this.posX<100){
this.posX=100;
}
if(this.posX>300){
this.posX=300;
}
}
}
function comojogar(){
time--;
image(imgFundoS, 0,0);
//quadrado
stroke(0,0,0);
strokeWeight(4);
fill('#FAFAD2');
square(50, 50, 300,15,15,50);
//interrogação do quadrado
xladoInter = 238;
yladoInter = 63;
image(imgInter,xladoInter, yladoInter, 100, 100);
//titulo
stroke(0,0,0);
strokeWeight(4);
fill('#d50000');
textFont(fontGeral);
textSize(40);
text('Como', 70, 110);
textSize(40);
text('jogar', 70, 150);
//texto
noStroke();
textFont(fontText);
textSize(21);
fill(0,0,0);
text('Use as teclas do teclado,', 70, 185);
text('como estas ao lado', 70, 200);
//setas
//esquerda
xladoE = 233;
yladoE = 165;
image(imgSetaE, xladoE, yladoE, 50,50);
//cima
xladoC = 265;
yladoC = 155;
image(imgSetaC, xladoC, yladoC, 50,50);
//baixo
xladoB = 265;
yladoB = 180;
image(imgSetaB, xladoB, yladoB, 50,50);
//direita
xladoD = 297;
yladoD = 165;
image(imgSetaD, xladoD, yladoD, 50,50);
//texto esquerda
noStroke();
textFont(fontText);
textSize(21);
fill(0,0,0);
text('Esquerda', 70, 220);
//seta esquerda
xladoES = 120;
yladoES = 200;
image(imgSetaE, xladoES, yladoES, 30,30);
//texto direita
noStroke();
textFont(fontText);
textSize(21);
fill(0,0,0);
text('Direita', 70, 240);
//seta direita
xladoDS = 120;
yladoDS = 220;
image(imgSetaD, xladoDS, yladoDS, 30,30);
//texto cima
noStroke();
textFont(fontText);
textSize(21);
fill(0,0,0);
text('Cima', 70, 260);
//seta cima
xladoCS = 110;
yladoCS = 240;
image(imgSetaC, xladoCS, yladoCS, 30,30);
//texto baixo
noStroke();
textFont(fontText);
textSize(21);
fill(0,0,0);
text('Baixo', 70, 280);
//seta baixo
xladoBS = 110;
yladoBS = 260;
image(imgSetaB, xladoBS, yladoBS, 30,30);
//texto sair
noStroke();
textFont(fontText);
textSize(21);
fill(0,0,0);
text('Sair', 150, 220);
fill(0,0,0);
square(177, 207, 18, 2);
fill('#FAFAFA');
textSize(13);
text('ESC', 180, 218);
//texto entrar
textFont(fontText);
textSize(21);
fill(0,0,0);
text('Entrar', 150, 240);
xladoEN = 190;
yladoEN = 220;
image(entrar, xladoEN, yladoEN, 30,30);
//texto entrar
textFont(fontText);
textSize(21);
fill(0,0,0);
text('Para vencer o inimigo: conte', 150, 260);
text('quantos você vê na tela', 150, 275);
text('apertando na tecla que ', 150, 290);
text('corresponde', 150, 305);
//xladoEN = 190;
//yladoEN = 220;
//image(entrar, xladoEN, yladoEN, 30,30);
//botão
//jogar
fill(255,255,0);
stroke(0,0,0);
strokeWeight(4);
rect(165, 315, 60, 60, 100);
xladoP = 170;
yladoP = 317;
image(imgPlay, xladoP, yladoP, 55,55);
}
function creditos(){
time--;
image(imgFundoS, 0,0);
stroke(0,0,0);
strokeWeight(4);
fill('#FAFAD2');
square(50, 50, 300,15,15,50);
//titulo
stroke(0,0,0);
strokeWeight(4);
fill('#d50000');
textFont(fontGeral);
textSize(40);
text('Creditos', 70, 110);
//nomes
noStroke();
textFont(fontText);
textSize(21);
fill(0,0,0);
text('Desenvolvedora: Brenda Vitória', 70, 185);
text('Mentora: Renata Pitta', 70, 200);
//botão
//jogar
fill(255,255,0);
stroke(0,0,0);
strokeWeight(4);
rect(165, 315, 60, 60, 100);
xladoP = 170;
yladoP = 317;
image(imgPlay, xladoP, yladoP, 55,55);
}
function venceu (){
}
function gameOver(){
background(0);
stroke('#ffffff');
strokeWeight(4);
fill('#d50000');
textFont(fontGeral);
textSize(40);
text('game over', 100, 110);
image(marioPerde, 300, 400, 30,40);
}
function keyPressed(){
if(tela == 0){
if(key=="ArrowUp" && ySelecionado>140){
ySelecionado=ySelecionado-70;
opc = opc-1;
}if(key=="ArrowDown" && ySelecionado<240){
ySelecionado=ySelecionado+70;
opc = opc+1;
}
if(key=="Enter"){
tela = opc;
}
}
//como jogar play
if(key=="Escape"){
tela=0;
time = 60;
opcPlay=1;
}
if(key=="Enter"&&time<0){
tela = opcPlay;
}
//jogar
if(tela==1){
if(key==='3'){
tela = 5;
} else if (key==='5'||key==='2'){
tela = 4;
}
}
}