//File-Preferences
// week02_1_pacman_radians_mouseX
void setup() {
size(400, 400); //大小
}
void draw() {
background(255);
fill(#FFDC0F);
float a = radians(mouseX);
for(int x=0; x<400; x+=100){
for(int y=0; y<400; y+=100){
arc(x+50, y+50, 100, 100, 0+a, PI*2-a, PIE);
}
}
}
//File-Preferences
// week02_1_pacman_radians_frameCount
void setup() {
size(400, 400); //大小
}
void draw() {
background(255);
fill(#FFDC0F);
float a = radians(frameCount);
if(a>PI/4)a = a-PI/4;
arc(200, 200, 300, 300, 0+a, PI*2-a, PIE);
}
// week02_3_pacman_open_close_open_close
void setup() {
size(400, 400); //大小
}
void draw() {
background(255);
fill(#FFDC0F);
float a = frameCount;
if(a<45)a = radians(a);
else if(a<90) a = radians(90-a);
else if(a<135) a = radians(a-90);
else if(a<180) a = radians(180-a);
arc(200, 200, 300, 300, 0+a, PI*2-a, PIE);
}
// week02_4_pacman_for_for_open_close_open_close
void setup() {
size(400, 400); //大小
}
void draw() {
background(255);
fill(#FFDC0F);
for(int x=0; x<400; x+=100){
for(int y=0; y<400; y+=100){
float a = frameCount % 180;
if(a<45)a = radians(a);
else if(a<90) a = radians(90-a);
else if(a<135) a = radians(a-90);
else if(a<180) a = radians(180-a);
arc(x+50, y+50, 100, 100, 0+a, PI*2-a, PIE);
}
}
}
//week02_5_pacman_if_keyPressed_keyCode
void setup(){
size(400, 400);
}
int x=200, y=200;
void draw(){
background(255);
fill(#FFDC0F);
if(keyPressed && keyCode==RIGHT) x++;
if(keyPressed && keyCode==LEFT) x--;
if(keyPressed && keyCode==UP) y--;
if(keyPressed && keyCode==DOWN) y++;
ellipse(x, y, 100, 100);
}
//week02_6_pacman_b_direction from weeek_02_3
void setup(){
size(400, 400);
}
void draw(){
background(255);
fill(#FFDC0F);
float a = frameCount;
float b = radians(mouseX);
if(a<45)a = radians(a);
else if(a<90) a = radians(90-a);
else if(a<135) a = radians(a-90);
else if(a<180) a = radians(180-a);
arc(200, 200, 300, 300, b+0+a, b+PI*2-a, PIE);
}
//week02_7_pacman_d_direction_void_keyPressed_keyCode
void setup(){
size(400, 400);
}
float x=200, y=200, d=PI/2*0;
void draw(){
background(255);
fill(#FFDC0F);
float a = frameCount % 180;
if(a<45)a = radians(a);
else if(a<90) a = radians(90-a);
else if(a<135) a = radians(a-90);
else if(a<180) a = radians(180-a);
arc(x, y, 100, 100, d+0+a, d+PI*2-a, PIE);
}
void keyPressed(){
if(keyCode==RIGHT){
x++;
d=PI/2*0;
}
else if(keyCode==DOWN){
y++;
d=PI/2*1;
}
else if(keyCode==LEFT){
x--;
d=PI/2*2;
}
else if(keyCode==UP){
y--;
d=PI/2*3;
}
}
沒有留言:
張貼留言