嘎 嘎嘎嘎嘎
速寫本 → 添加庫文件 → 下載Sound



氣球程式碼
PImage imgBalloon;
float []balloonX = new float[200];
float []balloonY = new float[200];
float []balloonsize = new float[200];
int nowN=0;
void setup(){
size(500,400);
imgBalloon = loadImage("balloon,png");
}
void draw(){
background(255);
for(int i=0;i<nowN;i++){
image(imgBalloon,balloonX[i],balloonY[i],balloonsize[i],balloonsize[i]/2*3);
if(mousePressed) println("mousePressed in draw()");
if(balloonY[i]>0) balloonY[i]--;
}
if(mousePressed) setBalloon(balloonsize[nowN-1]*1.01, nowN-1);
}
void setBalloon(float size, int i){
balloonsize[i]=size;
balloonX[i]= mouseX-balloonsize[i]/2;
balloonY[i]= mouseY-balloonsize[i]/2*3;
}
void mousePressed(){
setBalloon(10,nowN);
nowN++;
}
沒有留言:
張貼留言