Week04-1
開啟processing,輸入以下程式碼
void setup(){
size(400,400);
}
int [][] card=new int[8][11];
void draw(){
background(255);
for(int i=0;i<8;i++){
for(int j=0;j<11;j++){
rect(j*30,i*50,30,50);
}
}
}
命名week04_1_uno_for_rect
牌的框架
Week04-2
開啟processing,輸入以下程式碼
void setup(){ size(400,400); } int [][] card=new int[8][11]; color[] C={#FF5555,#FFAA00,#55AA55,#5555FF}; void draw(){ background(255); for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ fill(C[i%4]); rect(j*30,i*50,30,50); } } }
命名week04_2_uno_color4
四種顏色的牌
Week04-3
開啟processing,輸入以下程式碼
void setup(){ size(400,400); } int [][] card=new int[8][11]; color[] C={#FF5555,#FFAA00,#55AA55,#5555FF}; void draw(){ background(255); for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ drawCard(j*30, i*50, C[i%4]); } } } void drawCard(int x, int y, color c){ stroke(128); //gray stroke fill(255); //white rect(x,y,32,50,7); //7是四角圓角弧度 //以上外框 noStroke(); fill(c); rect(x+3,y+3,32-5,50-5,4); }
命名week04_3_uno_better_card
把外框邊邊圓角弧度畫出來
Week04-4
開啟processing,輸入以下程式碼
void setup(){ size(400,400); } int [][] card=new int[8][11]; color[] C={#FF5555,#FFAA00,#55AA55,#5555FF}; void draw(){ background(255); for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ drawCard(j*30, i*50, C[i%4]); } } } void drawCard(int x, int y, color c){ stroke(128); //gray stroke fill(255); //white rect(x,y,32,50,7); //7是四角圓角弧度 //以上外框 noStroke(); fill(c); rect(x+3,y+3,32-5,50-5,4); //畫橢圓 pushMatrix(); fill(255); translate(x+16, y+25); rotate(radians(45)); ellipse(0,0,20,30); popMatrix(); }
命名week04_4_uno_ellipse
用電腦圖學畫橢圓
Week04-5
開啟processing,加入以下程式碼
textAlign(CENTER,CENTER); textSize(9); text("1", x+7, y+6); textSize(20); fill(c); text("1", x+16, y+22);
命名week04_5_uno_text_size
寫數字進去
Week04-6
開啟processing,輸入以下程式碼
void setup(){ size(400,400); myShuffle(); } void myShuffle(){ for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ cardN[i*11+j]=j; cardC[i*11+j]=C[i%4]; } } int a= int(random(88)), b= int(random(88)); int temp= cardN[a]; cardN[a]=cardN[b]; cardN[b]=temp; temp= cardC[a]; cardC[a]=cardC[b]; cardC[b]=temp; } //int [][] card=new int[8][11]; int [] cardN = new int[88]; //card number int [] cardC = new int[88]; //card color color[] C={#FF5555,#FFAA00,#55AA55,#5555FF}; void draw(){ background(255); for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ //drawCard(j*32, i*50, C[i%4],j); drawCard(j*32, i*50, cardC[i*11+j],cardN[i*11+j]); } } } void drawCard(int x, int y, color c,int n){ stroke(128); //gray stroke fill(255); //white rect(x,y,32,50,7); //7是四角圓角弧度 //以上外框 noStroke(); fill(c); rect(x+3,y+3,32-5,50-5,4); //4是四角圓角弧度 //畫橢圓 pushMatrix(); fill(255); translate(x+16, y+25); rotate(radians(45)); ellipse(0,0,20,30); popMatrix(); textAlign(CENTER,CENTER); textSize(9); text(""+n, x+7, y+6); textSize(20); fill(c); text(""+n, x+16, y+22); }
命名week04_6_uno_shuffle_washcard
洗牌一次
Week04-7
開啟processing,改變以下程式碼
void myShuffle(){ for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ cardN[i*11+j]=j; cardC[i*11+j]=C[i%4]; } } for(int i=0;i<10000;i++){ int a= int(random(88)), b= int(random(88)); int temp= cardN[a]; cardN[a]=cardN[b]; cardN[b]=temp; temp= cardC[a]; cardC[a]=cardC[b]; cardC[b]=temp; } }
命名week04_7_uno_shuffle_manytimes
迴圈多次洗牌
Week04-8
開啟processing,輸入以下程式碼
void setup(){ size(800,400); myShuffle(); } void myShuffle(){ for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ cardN[i*11+j]=j; cardC[i*11+j]=C[i%4]; } } for(int i=0;i<10000;i++){ int a= int(random(88)), b= int(random(88)); int temp= cardN[a]; cardN[a]=cardN[b]; cardN[b]=temp; temp= cardC[a]; cardC[a]=cardC[b]; cardC[b]=temp; } } //int [][] card=new int[8][11]; int [] cardN = new int[88]; //card number int [] cardC = new int[88]; //card color color[] C={#FF5555,#FFAA00,#55AA55,#5555FF}; void draw(){ background(255); for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ drawCard(j*32, i*50, cardC[i*11+j],cardN[i*11+j],32); } } drawCard(450,50,cardC[7],cardN[77],128); } void drawCard(int x, int y, color c,int n,int w){ float s= w/32.0; //scale size stroke(128); //gray stroke fill(255); //white rect(x,y,32*s,50*s,7*s); //7是四角圓角弧度 //以上外框 noStroke(); fill(c); rect(x+2.5*s, y+2.5*s, 32*s-5*s, 50*s-5*s,5*s); //5是四角圓角弧度 //畫橢圓 pushMatrix(); fill(255); translate(x+16*s, y+25*s); rotate(radians(45)); ellipse(0,0,20*s,30*s); popMatrix(); textAlign(CENTER,CENTER); textSize(9*s); text(""+n, x+7*s, y+6*s); textSize(20*s); fill(c); text(""+n, x+16*s, y+22*s); }
命名week04_8_uno_bigcard_interaction
大牌等比例放大
Week04-9
開啟processing,輸入以下程式碼
void setup(){ size(800,400); myShuffle(); } void myShuffle(){ for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ cardN[i*11+j]=j; cardC[i*11+j]=C[i%4]; } } for(int i=0;i<10000;i++){ int a= int(random(88)), b= int(random(88)); int temp= cardN[a]; cardN[a]=cardN[b]; cardN[b]=temp; temp= cardC[a]; cardC[a]=cardC[b]; cardC[b]=temp; } } //int [][] card=new int[8][11]; int [] cardN = new int[88]; //card number int [] cardC = new int[88]; //card color color[] C={#FF5555,#FFAA00,#55AA55,#5555FF}; void draw(){ background(255); if(mousePressed && mouseButton==RIGHT){ //cheat key ,peek all for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ drawCard(j*32, i*50, cardC[i*11+j],cardN[i*11+j],32); } } }else drawCard(50,50,#000000,99,128); //get card here for(int i=0;i<myCard;i++){ drawCard(430+40*i,50,cardC[i],cardN[i],128); } } int myCard=0; void mousePressed(){ if(mouseButton==LEFT) myCard++; } void drawCard(int x, int y, color c,int n,int w){ float s= w/32.0; //scale size stroke(128); //gray stroke fill(255); //white rect(x,y,32*s,50*s,7*s); //7是四角圓角弧度 //以上外框 noStroke(); fill(c); rect(x+2.5*s, y+2.5*s, 32*s-5*s, 50*s-5*s,5*s); //4是四角圓角弧度 //畫橢圓 pushMatrix(); fill(255); translate(x+16*s, y+25*s); rotate(radians(45)); ellipse(0,0,20*s,30*s); popMatrix(); textAlign(CENTER,CENTER); textSize(9*s); text(""+n, x+7*s, y+6*s); textSize(20*s); fill(c); text(""+n, x+16*s, y+22*s); }
命名week04_9_uno_poll_getcard
右鍵偷看牌 左鍵抽牌
Week04-10
開啟processing,輸入以下程式碼
void setup(){ size(850,850); myShuffle(); } void myShuffle(){ for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ cardN[i*11+j]=j; cardC[i*11+j]=C[i%4]; } } for(int i=0;i<10000;i++){ int a= int(random(88)), b= int(random(88)); int temp= cardN[a]; cardN[a]=cardN[b]; cardN[b]=temp; temp= cardC[a]; cardC[a]=cardC[b]; cardC[b]=temp; } } //int [][] card=new int[8][11]; int [] cardN = new int[88]; //card number int [] cardC = new int[88]; //card color color[] C={#FF5555,#FFAA00,#55AA55,#5555FF}; void draw(){ background(255); if(mousePressed && mouseButton==RIGHT){ //cheat key ,peek all for(int i=0;i<8;i++){ for(int j=0;j<11;j++){ drawCard(j*32, i*50, cardC[i*11+j],cardN[i*11+j],32); } } }else drawCard(50,50,#000000,99,128); //get card here for(int i=0;i<myCard;i++){ if(i%4==0) drawCard(430 +40*i/4,50,cardC[i],cardN[i],128); if(i%4==1) drawCard(630-40 +40*i/4,350,cardC[i],cardN[i],128); if(i%4==2) drawCard(430-80 +40*i/4,650,cardC[i],cardN[i],128); if(i%4==3) drawCard(230-120 +40*i/4,350,cardC[i],cardN[i],128); } } int myCard=0; void mousePressed(){ if(mouseButton==LEFT) myCard++; } void drawCard(int x, int y, color c,int n,int w){ float s= w/32.0; //scale size stroke(128); //gray stroke fill(255); //white rect(x,y,32*s,50*s,7*s); //7是四角圓角弧度 //以上外框 noStroke(); fill(c); rect(x+2.5*s, y+2.5*s, 32*s-5*s, 50*s-5*s,5*s); //4是四角圓角弧度 //畫橢圓 pushMatrix(); fill(255); translate(x+16*s, y+25*s); rotate(radians(45)); ellipse(0,0,20*s,30*s); popMatrix(); textAlign(CENTER,CENTER); textSize(9*s); text(""+n, x+7*s, y+6*s); textSize(20*s); fill(c); text(""+n, x+16*s, y+22*s); }
命名week04_A_uno_4player
出現四個人的卡牌
沒有留言:
張貼留言