2022年10月29日 星期六

大拇指的啦

製作卡片遊戲

方塊 : rect(x ,y ,寬 , 高 , 邊框圓滑度)
  , 也可以針對 (x , y,左上 ,右上,右下, 左下)



用drawcards來畫出更多張卡片
int w=10;
void drawCard(int x,int y){
   fill(#6AB1FA);
  rect(x+w,y+w, 150,200 , 10);
  fill(#D060FA);
  rect(x+w+10,y+w+10, 130,180 ,10);
}




Poker內容 
textSize( ) :字體大小

text( 字 , x , y) :文字位置
記得在檔案->偏好設定->字型改標楷體 才能打中文

Pfont font = createFont(標楷體,大小) : 建立字型變數為標楷體+字體大小

textFont( 字型變數 ) : 套用font字型

.indexOf("字")  : 有這個字

.indexOf("字") == -1  :沒這個字 
void setup(){
 size(500,500);
 PFont font = createFont("標楷體",40);
 textFont(font);
}
void draw(){
 drawCard(100,130,"黑桃1");
 drawCard(130,180,"愛心2");
 drawCard(160,230,"方塊3");
 drawCard(190,280,"梅花4");
}
int w=10;
void drawCard(int x,int y,String face ){
   fill(255);
  rect(x+w,y+w, 150,200 , 10);
  fill(#CFECFA);
  rect(x+w+10,y+w+10, 130,180 ,10);
  if (face.indexOf("黑桃")== -1 && face.indexOf("梅花") == -1) fill (#FF0000);
  else fill(0);
  textSize(30);
  text(face,x+25,y+50);
}




沒有留言:

張貼留言