2023年10月5日 星期四

學校滑鼠有夠爛 - Week04 - 互動技術🦆

Week04

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*32,i*50,32,50);
    }
  }
}






void setup(){
  size(400,400);
}
int [][] card = new int[8][11];
color [] C = {#FF5555,#FFAA00,#55AA55,#5555FF};//大寫C
void draw(){
  background(255);
  for(int i=0;i<8;i++){
    for(int j=0;j<11;j++){
      fill(C[i%4]);//大寫C
      rect(j*32,i*50,32,50);
    }
  }
}







//邊邊有弧度
void setup(){
  size(400,400);
}
int [][] card = new int[8][11];
color [] C = {#FF5555,#FFAA00,#55AA55,#5555FF};//大寫C
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]);
      
    }
  }
}
void drawCard(int x,int y,color c){
  stroke(128);
  fill(255);
  rect(x,y,32,50,7);
  noStroke();
  fill(c);
  rect(x+3,y+3,32-5,50-5,4);
}




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*32,i*50,C[i%4]);
      
    }
  }
}
void drawCard(int x,int y,color c){
  stroke(128);
  fill(255);
  rect(x,y,32,50,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();
}



//字
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*32,i*50,C[i%4]);
      
    }
  }
}
void drawCard(int x,int y,color c){
  stroke(128);
  fill(255);
  rect(x,y,32,50,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();
  
  textAlign(CENTER,CENTER);
  textSize(9);
  text("1",x+7,y+6);
  
  textSize(20);
  fill(c);
  text("1",x+16,y+22);
}





//數字0-10
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*32,i*50,C[i%4],j);//step 2
      
    }
  }
}
void drawCard(int x,int y,color c,int n){//step 1
  stroke(128);
  fill(255);
  rect(x,y,32,50,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();
  
  textAlign(CENTER,CENTER);
  textSize(9);
  text(""+n,x+7,y+6);//step 3
  
  textSize(20);
  fill(c);
  text(""+n,x+16,y+22);//step 3
  
}




//隨機洗牌
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];//step 1
int [] cardC = new int[88];//step 1
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);//step 2
      drawCard(j*32,i*50,cardC[i*11+j],cardN[i*11+j]);//step 3
      
    }
  }
}
void drawCard(int x,int y,color c,int n){//step 1
  stroke(128);
  fill(255);
  rect(x,y,32,50,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();
  
  textAlign(CENTER,CENTER);
  textSize(9);
  text(""+n,x+7,y+6);//step 3
  
  textSize(20);
  fill(c);
  text(""+n,x+16,y+22);//step 3
  
}








//多一個迴圈,可以讓洗牌變得更隨機
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];
   }
 }
 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];//step 1
int [] cardC = new int[88];//step 1
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);//step 2
      drawCard(j*32,i*50,cardC[i*11+j],cardN[i*11+j]);//step 3
      
    }
  }
}
void drawCard(int x,int y,color c,int n){//step 1
  stroke(128);
  fill(255);
  rect(x,y,32,50,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();
  
  textAlign(CENTER,CENTER);
  textSize(9);
  text(""+n,x+7,y+6);//step 3
  
  textSize(20);
  fill(c);
  text(""+n,x+16,y+22);//step 3
  
}










void setup(){
  size(600,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];
int [] cardC = new int[88];
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],32);//step1
      
    }
  }
  drawCard(450,50,cardC[7],cardN[77],128);//step2
}
void drawCard(int x,int y,color c,int n,int w){//step3
  float s = w/32.0;//scale size
  stroke(128);
  fill(255);
  rect(x,y,32*s,50*s,7*s);
  noStroke();
  fill(c);
  rect(x+2.5*s,y+2.5*s,32*s-5*s,50*s-5*s,4*s);
  
  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);//step 3
  
  textSize(20*s);
  fill(c);
  text(""+n,x+16*s,y+22*s);//step 3
  
}








//點擊左側,右側會跑出隨機卡牌



void setup(){
  size(1000,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];
int [] cardC = new int[88];
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,C[i%4],j);
        drawCard(j*32,i*50,cardC[i*11+j],cardN[i*11+j],32);//step1
      } 
    }
  } else drawCard(50,50,#000000,99,128);//get card here 
  
  for(int i=0; i<myCard; i++){
    drawCard(450+40*i, 50, cardC[i], cardN[i], 128);//step2
  }
}
int myCard=0;
void mousePressed(){
  if(mouseButton == LEFT) myCard++;
}
void drawCard(int x,int y,color c,int n,int w){//step3
  float s = w/32.0;//scale size
  stroke(128);
  fill(255);
  rect(x,y,32*s,50*s,7*s);
  noStroke();
  fill(c);
  rect(x+2.5*s,y+2.5*s,32*s-5*s,50*s-5*s,4*s);
  
  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);
  
}



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];
int [] cardC = new int[88];
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,C[i%4],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*i/4, 350, cardC[i], cardN[i], 128);
    if(i%4==2) drawCard(430  +40*i/4, 650, cardC[i], cardN[i], 128);
    if(i%4==3) drawCard(230  +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){//step3
  float s = w/32.0;//scale size
  stroke(128);
  fill(255);
  rect(x,y,32*s,50*s,7*s);
  noStroke();
  fill(c);
  rect(x+2.5*s,y+2.5*s,32*s-5*s,50*s-5*s,4*s);
  
  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);
  
}



沒有留言:

張貼留言