原圖:
與別人配對後的圖:
程式碼:
int numPic=10;
int top = 1; // Select the front card
int buttom = 1; // Select the back card
void setup(){
PFont font;
size(600, 800);
font = loadFont("Univers-66.vlw");
textFont(font);
textSize(15);
rect(550, 200, 50, 50);
fill(0);
text("Next", 550, 240);
fill(255);
rect(550, 250, 50, 50);
fill(0);
text("Before", 550, 290);
fill(255);
rect(540, 400, 100, 50);
fill(0);
text("random", 540, 440);
fill(255);
rect(550, 500, 50, 50);
fill(0);
text("Next", 560, 550);
fill(255);
rect(550, 550, 50, 50);
fill(0);
text("Before", 550, 590);
fill(255);
smooth();
}
void draw() {
PImage imgTop = loadImage(top + "t.jpg");
PImage imgButtom = loadImage(buttom + "b.jpg");
image(imgTop,0, 0);
image(imgButtom, 0,400);
if (mousePressed == true) {
if (mouseButton == LEFT) {
if(mouseX>550 && mouseX<600 && mouseY>200 && mouseY<250){
top=top+1;
if(top==numPic)top=1;
}
if(mouseX>550 && mouseX<600 && mouseY>250 && mouseY<300){
top=top-1;
if(top==0)top=1;
}
if(mouseX>540 && mouseX<640 && mouseY>440 && mouseY<490){
frameRate(1);
top = int(random(1, numPic)); // Select the front card
buttom = int(random(1, numPic));
}
if(mouseX>550 && mouseX<600 && mouseY>500 && mouseY<550){
buttom=buttom+1;
if(buttom==numPic)buttom=1;
}
if(mouseX>550 && mouseX<600 && mouseY>550 && mouseY<600){
buttom=buttom-1;
if(buttom==0)buttom=1;
}
}
}
}
心得:我覺得最困難的地方在於化的部分,其他地方透過與同學討論和自己的研究,所以做得很有成就感,我相信這個技巧會對未來的專案有幫助


沒有留言:
張貼留言