
PImage [] imgN=new PImage[10];
float[] eggX=new float[100];
float[] eggY=new float[100];
boolean[] eggDie=new boolean[100];
void setup() {
size(800, 600);
for(int i=0;i<=9;i++) imgN[i] = loadImage(i+".jpg");
for(int i=0; i<100; i++) {
eggX[i]=random(100, 700);
eggY[i]=random(2000);
eggDie[i]=false;
}
}
int score=0;
void draw(){
background(255);
fill(255); rect(mouseX-50, mouseY-25, 100, 50);
for(int i=0; i<100; i++){
if(eggDie[i]) continue;
ellipse(eggX[i], eggY[i], 80, 100);
eggY[i]+=5;
if(eggY[i]>700) eggY[i]=-2000+600;
if(dist(mouseX, mouseY, eggX[i], eggY[i])<50 ){
eggDie[i]=true;
score+=100;
}
}
int now=score;
for(int i=0; i<7; i++){
image(imgN[(now%10)], 800-i*100, 100, 100,150);
now/=10;
}
}
櫻桃
PImage []img= new PImage[8];
float []cherryX=new float[8];
float []cherryY=new float[8];
float []cherryVX=new float[8];
float []cherryVY=new float[8];
void cherryReborn(int i){
cherryX[i]=random(800);
cherryY[i]= 700;
cherryVX[i]=random(8)-4;
cherryVY[i]=-40;
}
void setup(){
size(800,600);
for(int i=0;i<8;i++) img[i]=loadImage("cherry.png");
for(int i=0;i<8;i++) cherryReborn(i);
for(int i=0;i<10;i++) sword[i]=new PVector();
}
PVector [] sword = new PVector[10];
void draw(){
background(255);
for(int i=0;i<8;i++){
image(img[i], cherryX[i],cherryY[i],100,150);
cherryX[i]+=cherryVX[i];
cherryY[i]+=cherryVY[i];
cherryVY[i]+=0.98;
}
for(int i=9; i>0; i--){
sword[i].x=sword[i-1].x; sword[i].y=sword[i-1].y;
}
sword[0].x=mouseX; sword[0].y=mouseY;
for(int i=1;i<10;i++){
line(sword[i].x, sword[i].y, sword[i-1].x, sword[i-1].y);
}
}
沒有留言:
張貼留言