2014年9月29日 星期一

第三週課堂作業


貼圖
跟著滑鼠跑的奇奇蒂蒂



貼圖背景



加入音檔
滑鼠按下有鳥叫聲



發射蛋攻擊小鳥




PImage img,imgBG;
import ddf.minim.*;
Minim minim;
AudioPlayer bird;
float eggX=750, eggY=550, eggVX, eggVY, flying=0;
void setup(){
  size(800,600,P3D);
  minim = new Minim(this);
  
  bird= minim.loadFile("bird.wav");
  
  img= loadImage("bird.png");
  imgBG= loadImage("tree.jpg");
  imgBG.resize(800,600);
  imageMode(CENTER);
  
}
void draw(){
  background(imgBG);
  image(img,mouseX,mouseY,100,100);
  if(flying>0){
    ellipse(eggX,eggY,50,50);
    eggX+=eggVX;
    eggY+=eggVY;
    flying--;
  }
}
void mousePressed(){
  eggX=750; eggY=550; flying=30;
  eggVX=(mouseX-eggX)/30;
  eggVY=(mouseY-eggY)/30;
  bird.rewind();
  bird.play();
}






沒有留言:

張貼留言