2012年11月13日 星期二

Midtern

1.程式碼

int now=1;
int a=874,b=874;
PImage img0,img1,img2,img3,img4,img5,img6,img7,img8;
import ddf.minim.*;
AudioPlayer backmusic,food2,touch2 ;
Minim minim;
void setup(){  
size(768,1024); 
img0=loadImage("background0.jpg"); 
img1=loadImage("cat1.jpg");  
img2=loadImage("food.jpg"); 
img3=loadImage("touch.jpg"); 
img4=loadImage("home.gif"); 
img5=loadImage("cat2.jpg");
img6=loadImage("cat3.jpg");
img7=loadImage("right.gif");
img8=loadImage("left.gif");
minim=new Minim(this);
food2=minim.loadFile("food2.mp3", 2048);
touch2=minim.loadFile("touch2.mp3", 2048);
backmusic=minim.loadFile("backmusic.mp3", 2048);
backmusic.play();
}
void show1(){
  image(img0,0,0);
}
void show2(){
image(img1,0,0);  
image(img2,0,a); 
image(img3,618,b);  
image(img4,660,0); 
image(img7,700,560); 
}
void show3(){
image(img5,0,0);  
image(img2,0,a); 
image(img3,618,b);  
image(img4,660,0); 
image(img7,700,500);
image(img8,10,500); 
}
void show4(){
image(img6,0,0);  
image(img2,0,a); 
image(img3,618,b);  
image(img4,660,0); 
image(img8,10,560); 
}
void draw(){
if(now==1){
    show1(); 
    if(mousePressed&&mouseX>=248&&mouseX<=483&&mouseY>=544&&mouseY<=635){
    now=2; 
}
}
if(now==2)
    show2();
  if(mousePressed&&mouseX>=0&&mouseX<=150&&mouseY>=874&&mouseY<=1024)  {
    food2.play();
    a=1024;
  }
  if(mousePressed&&mouseX>=618&&mouseX<=768&&mouseY>=874&&mouseY<=1024) {
    touch2.play();
    b=1024;
  }
  if(mousePressed&&mouseX>=618&&mouseX<=768&&mouseY>=0&&mouseY<=150) {
    now=1;
    a=874;
    b=874;
  }
  if(mousePressed&&mouseX>=618&&mouseX<=768&&mouseY>=500&&mouseY<=600) now=3;
  if(now==3)
     show3();
  if(mousePressed&&mouseX>=0&&mouseX<=150&&mouseY>=874&&mouseY<=1024){
    food2.play();
    a=1024;
  }
  if(mousePressed&&mouseX>=618&&mouseX<=768&&mouseY>=874&&mouseY<=1024){
    touch2.play();
    b=1024;
  }
  if(mousePressed&&mouseX>=618&&mouseX<=768&&mouseY>=0&&mouseY<=150){
    now=1;
    a=874;
    b=874;
  }
  if(mousePressed&&mouseX>=0&&mouseX<=150&&mouseY>=500&&mouseY<=600) now=2;
  if(mousePressed&&mouseX>=618&&mouseX<=768&&mouseY>=500&&mouseY<=550) now=4;
  if(now==4)
     show4();
  if(mousePressed&&mouseX>=0&&mouseX<=150&&mouseY>=874&&mouseY<=1024){
    food2.play();
    a=1024;
  }
  if(mousePressed&&mouseX>=618&&mouseX<=768&&mouseY>=874&&mouseY<=1024){
    touch2.play();
    b=1024;
  }
  if(mousePressed&&mouseX>=618&&mouseX<=768&&mouseY>=0&&mouseY<=150){
    now=1;
    a=874;
    b=874;
  }
  if(mousePressed&&mouseX>=0&&mouseX<=150&&mouseY>=550&&mouseY<=600) now=3;
  }






沒有留言:

張貼留言