2012年11月12日 星期一

Midtern

float x;
float y;
float easing = 0.05;
int score;
int savetime;
PImage bang, bang1, mouse,mouse2,mouse3;
int hole=0;
import ddf.minim.*;
AudioPlayer player;
Minim minim;
AudioPlayer bm;
void setup() {
  size(800, 600);
  noStroke();
  bang = loadImage("bang.png");
  bang1 = loadImage("bang1.png");
  mouse=loadImage("mouse1.jpg");
  mouse2=loadImage("mouse2.png");
  savetime = millis();
  minim = new Minim(this); 
  player = minim.loadFile("123.mp3");
  player.play();
}
void draw() {
  image(mouse, 0, 0);
  float targetX = mouseX;
  if (mousePressed) {
    image(bang1, mouseX-60, mouseY-60);
    }
    else {
      image(bang, mouseX-60, mouseY-60);
    }
    if(millis()%1000<30){  
      hole=int(random(1,10)); 
    }
  
   
   fill(255,0,0); 
   if(hole==1){   image(mouse2, 80, 25);  } 
   if(hole==2){   image(mouse2, 340, 25); } 
   if(hole==3){   image(mouse2, 600,25);  } 
   if(hole==4){   image(mouse2, 50,190);   } 
   if(hole==5){   image(mouse2, 350,190);   } 
   if(hole==6){   image(mouse2, 620,190);}
   if(hole==7){   image(mouse2, 40,370);   }
   if(hole==8){   image(mouse2, 350,370);   }
   if(hole==9){   image(mouse2,645,370);   }  
   fill(255,255,255); 
    fill(255,255,255);
    textSize(24);
    text("S  C  O  R  E   : "+score, 100, 550);
    int passtime = millis() - savetime;
    int gametime = 40-passtime/1000;
    textSize(24);
    text("T I M E : "+gametime,500,550);
    if( gametime <= 0 ){
    background(255,255,0);
    fill(255,0,0);
    textSize(30);
  
    text(" T I M E    IS    UP ",200,200);
    text(" Y O U R    S  C  O  R  E  :  "+score, 200,300);
 
 
 }
}
void mouseClicked(){
    if( mouseX-60>70 && mouseX-60<200 && mouseY-60>15 && mouseY-60<188 && hole==1){
       score=score+=100;
     }
     if( mouseX-60>320 && mouseX-60<470 && mouseY-60>15 && mouseY-60<188 && hole==2){
       score=score+=100;
     }
     if( mouseX-60>580 && mouseX-60<730 && mouseY-60>15 && mouseY-60<188 && hole==3){
       score=score+=100;
     }
     if( mouseX-60>30 && mouseX-60<180 && mouseY-60>170 && mouseY-60<353 && hole==4){
       score=score+=100;
     }
     if( mouseX-60>330 && mouseX-60<480 && mouseY-60>170 && mouseY-60<353 && hole==5){
       score=score+=100;
     }
     if( mouseX-60>600 && mouseX-60<750 && mouseY-60>170 && mouseY-60<353 && hole==6){
       score=score+=100;
     }
     if( mouseX-60>20 && mouseX-60<170 && mouseY-60>350 && mouseY-60<533 && hole==7){
       score=score+=100;
     }
     if( mouseX-60>330 && mouseX-60<480 && mouseY-60>350 && mouseY-60<533 && hole==8){
       score=score+=100;
     }
     if( mouseX-60>625 && mouseX-60<775 && mouseY-60>350 && mouseY-60<533 && hole==9){
       score=score+=100;
     }
     minim=new Minim(this);
     bm=minim.loadFile("kk.wav", 2048);
     bm.play();
   }

沒有留言:

張貼留言