int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0;
int SPEED = 20;
long grade=0;
int rtime;
int q;
int[] lag,site;
float z;
PImage y;
PFont myFont;
void setup()
{
myFont = createFont("FFScala", 32);
textFont(myFont);
size(600,700);
background(255,255,255);
//宣告
lag=new int[10];
site = new int[10];
y=loadImage("Mouse.jpg");
}
void draw()
{
if(millis()>30000){
delay(3000);
exit();
}
if((millis()/1000)>=20) SPEED = 10;
q++;
background(255);
fill(255,0,255);
text("Grade : " + grade, 400, 600);
text("剩餘時間 : " + (30-(millis()/1000)), 400, 650);
if(lag[0]!=0){
lag[0]--;
image(y, 70,60);
}else image(y, 70,80);
if(lag[1]!=0){
lag[1]--;
image(y, 220,60);
}else image(y, 220,80);
if(lag[2]!=0){
lag[2]--;
image(y, 370,60);
}else image(y, 370,80);
if(lag[3]!=0){
lag[3]--;
image(y, 70,210);
}else image(y, 70,230);
if(lag[4]!=0){
lag[4]--;
image(y, 220,210);
}else image(y, 220,230);
if(lag[5]!=0){
lag[5]--;
image(y, 370,210);
}else image(y, 370,230);
if(lag[6]!=0){
lag[6]--;
image(y, 70,360);
}else image(y, 70,380);
if(lag[7]!=0){
lag[7]--;
image(y, 220,360);
}else image(y, 220,380);
if(lag[8]!=0){
lag[8]--;
image(y, 370,360);
}else image(y, 370,380);
rtime=(int)random(0,9.99);
if((q%SPEED)==0)
switch(rtime)
{
case 0: image(y, 70,60);lag[0]=150; break;
case 1: image(y, 220,60);lag[1]=150; break;
case 2: image(y, 370,60);lag[2]=150; break;
case 3: image(y, 70,210);lag[3]=150; break;
case 4: image(y, 220,210);lag[4]=150; break;
case 5: image(y, 370,210);lag[5]=150; break;
case 6: image(y, 70,360);lag[6]=150; break;
case 7: image(y, 220,360);lag[7]=150; break;
case 8: image(y, 370,360);lag[8]=150; break;
}
if(lag[0] == 0) image(y, 70,80);
if(lag[1] == 0) image(y, 220,80);
if(lag[2] == 0) image(y, 370,80);
if(lag[3] == 0) image(y, 70,230);
if(lag[4] == 0) image(y, 220,230);
if(lag[5] == 0) image(y, 370,230);
if(lag[6] == 0) image(y, 70,380);
if(lag[7] == 0) image(y, 220,380);
if(lag[8] == 0) image(y, 370,380);
if(a==1)
{
fill(255,0,0);
}
else
{
fill(0,255,0);
}
ellipse(100,150,100,100);
if(b==1)
{
fill(255,0,0);
}
else
{
fill(0,255,0);
}
ellipse(250,150,100,100);
if(c==1)
{
fill(255,0,0);
}
else
{
fill(0,255,0);
}
ellipse(400,150,100,100);
if(d==1)
{
fill(255,0,0);
}
else
{
fill(0,255,0);
}
ellipse(100,300,100,100);
if(e==1)
{
fill(255,0,0);
}
else
{
fill(0,255,0);
}
ellipse(250,300,100,100);
if(f==1)
{
fill(255,0,0);
}
else
{
fill(0,255,0);
}
ellipse(400,300,100,100);
if(g==1)
{
fill(255,0,0);
}
else
{
fill(0,255,0);
}
ellipse(100,450,100,100);
if(h==1)
{
fill(255,0,0);
}
else
{
fill(0,255,0);
}
ellipse(250,450,100,100);
if(i==1)
{
fill(255,0,0);
}
else
{
fill(0,255,0);
}
ellipse(400,450,100,100);
}
void keyPressed(){
if(key=='1')
{
g=1;
if(lag[6]!=0){
lag[6]=0;
grade++;
println("Grade : " + grade ) ;
}
}
else if(key=='2')
{
h=1;
if(lag[7]!=0){
lag[7]=0;
grade++;
println("Grade : " + grade ) ;
}
}
else if(key=='3')
{
i=1;
if(lag[8]!=0){
lag[8]=0;
grade++;
println("Grade : " + grade ) ;
}
}
else if(key=='4')
{
d=1;
if(lag[3]!=0){
lag[3]=0;
grade++;
println("Grade : " + grade ) ;
}
}
else if(key=='5')
{
e=1;
if(lag[4]!=0){
lag[4]=0;
grade++;
println("Grade : " + grade ) ;
}
}
else if(key=='6')
{
f=1;
if(lag[5]!=0){
lag[5]=0;
grade++;
println("Grade : " + grade ) ;
}
}
else if(key=='7')
{
a=1;
if(lag[0]!=0){
lag[0]=0;
grade++;
println("Grade : " + grade ) ;
}
}
else if(key=='8')
{
b=1;
if(lag[1]!=0){
lag[1]=0;
grade++;
println("Grade : " + grade ) ;
}
}
else if(key=='9')
{
c=1;
if(lag[2]!=0){
lag[2]=0;
grade++;
println("Grade : " + grade ) ;
}
}
}
void keyReleased(){
if(key=='1')
{
g=0;
}
else if(key=='2')
{
h=0;
}
else if(key=='3')
{
i=0;
}
else if(key=='4')
{
d=0;
}
else if(key=='5')
{
e=0;
}
else if(key=='6')
{
f=0;
}
else if(key=='7')
{
a=0;
}
else if(key=='8')
{
b=0;
}
else if(key=='9')
{
c=0;
}
}
沒有留言:
張貼留言