2020年11月16日 星期一

week08

 

其中作業!!!


int [][]A={{2,0,2,0},{1,2,1,2},

{2,0,2,1},{2,1,2,1}}; PImage a,b; void mousePressed(){ int i=int(mouseY/100); int j=int(mouseX/100); if(A[i][j]==0) A[i][j]=1; else A[i][j]=2; if(A[i][j]==1) A[i][j]=0; else A[i][j]=2; if(A[i][j]==2) A[i][j]=0; else A[i][j]=1; } void setup(){ size(400,400); a=loadImage("a.png"); b=loadImage("b.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(a, j*100, i*100, 100,100); if(A[i][j]==2) image(b, j*100, i*100, 100,100); } } ellipse(mouseX,mouseY,10,10); }


秀出分數的方法
textSize(50);
fill(#FFE412); text("Score:"+score,100,50);

void mousePressed()
{
    int i=int (mouseY/100),j=int(mouseX/100);
if(A[i][j]==1)
{
    A[i][j]=0;score+=100;println(score);
}
}

沒有留言:

張貼留言