int newX, newY;
int[][] array = new int [19][19];
void setup(){
size(1000,1000);
}
void draw(){
background(255,226,111);
noFill();
strokeWeight(4);
rect(50,50,900,900);
strokeWeight(2);
for (int i=0;i<18;i=i+1){
line(50,50+i*50,950,50+i*50);
line(50+i*50,50,50+i*50,950);
}
fill(#E85E0E);
ellipse(newX*50+50, newY*50+50,50,50);
for(int i=0;i<19;i=i+1){
for(int j=0;j<19;j=j+1){
if(array[i][j]==1){fill(0); ellipse(i*50+50,j*50+50,50,50);}
if(array[i][j]==2){fill(255); ellipse(i*50+50,j*50+50,50,50);}
}
}
}
void mousePressed(){
array[newX][newY]=nowColor;
if(nowColor==1)nowColor=2;
else if(nowColor==2)nowColor=1;
}
void mouseMoved(){
newX=(mouseX-25)/50;
newY=(mouseY-25)/50;
if(newX > 18) newX=18;
if(newY > 18) newY=18;
}
沒有留言:
張貼留言