(*) Créditos:Desbravadoido é uma publicação original do Clube Eclipse https://clube-eclipse.blogspot.com.br/
Animações:
/** Hello there-
when viewing this program, please check to make sure the author is diagram1111
if this is a spin-off and you like it, it would
be appreciated you check out
the original.
VOTE UP IF YOU LIKE IT :-D
also, if you spin-off please give credit and
do not delete this message
controls:
space/click:flap
press and hold the mouse or the spacebar when in glide mode
**/
/*
___ _ __ ___ ___
|| || //\\ // \\ // \\ \\ //
||__ || //--\\ ||_// ||_// \\//
|| || // \\ || || ||
|| /|____ // \\ || || ||
_______ _______
// /\ ||
|/ /__\ || ___ _ __ __ _
|\ / \ || __ |\ | /-\ / _ |_\ /-\ |\/| /| /| /| /|
\\______ || |/ _|_/ \ \_| |\ / \ | | _|_ _|_ _|_ _|_
ANOTHER CLONE?!???
____________________
| |
| PLAY |
|____________________|
*meowww*
|\___/| |\___/| |\___/| |\___/| |\___/|
|o o| |o o| |o o| |o o| |o o|
\__^__/ \__^__/ \__^__/ \__^__/ \__^__/
*/
var hitbox=false; //muito difícil? isso lhe dará uma idéia melhor de hitbox p/você
frameRate(50);
var start=0;
var cS=[400,400]; //canvasSize[width,height]
var catY=206;//cat Y cord
var catYM=0;//cat Y momentum
var catT=0;//cat tilt
var type=1;
var score=0;
var highscore=[0,0];
var im=createFont('Verdana',0);
var bold=createFont('Courier Bold',0);
var mouse={
x:0,
y:0
};
//variables for mouse clicked. ms.r is the return variable
var ms={
stage: 0,
r: false
};
//variables p/ teclas
var keys=[];
var keyOnce=[];
var kos=0;
var keyPressed=function(){
keys[keyCode]=true;
kos=1;
};
var keyReleased=function(){
keys[keyCode]=false;
keyOnce[keyCode]=true;
kos=0;
};
noStroke();
//var mY=400;
var message=function(txt,mY){
textAlign(CENTER,CENTER);
fill((mY+100)/2);
text(txt,200,mY);
mY+=-1;
};
var pipe=function(a,b,c,d){
fill(255, 19, 351);
rect(a,b,c,d,5);
fill(150, 0, 250);
rect(a-3,b,c+5,5,5);
rect(a-3,b+d-2,c+5,5,5);
fill(255, 139, 255,140);
rect(a+10,b+10,6,d-10-10,5);
};
var walls=[];
var ticker=0;
var newWall=function(){
walls.push([500,random(0,250)]);
};
var clouds=[[random(400,800),random(0,300),random(20,90),random(20,50)],[random(400,800),random(0,300),random(20,90),random(20,50)],[random(400,800),random(0,300),random(20,90),random(20,50)],[random(400,800),random(0,300),random(20,90),random(20,50)],[random(400,800),random(0,300),random(20,90),random(20,50)],[random(400,800),random(0,300),random(20,90),random(20,50)],[random(400,800),random(0,300),random(20,90),random(20,50)],[random(400,800),random(0,300),random(20,90),random(20,50)],[random(400,800),random(0,300),random(20,90),random(20,50)]];
var time=100;
var time2=100;
var ts=0.5;
var ts2=0.3;
var daytime=0;
var ds=0.5;
var graphics='fast';
var gameBackground=function(){
for(var h=0;h<400;h++){
stroke((time-daytime)*(h-20)/120, (55-daytime)*(h-20)/180, time2+time2-daytime);
line(0,h,400,h);
}
noStroke();
fill(0, 242, 255,100);
rect(0,0,400,400);
time+=ts;
time2+=ts2;
daytime+=ds;
if(time>255||time<100){
ts*=-1;
}
if(daytime>155||daytime<-20){
ds*=-1;
}
if(time2>255||time2<200){
ts2*=-1;
}
if(graphics==='fast'){
background(64, 222, 204);
}
for(var i in clouds){
if(start>0){
if(graphics==='fancy'){
for(var j =0;j< clouds[i][2]+clouds[i][0]/10;j++){
fill(j+200);
ellipse(clouds[i][0],clouds[i][1],(clouds[i][2]+clouds[i][0]/10)-j,clouds[i][3]-j*(clouds[i][3]/(clouds[i][2]+clouds[i][0]/10)));
}
}else{
fill(250);
ellipse(clouds[i][0],clouds[i][1],(clouds[i][2]+clouds[i][0]/10),clouds[i][3]);
}
clouds[i][0]+=-(clouds[i][0]+clouds[i][1])/400;
}
if(clouds[i][0]<-clouds[i][2]){
clouds[i]=[random(400,800),random(0,300),random(20,90),random(20,50)];
}
}
};
var tail=0;
var sprite=function(x,y){
translate(x,y);
rotate(catYM*2);
//grafico do gato
ellipse(0,0,40,10);
fill(143, 143, 143);
ellipse(0 - 15, 0 + 13, 14, 10);
ellipse(0 + 12, 0 + 13, 14, 10);
if(type===2){
if(mouseIsPressed||keys[32]){
tail++;
rotate(-tail);
ellipse(0 - 20, 0 + -7, 36, 7);
resetMatrix();
translate(x,y);
rotate(catYM*2.8);
}else{
tail-=10;
ellipse(0 - 20, 0 + -14, 6, 37);
}
if(tail<0){
tail=0;
}
if(tail>7){
tail=7;
}
}else{
rotate(30);
//rabo do gato
ellipse(0 - 28, 0 + 7, 36, 7);
rotate(-30);
}
//corpo do gato
ellipse(0, 0, 45, 22);
//manchas brancas
fill(255, 255, 255);
//tamanho das manchas
//ellipse(0 - 7, 0, 7, 20);
//ellipse(0 + 7, 0, 7, 20);
//ellipse(0 - 19, 0, 5, 11);
noStroke();
//translate(250, 200);
//scale(4);
// lenço
fill(219, 219, 65);
triangle( -19, -3, 24, 10, 2, -17);
//pontas enroladas
ellipse(25, 7, 4, 37);
ellipse(20, 7, 4, 37);
//arganel
fill(32, 128, 66);
ellipse( 22, 4, 9, 12);
fill(240, 245, 244);
ellipse( 22, 4, 10, 10);
//triangulo do arganel
stroke(236, 32, 34);
fill(240, 232, 234);
triangle(19, 2, 25, 2, 22, 9);
//noStroke();
stroke(29, 26, 186);
line(24, 4, 21, 5);
//globo do lenço
stroke(32, 128, 66);
fill(240, 245, 244);
ellipse(-1, -6, 12, 13);
fill(240, 245, 244);
stroke(236, 32, 34);
fill(242, 236, 234);
triangle(-5, -6, 2, -2.5, 2, -9);
stroke(29, 26, 186);
line(0, -4, -1, -8);
stroke(0, 0, 0);
//cor das orelhas
fill(153, 32, 110);
//orelhas do gato
triangle(0 + 5, 0 - 17, 0 + 5, 0 - 37, 0 + 15, 0 - 26);
triangle(0 + 18, 0 - 17, 0 + 33, 0 - 36, 0 + 33, 0 - 7);
//cor da cabeça do gato
fill(143, 143, 143);
//cabeça do gato
ellipse(0 + 19, 0 - 12, 31, 28);
//cor do focinho do gato
fill(237, 17, 17);
//tamanho e posição do focinho
triangle(0 + 14, 0 - 7, 0 + 18, 0 - 12, 0 + 22, 0 - 7);
//branco dos olhos
fill(255, 255, 255);
//olhos do gato
ellipse(0 + 13, 0 - 17, 11, 11);
ellipse(0 + 26, 0 - 17, 11, 11);
//cor da iris dos olhos
fill(32, 209, 23);
//iris dos olhos
ellipse(0 + 13, 0 - 17, 4, 9);
ellipse(0 + 26, 0 - 17, 4, 9);
//var boy = getImage("space/rocketship");
//image(boy,- 20, - 100, 80, 100);
resetMatrix();
};
var flap=function(){
catYM=-8;
};
var flap2=function(){
catYM-=1;
};
var contact=function(rect1,rect2){
var x1=rect1[0];
var y1=rect1[1];
var w1=rect1[2];
var h1=rect1[3];
var x2=rect2[0];
var y2=rect2[1];
var w2=rect2[2];
var h2=rect2[3];
var returnVal=false;
if(y2+h2>y1&&x2+w2>x1&&y2
returnVal=true;
}
if(y2+h2>y1&&x2+5-5x1+10-10){
returnVal=true;
}
if(y2+h2>y1&&x2+5-5x1+10-10){
returnVal=true;
}
return returnVal;
};
draw= function() {
gameBackground();
//para verificar clique do mouse
ms.r=false;
if(mouseIsPressed){
ms.stage=1;
}else if(ms.stage===1){
ms.r=true;
ms.stage=0;
}
//movimento do gato
if(start>0){
catY+=catYM;
catYM+=0.7;
}
if(catYM>20){
catYM=20;
}
//verificado para ver se o mouse foi clicado, então batida
if((ms.r||keyOnce[32])&&type===1){
if(keyOnce[32]&&start===0){
start=1;
walls=[];
}
flap();
}
if(start<0&&keyOnce[16]){
score=0;
start=1;
walls=[];
}
if((mouseIsPressed||keys[32])&&type===2){
if(keyOnce[32]&&start===0){
start=1;
}
if(start>0){
flap2();
}
}
if(keyOnce[68]){
if(hitbox){
hitbox=false;
}else{
hitbox=true;
}
}
//if((mouseIsPressed||keys[32])&&type===2&&start>0){
//flap2();
//}
//various text
textAlign(TOP,LEFT);
//"título"
if(start===0){
textFont(im,28);
fill(59, 87, 227);
text('Desbravagato',110,47);
fill(227, 59, 59);
text('Desbravagato',108,49);
text('Pressione SPACE p/ iniciar\nUse as setas p/ mudar as\ndefinições',14,297);
}
if(start<1){
//verificar se há alterações nas configurações
if(keyOnce[RIGHT]){
graphics='fast';
println('Graficos alterado p/ rápido.');
}
if(keyOnce[LEFT]){
graphics='fancy';
println('Gráficos alterado para fantasia.');
}
if(keyOnce[UP]){
type=1;
println('Movimento alterado para bater.');
}
if(keyOnce[DOWN]){
type=2;
println('Movimento alterado para deslizar.');
}
}
frameRate(50);
if(start!==0&&frameCount%120===0){
newWall();
if(start>0){
score+=1;
}
//println(Math.random());
}
if(start===-1){
if(type===1){
if(score>highscore[0]){
highscore[0]=score;
}
}
if(type===2){
if(score>highscore[1]){
highscore[1]=score;
}
}
start=-2;
}
for(var i in walls){
var cur=walls[i];
var catBox=[70,catY-35,64,50];
walls[i][0]+=-3;
//cor dos canos
fill(252, 0, 252);
//tamanho dos canos
pipe(cur[0],-10,40,cur[1]+5);
if(contact(catBox,[cur[0],0,40,cur[1]])){
start=-1;
}
if(type===1){
pipe(cur[0],cur[1]+140,40,400);
if(contact(catBox,[cur[0],cur[1]+140,40,400])){
start=-1;
}
}else{
pipe(cur[0],cur[1]+100,40,400);
if(contact(catBox,[cur[0],cur[1]+100,40,400])){
start=-1;
}
}
}
fill(34, 0, 255);
rect(0,380,400,20);
fill(40, 112, 97);
if(ticker<-50){
ticker=410;
}
ticker-=3;
for(var e=0;e<25;e++){
quad((ticker+e*40)%800-10,380,(ticker+e*40)%800+20-10,380,(ticker+e*40)%800-20-10,400,(ticker+e*40)%800-40-10,400);
}
if(start<0){
textFont(im,28);
fill(255, 15, 15);
catY=200;
catYM=0;
text('Pressione SHIFT para\ntentar novamente\nUse as setas para mudar\nas definições.\n\n\n\n\nPontuação: '+score+'\nMaior pontuação: '+highscore[0]+' (batida)\n'+highscore[1]+' (deslizar)',1,32);
}
if(catY+10<0||catY>365){
start=-1;
}
if(hitbox){
textFont(bold,18);
fill(125, 105, 105);
text('Cat Y-Cord: '+catY+'\nCat Y Momentum: '+catYM,5,40);
}
sprite(100,catY);
fill(25, 0, 255,100);
if(hitbox){
rect(70,catY-35,64,50);
}
if(start===1){
textFont(im,18);
fill(255, 0, 0);
text(score,8,20);
frameRate(50);
}
keyOnce=[];
};