期中作業
int screen=0;
PImage img,img2,imgPooh,imgHunny,img3,img4;
float[] angle=new float[15];
float[] R=new float [15];
float poohX=400,poohY=250;
void setup() {
size(1000, 656);
img=loadImage("Winnie the Pooh.png");
img2=loadImage("Taiwan.PNG");
imgPooh=loadImage("pooh.png");
imgHunny=loadImage("hunny.png");
img3=loadImage("win.png");
img4=loadImage("Game Over.png");
fill(0);
textSize(48);
for (int i=0; i<15; i++) {
R[i]=350+random(500);
angle[i]=random(PI*2);
}
}
int score=0;
void draw() {
if (screen==0) {
image(img, 0, 0);
//text("Start Wellcome", 100, 100);
} else if(screen==1) {
image(img2, 0, 0);
// background(255);
fill(0);
textSize(40);
text("Score:"+score, 10, 100);
fill(255);
image(imgPooh,poohX,poohY,200,200);
//rect(250, 250, 100, 100);
for (int i=0; i<15; i++) {
float x=500+R[i]*cos(angle[i]), y=300+R[i]*sin(angle[i]);
image(imgHunny,x,y,50,50);
//ellipse(x, y, 50, 50);
R[i]-=2;
if (dist(mouseX, mouseY, x, y)<25) {
R[i] = 350+random(500);
score+=10;
}
if (R[i]<75) {
background(255, 0, 0);
R[i] = 350+random(500);
score-=10;
}
if(score==100) screen=2;
if(score==-100) screen=3;
}
}
else if(screen==2){
image(img3, 0, 0);
}
else if(screen==3){
image(img4, 0, 0);
}
}
void keyPressed() {
if (screen==0) screen=1;
}
➤開始圖片
➤遊戲玩法:滑鼠按蜂蜜罐
➤YOU Win
➤YOU lost
沒有留言:
張貼留言