![]() |
| 將原本的3*3圓形改成4*4 |
for(int x=0; x<4;x++){ //原本x<3變成x<4
ellipse(50+x*100,200+50+y*100,100,100);
}
}
void setup(){
size(300,500);
}
int n=5;int R=300/n,w=R/2,RR=0;
void draw(){
for(int y=0;y<n;y++){
for(int x=0;x<n;x++){
ellipse(w+x*R,200+w+y*R,RR,RR);
}
}
if(RR<R)RR++;
}
利用變數讓圖形由小變大
我稱這個叫打地鼠
![]() |
| 我稱這個彩色版打地鼠 |
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;
}
紅色字為彩色版新增的





沒有留言:
張貼留言