再來把字行變成紅色
size(800,300);//介面大小
fill(255,0,0);
PFont font1 = createFont("Times New Roman", 30);
textFont(font1);
text("中文vs.English", 30, 30);
PFont font2 = createFont("標楷體", 30);
textFont(font2);
text("中文vs.English", 30,130);//
接下來交了陣列
接下來就可以把自己喜歡的圖片放上去
PImage bird, pig;
void setup(){
size(400,400);
bird=loadImage("bird.png");
pig =loadImage("pig.png");
}
void draw(){
background(0);//黑背景
for(int i=0;i<4;i++){//左邊
for(int j=0;j<4;j++){//右邊
if(A[i][j]==1) image(bird,j*100,i*100,100,100);//1:紅鳥
if(A[i][j]==2) image(pig,j*100,i*100,100,100);//2:綠豬
}
}
}
接下來做出了一個小遊戲點及圖案會消除
//右:0,1,2, x座標
int [][]A={{1,2,2,2},
{0,1,1,1},
{0,1,1,1},
{2,2,2,2} };//0:黑,1:bird,2:pig
//左邊: 高4層
PImage bird, pig;
void mousePressed(){
int i=int(mouseY/100);
int j=int(mouseX/100);
A[i][j]=0;
}
void setup(){
size(400,400);
bird=loadImage("bird.png");
pig =loadImage("pig.png");
}
void draw(){
background(0);
for(int i=0;i<4;i++){//左邊
for(int j=0;j<4;j++){//右邊
if(A[i][j]==1) image(bird,j*100,i*100,100,100);//1:紅鳥
if(A[i][j]==2) image(pig,j*100,i*100,100,100);//2:綠豬
}
}
ellipse(mouseX,mouseY, 25,25);
text("mouseX:"+mouseX+"mouseY:"+mouseY,100,100);
}





沒有留言:
張貼留言