![]() |
最後做出了一款小遊戲,尋找顏色不同的點
void setup()
{
size(300,500);
colorMode(HSB,256);
}
int ansX=1,ansY=2;
int n=3,RR=0;
int H=0;
void draw(){
background(0);
int R=300/n,w=R/2;
for(int y=0;y<n;y++)
{
for(int x=0;x<n;x++)
{
if(x==ansX && y==ansY)fill(H-10,243,234);
else fill(H,255,255);
if( dist(mouseX, mouseY,w+x*R,200+w+y*R)<w){
if(mousePressed &&x==ansX && y==ansY){
ansX= int(random(n));
ansY= int(random(n));
H+=20;
if(H>256)H=0;
}
}
ellipse(w+x*R,200+w+y*R,RR,RR);
}
}
if(RR<R) RR+=R/30;
}


沒有留言:
張貼留言