xxxxxxxxxx
227
var xDino = 0;
var x = 280
var y = 156
var opçao = 1
var tela = 0
var img;
var w = -305
var Zchao = 416
var z = Zchao
var pulo = false
var img7;
var x1 = 0
var x2 =200
var scrollSpeed = 4;
var x3 = 320
var x4 = 700
var x5 = 1000
var x6 = 1300
var x7 = 1500
function preload() {
img = loadImage('cenario.png');
img2 = loadImage('seta.png');
img3 = loadImage('DINAO.png');
img4 = loadImage('eu(1).png');
img5 = loadImage('maqsi(1).png');
img6 = loadImage('enfeite matinho2.png');
img7 = loadImage('miniCacto.png');
img8 = loadImage('passaross.png');
img9 = loadImage('passaross.png');
img10 = loadImage('passaross.png');
img11 = loadImage('passaross.png');
img12 = loadImage('DINAO2.png');
}
function setup() {
createCanvas(500, 500);
x2 = width;
}
function draw(){
//red(vermelho), green(verde), blue(azul)
background(190, 250, 190);
if(tela==0 || tela==2){
image(img, -305, -50)
image(img2, 400, 420)
image(img3, 0, 217)
image(img8, 12,233);
image(img9, 40,190);
image(img10, 47,225);
image(img11, 5,200);
}
if(tela == 1 ){
image(img, x1, 0, width, height);
image(img, x2, 0, width, height);
image(img8, 12,233);
image(img9, 40,190);
image(img10, 47,225);
image(img11, 5,200);
image(img12, xDino, z,100,100);
image(img7, x3, 460, 40, 40);
image(img7, x4, 470, 30, 50);
image(img7, x5, 460, 40, 40);
image(img7, x6, 460, 35, 40);
image(img7, x7, 470, 30, 50);
x1 -= scrollSpeed;
x2 -= scrollSpeed;
x3 -= scrollSpeed;
x4 -= scrollSpeed;
x5 -= scrollSpeed;
x6 -= scrollSpeed;
x7 -= scrollSpeed;
if ( dist(xDino,z,x3,460) < 100 ){
console.log("Colidiu!")
fill(255)
ellipse(xDino,z,20,20)
ellipse(x3,460,20,20)
console.log(dist(xDino,z,x3,460))
x3 = 320
x4 = 700
x5 = 1000
x6 = 1300
x7 = 1500
}
if (x1 < -width){
x1 = width;
}
if (x2 < -width){
x2 = width;
}
if (x3 < -width){
x3 = width;
}
if (x4 < -width){
x4 = width;
}
if (x5 < -width){
x5 = width;
}
if (x6 < -width){
x6 = width;
}
if (x7 < -width){
x7 = width;
}
}
if(keyIsDown(RIGHT_ARROW)){
w = w - 10
}
if(keyIsDown(UP_ARROW) && ! pulo){
z = Zchao - 100
pulo = true
}
if(pulo){
if(z < Zchao){
z = z + 2
}
else{
pulo = false;
}
}
if(tela==3){
image(img, -305, -50);
image(img2, 400, 420);
image(img4, 100, 200);
image(img5, 290, 200);
image(img6, 200, 430);
image(img7, 10, 400);
image(img8, 12,233);
image(img9, 40,190);
image(img10, 47,225);
image(img11, 5,200);
}
if (tela == 0) {
menu();
}
if (tela == 1){
start();
}
if(tela == 2){
instruçoes();
}
if(tela == 3){
creditos();
}
}
function menu() {
stroke(20,30,40);
fill(25, 100)
rect(x, y, 200, 50, 40);
textSize(30);
text("T-Rex Running", 132, 80);
text("Jogar", 338, 190);
text("Instruções", 309, 290);
text("Créditos", 326, 390);
}
function start(){
text("START", 100, 50);
textSize(30);
}
function instruçoes(){
text("Instruções", 40, 40)
text("Ajude nosso amigo Dino a vencer os obstáculos do caminho !", 18, 80);
text(" Basta controlá-lo com a seta 'Arrow Up' do seu teclado.", 10, 137);
text("Para escolher uma opção, use as teclas 'Arrow Up' e 'Arrow", 15, 160);
text(" Down'. Para selecionar a opção desejada, aperte a tecla 'enter'.", 11, 182);
text("Para voltar ao menu, aperte a tecla 'esc' a qualquer momento.", 15, 205);
text(" Estão preparados? Vamos lá!", 250, 350)
textSize(17);
}
function creditos(){;
text("Créditos", 100, 50);
text("Este programa foi desempenhado por Emily Cabral,", 20, 100);
text(" aluna de Ciência e Tecnologia da UFRN, com a colaboração ", 15, 120);
text("de Max Xavier, graduando em C&T da UFERSA.", 20, 140);
text("Emily Cabral", 120, 340);
text("Max Xavier", 323, 340);
textSize(17);
}
function keyPressed(){
if(key=="ArrowUp" && y >200){
y = y - 100
opçao = opçao - 1;
console.log(opçao)
}
if(key=="ArrowDown" && y < 300){
y = y + 100
opçao = opçao + 1
console.log(opçao)
}
if(key == "Enter") {
tela = opçao
}
if(key == "Escape") {
tela = 0
}
}