2012年11月12日 星期一

Midtern

1.圖片說明
 (1)開始畫面 按PLAY按紐
 (2)第一關
 (3)共有五個相異點 點出即會框出來
(4)找出五個就過關 按NEXT 
 (5)共有五個相異點 點出即會框出來
 (6)過關 即結束
2.程式碼
PImage img1, img2, img3,img4,img5; //宣告畫面
int now=1;
int a01=0,a02=0,a03=0,a04=0,a05=0,z01=0,e01=0,b01=0,b02=0,b03=0,b04=0,b05=0;
int x,y,z,c;
import ddf.minim.*;  //音樂
AudioPlayer player;
Minim minim;

void setup(){
minim=new Minim(this);
player=minim.loadFile("159.mp3", 2048);
player.play();

size(700,500);  //畫面大小
img1=loadImage("img1.jpg");
img2=loadImage("img2.jpg");
img3=loadImage("img3.jpg");
img4=loadImage("img4.jpg");
img5=loadImage("img5.jpg");
}
void show1()
{image(img1,0,0);}
void show2()
{image(img2,0,0);}
void show3()
{image(img3,0,0);}
void show4()
{image(img4,0,0);}
void show5()
{image(img5,0,0);}
void draw(){
if(now==1){
show1();
if(mouseX>53 && mouseX<353 && mouseY>163 && mouseY<259 && mousePressed){
now=2;
}}
if(now==2){
background(0);
show2();
if(mouseX>475 && mouseX<495 && mouseY>75 && mouseY<97 && mousePressed)
{a01=1;}
if(mouseX>488 && mouseX<512 && mouseY>131 && mouseY<150 && mousePressed)
{a02=1;}
if(mouseX>590 && mouseX<635 && mouseY>178 && mouseY<202 && mousePressed)
{a03=1;}
if(mouseX>400 && mouseX<427 && mouseY>200 && mouseY<255 && mousePressed)
{a04=1; }
if(mouseX>533 && mouseX<554 && mouseY>290 && mouseY<305 && mousePressed)
{a05=1;}

if(a01==1)
{line(475,75,495,75);
line(475,75,475,97);
line(475,97,495,97);
line(495,97,495,75);
strokeWeight(4);
stroke(0,0,0);}

if(a02==1)
{line(488,131,512,131);
line(488,131,488,150);
line(488,150,512,150);
line(512,150,512,131);
strokeWeight(4);
stroke(0,0,0);}

if(a03==1)
{line(590,178,635,178);
line(590,178,590,202);
line(590,202,635,202);
line(635,202,635,178);
strokeWeight(4);
stroke(0,0,0);}

if(a04==1)
{line(400,200,427,200);
line(400,200,400,255);
line(400,255,427,255);
line(427,255,427,200);
strokeWeight(4);
stroke(0,0,0);}

if(a05==1)
{line(533,290,554,290);
line(533,290,533,305);
line(533,305,554,305);
line(554,305,554,290);
strokeWeight(4);
stroke(0,0,0);}


if(a01==1 && a02==1 && a03==1 && a04==1 && a05==1 )
{now=3; }
}


if(now==3){
show3();
if(mouseX>519 && mouseX<673 && mouseY>123 && mouseY<188 && mousePressed)
{z01=1;}
if(z01==1)
{now=4;}
}

if(now==4){
show4();
if(mouseX>434 && mouseX<464 && mouseY>103 && mouseY<128 && mousePressed)
{b01=1;}
if(mouseX>391 && mouseX<432 && mouseY>184 && mouseY<223 && mousePressed)
{b02=1;}
if(mouseX>380 && mouseX<400 && mouseY>355 && mouseY<384 && mousePressed)
{b03=1;}
if(mouseX>355 && mouseX<379 && mouseY>405 && mouseY<432 && mousePressed)
{b04=1;}
if(mouseX>441 && mouseX<457 && mouseY>480 && mouseY<498 && mousePressed)
{b05=1;}

if(b01==1)
{line(434,103,464,103);
line(434,103,434,128);
line(434,128,464,128);
line(464,128,464,103);
strokeWeight(4);
stroke(255,0,0);}

if(b02==1)
{line(391,184,432,184);
line(391,184,391,223);
line(391,223,432,223);
line(432,223,432,184);
strokeWeight(4);
stroke(255,0,0);}

if(b03==1)
{line(380,355,400,355);
line(380,355,380,384);
line(380,384,400,384);
line(400,384,400,355);
strokeWeight(4);
stroke(255,0,0);}

if(b04==1)
{line(355,405,379,405);
line(355,405,355,432);
line(355,432,379,432);
line(379,432,379,405);
strokeWeight(4);
stroke(255,0,0);}

if(b05==1)
{line(441,480,457,480);
line(441,480,441,498);
line(441,498,457,498);
line(457,498,457,480);
strokeWeight(4);
stroke(255,0,0);}

if(b01==1 && b02==1 && b03==1 && b04==1 && b05==1)
{now=5; }
}
if(now==5){
show5();
if(mouseX>36 && mouseX<149 && mouseY>94 && mouseY<152 && mousePressed)
{e01=1;}

if(e01==1)
{exit();}

}}

4.影片

5.心得感想
這次期中作業,可以把以前到現在老師所教的程式做結合
不是單單的一個大作業,因為除了老師在課堂上教的以外
還需自己找程式,或是組上討論,問同學
這個作業會讓我一直想繼續做下去,想改到最好
跟以前的情況不一樣
很喜歡老師教的風格、方法
這個作業可以因增加難度、程式一直延續下去
關卡、介面風格等等都可以更精進

1 則留言: