1.貼圖
2.程式碼
PImage tt0,tt1,tt2; float bangAngle; int startT=0; int value = 0; int score=0, lastTime=60; PImage img1,big,img2; int now=1; import ddf.minim.*; AudioPlayer player,aaa,cheers; Minim minim; int a=231,b=204,c=185 ; int b1=204,c1=185 ; int b2=204,c2=185 ; int b3=204,c3=185 ; int b4=204,c4=185 ; int b5=204,c5=185 ; int b6=204,c6=185 ; void setup(){ size(500,500); tt0=loadImage("tt0.png"); tt1=loadImage("tt1.png"); tt2=loadImage("tt2.png"); img1=loadImage("b1.png"); big=loadImage("big.png"); img2=loadImage("gameover.png"); } void show1(){ image(img1,0,0); } void show2(){ image(big,0,0); } void show3(){ image(img2,0,0); } void draw() { fill(value); rect(100, 100, 100, 100); size(500,500); int m=millis(); background(255,255,255); image(big,0,0,500,500); textSize(30); fill(m/10%10,m/10%10,m/10%255); text("Time:"+lastTime, 10,40); text("Score:"+score, 330,40); if(lastTime&rt;0) lastTime=60-millis()/1000; else lastTime=0; b-=3;c-=3; b1-=2;c1-=2; b2-=0.1;c2-=0.1; b3-=6;c3-=6; b4-=7;c4-=7; b5-=4;c5-=4; b6-=5;c6-=5; noStroke(); fill(a,b,c); ellipse(300,300,20,20); noStroke(); fill(a,b,c); ellipse(200,130,20,20); noStroke(); fill(a,b1,c1); ellipse(360,230,20,20); noStroke(); fill(a,b2,c2); ellipse(192,270,20,20); noStroke(); fill(a,b3,c3); ellipse(170,190,10,10); noStroke(); fill(a,b4,c4); ellipse(150,160,18,18); noStroke(); fill(a,b5,c5); ellipse(130,210,30,30); noStroke(); fill(a,b6,c6); ellipse(220,250,20,20); noStroke(); fill(a,b1,c1); ellipse(240,150,17,17); noStroke(); fill(a,b2,c2); ellipse(300,190,20,20); noStroke(); fill(a,b4,c4); ellipse(280,260,30,30); noStroke(); fill(a,b5,c5); ellipse(270,390,10,10); noStroke(); fill(a,b6,c6); ellipse(235,330,30,30); noStroke(); fill(a,b,c); ellipse(150,370,20,20); noStroke(); fill(a,b1,c1); ellipse(100,250,15,15); noStroke(); fill(a,b2,c2); ellipse(300,300,20,20); noStroke(); fill(a,b3,c3); ellipse(350,350,30,30); if (b<0 ) { b=255; c=255;} if (b1<0 ) { b1=255; c1=255;} if (b2==0 ) { b2=255; c2=255;} if (b3<0 ) { b3=255; c3=255;} if (b4<0 ) { b4=255; c4=255;} if (b5<0 ) { b5=255; c5=255;} if (b6<0 ) { b6=255; c6=255;} if(mouseX&rt;290 && mouseX < 310 && mouseY&rt;290 && mouseY<310 && mousePressed)image(tt2,290,280,30,30);//又嘴 else if(mouseX&rt;190 && mouseX < 210 && mouseY&rt;120 && mouseY<140 && mousePressed)image(tt2,190,115,30,30);//額頭 else if(mouseX&rt;350 && mouseX < 370 && mouseY&rt;220 && mouseY<240 && mousePressed)image(tt2,350,210,30,30);//右邊 else if(mouseX&rt;180 && mouseX < 200 && mouseY&rt;260 && mouseY<280 && mousePressed)image(tt2,180,250,30,30);//左 else if(mouseX&rt;160 && mouseX < 180 && mouseY&rt;180 && mouseY<200 && mousePressed)image(tt2,160,180,20,20); else if(mouseX&rt;140 && mouseX < 160 && mouseY&rt;150 && mouseY<170 && mousePressed)image(tt2,140,145,25,25); else if(mouseX&rt;120 && mouseX < 140 && mouseY&rt;200 && mouseY<220 && mousePressed)image(tt2,115,185,45,45); else if(mouseX&rt;210 && mouseX < 230 && mouseY&rt;240 && mouseY<260 && mousePressed)image(tt2,210,235,27,27); else if(mouseX&rt;230 && mouseX < 250 && mouseY&rt;140 && mouseY<150 && mousePressed)image(tt2,230,140,26,26); else if(mouseX&rt;290 && mouseX < 310 && mouseY&rt;180 && mouseY<200 && mousePressed)image(tt2,290,180,25,25); else if(mouseX&rt;270 && mouseX < 290 && mouseY&rt;250 && mouseY<270 && mousePressed)image(tt2,260,235,45,45); else if(mouseX&rt;260 && mouseX < 280 && mouseY&rt;380 && mouseY<400 && mousePressed)image(tt2,260,380,17,17); else if(mouseX&rt;220 && mouseX < 245 && mouseY&rt;320 && mouseY<340 && mousePressed)image(tt2,220,300,49,49); else if(mouseX&rt;140 && mouseX < 160 && mouseY&rt;360 && mouseY<380 && mousePressed)image(tt2,140,350,30,30); else if(mouseX&rt;90 && mouseX < 110 && mouseY&rt;240 && mouseY<260 && mousePressed)image(tt2,90,235,26,26); else if(mouseX&rt;290 && mouseX < 310 && mouseY&rt;290 && mouseY<310 && mousePressed)image(tt2,290,290,30,30); else if(mouseX&rt;340 && mouseX < 360 && mouseY&rt;340 && mouseY<360 && mousePressed)image(tt2,325,325,41,41); if(now==1){ show1(); if(mouseX&rt;200 && mouseX<330 && mouseY&rt;300 && mouseY<430 && mousePressed){ now=2; } } if(lastTime==0) //當時間=0,秀出得分 { stop(); show3(); textFont(createFont("Calibri", 40)); fill(128,0,0); text("Your score:"+score,150,300); // cheers=minim.loadFile("cheers.wav", 2048); //cheers.play(); } } void mousePressed() { if ( mouseX&rt;180 && mouseX < 200 && mouseY&rt;260 && mouseY<280) { value = 255; score+=10; minim=new Minim(this); aaa=minim.loadFile("aaa.wav", 2048); //戳到泡泡時播放音效 aaa.play(); } else if (mouseX&rt;350 && mouseX < 370 && mouseY&rt;220 && mouseY<240) { value = 255; score+=10; minim=new Minim(this); aaa=minim.loadFile("aaa.wav", 2048); //戳到泡泡時播放音效 aaa.play(); } else if (mouseX&rt;190 && mouseX < 210 && mouseY&rt;120 && mouseY<140) { value = 255; score+=10; minim=new Minim(this); aaa=minim.loadFile("aaa.wav", 2048); //戳到泡泡時播放音效 aaa.play(); } else if (mouseX&rt;290 && mouseX < 310 && mouseY&rt;290 && mouseY<310) { value = 255; score+=10; minim=new Minim(this); aaa=minim.loadFile("aaa.wav", 2048); //戳到泡泡時播放音效 aaa.play(); } else if (mouseX&rt;160 && mouseX < 180 && mouseY&rt;180 && mouseY<200) { value = 255; score+=100; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;140 && mouseX < 160 && mouseY&rt;150 && mouseY<170) { value = 255; score+=10; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;120 && mouseX < 140 && mouseY&rt;200 && mouseY<220) { value = 255; score+=1; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;210 && mouseX < 230 && mouseY&rt;240 && mouseY<260) { value = 255; score+=10; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;230 && mouseX < 250 && mouseY&rt;140 && mouseY<150) { value = 255; score+=10; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;290 && mouseX < 310 && mouseY&rt;180 && mouseY<200) { value = 255; score+=10; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;270 && mouseX < 290 && mouseY&rt;250 && mouseY<270) { value = 255; score+=1; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;260 && mouseX < 280 && mouseY&rt;380 && mouseY<400) { value = 255; score+=100; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;220 && mouseX < 245 && mouseY&rt;320 && mouseY<340) { value = 255; score+=1; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;90 && mouseX < 110 && mouseY&rt;240 && mouseY<260) { value = 255; score+=10; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;140 && mouseX < 160 && mouseY&rt;360 && mouseY<380) { value = 255; score+=10; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;290 && mouseX < 310 && mouseY&rt;290 && mouseY<310) { value = 255; score+=10; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else if (mouseX&rt;340 && mouseX < 360 && mouseY&rt;340 && mouseY<360) { value = 255; score+=1; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} else { value = 0; score-=50; minim=new Minim(this);aaa=minim.loadFile("aaa.wav", 2048);aaa.play();} }3.遊戲規則
點到痘痘就可得分
大顆1分
小顆100分
點到臉扣50分
點到痘痘會有"啵~"的聲音
限時60秒
時間歸零即遊戲結束
4.心得
完成一個作品蠻有成就感的,雖然沒有做到很完美,但是一步步寫出來,遇到問題一起討論然後解決他,感覺真的有學到東西。
沒有留言:
張貼留言