int i,d1=0,d2=0,d3=0,d4=0;
int score=0, lastTime=60;
int[] value = new int[50000];
color[] c=new color[4];
int a,count=0;
int tmp=0;
int startt;
void setup(){
size(500,600);
c[0]=color(255,0,0);
c[1]=color(0,255,0);
c[2]=color(0,0,255);
c[3]=color(255,255,255);
for(i=0;i<10000;i++)
{
a=int(random(0,3.99));
/*
if(i%25==0)
fill(255,0,0);
else if(i%30==0)
fill(0,255,0);
else if(i%40==0)
fill(0,0,255);
else
fill(255,255,255);
*/
count%=50000;
value[count++]=a;
}
}
void draw(){
background(255,200,100);
textSize(30);
fill(100,0,50);
text("Time:"+lastTime, 50,80);
text("Score:"+score, 0,220);
if(lastTime==0){
stop();
textFont(createFont("3", 60));
background(100,100,100);
fill(255,255,255);
text("Game Over ",120,250);
text("Your score:"+score,0,350);
}
lastTime=30-millis()/1000;
i=200;
for(int k=startt;k<startt+20;k++){
fill(c[value[k]]);
rect(i,100,80,80);
i+=20;
}
fill(255,200,100);
rect(0,100,200,80);
if(d1==1){
fill(128,128,128);
}else{
fill(255,0,0);
}
rect(160,400,80,80);
if(d2==1){
fill(128,128,128);
}else{
fill(0,255,0);
}
rect(280,400,80,80);
if(d3==1){
fill(128,128,128);
}else{
fill(0,0,255);
}
rect(160,500,80,80);
if(d4==1){
fill(128,128,128);
}else{
fill(255,255,255);
}
rect(280,500,80,80);
}
void keyPressed(){
if(key=='4'){
d1=1;
if(value[startt]==0){
startt++;
score+=10;
}
}else if(key=='5'){
d2=1;if(value[startt]==1){
startt++;
score+=10;
}
}else if(key=='r'){
d3=1;if(value[startt]==2)
{ startt++;
score+=10;
}
}else if(key=='t'){
d4=1;if(value[startt]==3)
{ startt++;
score+=10;
}
}
}
void keyReleased(){
if(key=='4'){
d1=0;
}else if(key=='5'){
d2=0;
}else if(key=='r'){
d3=0;
}else if(key=='t'){
d4=0;
}
}
遊戲開始:
60秒後遊戲結束:
沒有留言:
張貼留言