// author:Kana Tanaka ;) // Let's enjoy :) // Works cited: // http://www.d-improvement.jp/learning/processing/2011-a/09.html // https://yoppa.org/proga10/1190.html // https://gist.github.com/studiokura/f58e8edc5845c56ef4c4 int gseq; int fl=400; int flJ; int ct, ctT, bGc, score, RR, deg, cC=0;//counter count Text/backGround count/score/Restart Remove/clear Check int gL, gC; //goal Long goal Count how goal long float hGl; int Hx, Hy, Lx; //Human x,y Line int Hsw=10; int Hsh=30; int pUx, pUy; int[] cLx=new int[150]; //dann cabbinet Line x int[] hLx=new int[100]; int[] sUp=new int[1000]; //score up point int[] blf=new int[1000]; float ySpeed = 0; //initialize speed int yCk, gSpeed;//ySpeeds =check gSpeed=gameSpeed float Obx, Rx; //Obstacle x/rain x int Fls; //flashing int bexist; int gO; //When gameOver, use; int SS, SSM1, SSM2; //Select Stage Seclet Stage Mode // SS=1 past SS=2 future SS=3 now void setup() { size(500, 500); colorMode(HSB, 100, 100, 100); gameInit(); } void draw() { //game nagare background(100); Fls++; if (gseq==0) { gameTitle(); } else if (gseq==1) { gameSelect(); } else if (gseq==2) { gamePlay(); } else if (gseq==3) { gameOver(); } else { gameInit(); } } void gameInit() { //game settei gseq=0; yCk=0; Hx=100; Hy=flJ=400; gO=0; gC=0; score=0; ctT=0; bGc=500; rectMode(CENTER); textAlign(CENTER); for (int i=0; i<150; i++) { cLx[i]= int(random(100, 200)); } for (int i=0; i<100; i++) { hLx[i]=int(random(50, 100)); } for (int i=0; i<1000; i++) { sUp[i]=int(random(250, 400)); } for (int i=0; i<1000; i++) { blf[i]=1; } } void gameTitle() { //game Title fill(0,100,80); textSize(50); text("Future",width/2,150); text("and",width/2,200); text("Past",width/2,250); if ((Fls%60)<40) { textSize(20); fill(50, 100, 75); text("Enter key to start!", width/2, 360); fill(100); } } void gameSelect() { //rule select fill(0); textSize(10); triangle(430, 30, 425, 35, 435, 35); //up key rect(430, 40, 5, 8); text("UP key", 470, 40); triangle(430, 70, 425, 65, 435, 65);//down key rect(430, 60, 5, 8); text("DOWN key", 470, 65); fill(100); for (int i=0; i<2; i++) { stroke(0); rect(width/2, i*100+200, 400, 60); } if ((Fls%60)<30) { if (SS==1) { fill(30, 100, 100, 100); rect(width/2, 200, 400, 60); fill(100); } else if (SS==2) { fill(30, 100, 100, 100); rect(width/2, 300, 400, 60); fill(100); } } if (SSM1==1&&SSM2==1) { //seacret mode stroke(0); rect(width/2, 450, 400, 60); if (SS==3) { if ((Fls%60)<30) { fill(50, 100, 100); rect(width/2, 450, 400, 60); fill(100); } } fill(0); textSize(20); text("Now", width/2, 450); } fill(0); textSize(12); text("Use UP and DOWN, after Enter!", width/2, 110); text("Rules"+":"+"NOT falling so use UP", width/2, 410); textSize(20); text("Choise period!", width/2, 75 ); text("Past", width/2, 200); text("Future", width/2, 300); fill(100); } void gamePlay() { if (width*4/5>=Hx) { if (SS==1) { gSpeed=3; } else if (SS==2) { gSpeed=4; } else { gSpeed=5; } backgroundMove(); backgroundDisp(); playerMove(); playerDisp(); blockDisp(); blockMove(); goalDisp(); goalMove(); ct++; } else if (width*4/5=320)&&(i*500-ct*gSpeedHx)) { //地面に着いたら立て速度を0に Hy = flJ = 325; ySpeed=0; } if ((Hy==325)&&(i*500-ct*gSpeed+cLx[i]+15400) { ySpeed = 0; Hy =flJ= 400; } } } else { gseq=3; } for (int i=0; i<100; i++) { //rakka hanntei if ((Hy==400)&&(i*1000-ct*gSpeed+20+500+RR=gL-gC) { Hx++; if (width*4/5==Hx) { Hx=width*4/5; } } } void playerDisp() { if (ct%10<5) { human1(Hx, Hy-20); } else { human2(Hx, Hy-20); } } void blockMove() { if (Lx>0) { Lx-=3; } else { Lx=width; } bexist =0; for (int i=0; i<1000; i++) { if (blf[i] ==1) { fill(17, 100, 100); pUx=i*75-gSpeed*ct; pUy=sUp[i]; pointHitCheck(i, pUx, pUy); if (blf[i]==1) { if (SS==1) { //score item past:coin money noStroke(); ellipse(pUx, pUy, 10, 10); } else if (SS==2) { //future: star hope star(pUx, pUy); } else { //now: drop kadainiowareru ase to namida drop(pUx, pUy); } bexist =1; } } } } void blockDisp() { line(0, fl, width, fl); for (int i=0; i<150; i++) { line(i*500-ct*gSpeed, 325, i*500-ct*gSpeed+cLx[i], 325); } for (int i=0; i<100; i++) { //fall if (SS==1) { stroke(10, 50, 80); } else if (SS==2) { stroke(55, 50, 80); } else { stroke(30, 10, 80); } line(i*1000-ct*gSpeed+500+RR, 400, i*1000-ct*gSpeed+hLx[i]+500+RR, 400); stroke(0); } } void pointHitCheck(int ii, int pUx, int pUy) { if (!((pUx-5Hx)&&(pUyHy))) { //+-5shiteiru yo return; } sUp[ii]=-30; score +=10; if (ii<10) { score +=10; } } void goalDisp() { strokeWeight(10); if (SS==1) { stroke(8, 100, 95); } else if (SS==2) { stroke(66, 93, 28); } else { stroke(0, 100, 100); } line(0, height-5, int(hGl), height-5); //shi-ku bar ^-^ strokeWeight(1); stroke(0); fill(0, 100, 100); if (width*4/5height/2) Rx=0; } Rx+=0.25; fill(0, 0, 70); rect(width/2, 450, width, 100); } } void backgroundMove() { bGc++; if (bGc>600) { bGc=0; } } void scoreDisp() { fill(0); textSize(15); text("Score"+":"+score, 375, 50); text("key"+"="+"Jump", 100, 475); triangle(45, 465, 52, 470, 38, 470); rect(45, 475, 5, 10); noFill(); } void human1(int x, float y) { fill(100); if (gO>60) { stroke(100); } else { stroke(0); } ellipse(x, y, 10, 10); line(x, y+5, x, y+20); line(x-5, y+10, x+5, y+10); line(x-5, y+10, x-7, y+15); line(x+5, y+10, x+7, y+5); line(x-5, y+18, x, y+20); line(x+5, y+15, x+7, y+20); line(x, y+15, x+5, y+15); } void human2(int x, float y) { fill(100); if (gO>60) { stroke(100); } else { stroke(0); } ellipse(x, y, 10, 10); line(x, y+5, x, y+20); line(x-5, y+10, x+5, y+10); line(x-5, y+10, x-5, y+15); line(x+5, y+10, x+5, y+5); line(x-5, y+20, x, y+20); line(x+5, y+15, x+5, y+20); line(x, y+15, x+5, y+15); noFill(); } void star(int x, int y) { noStroke(); fill(20, 100, 100); beginShape(); vertex(x, y-10); vertex(x-6, y+7); vertex(x+9, y-4); vertex(x-9, y-4); vertex(x+6, y+7); endShape(CLOSE); } void drop(int x, int y) { noStroke(); fill(55, 100, 100); ellipse(x, y, 10, 10); triangle(x-5, y, x+5, y, x, y-8); } void rankDisp() { textSize(15); fill(100); if (score<100) { text("Oh...no..", width/2, 350); } else if (score<300) { text("Nice", width/2, 350); } else if (score<500) { text("Great!", width/2, 350); } else { text("Fantastic!!!", width/2, 350); } } void overFall() { human1(width/2-5, height/2-10); for (int i=0; i<1000; i++) { line(0, height+i*50-gO*3, width, height+i*50-gO*3); } } void keyPressed() { if (key==ENTER) { if (gseq==0) { gseq=1; } if (SS==1) { gseq=2; } else if (SS==2) { gseq=2; } else if (SS==3) { if (SSM1==1&&SSM2==1) { gseq=2; } } if (gseq==2&&cC==1) { gseq=0; cC=0; SS=0; gseq=4; } if (gseq==3) { gseq=4; ctT=0; } } if (key==CODED) { if (gseq==1) { if ((keyCode==UP)&&(SS>0)) { SS--; } else if ((keyCode==DOWN)&&(SS<3)) { SS++; } } if ((keyCode == UP)&&(Hy==flJ)) { ySpeed = -6; } } }