2013年4月11日 星期四
2013資訊設計 processing 製作/ m10110302 林秉毅
太極旋轉球!!!!
兩顆球
一個順時針往畫面中心旋轉漸漸縮小
一個逆時針往畫面中心旋轉漸漸縮小
Car myCar1;
Car myCar2; // Two objects!
float xc, yc;
void setup() {
size(600,600);
xc=width/2;
yc=height/2;
// Parameters go inside the parentheses when the object is constructed.
myCar1 = new Car(color(255,255,255),300,20,0.05,100);
myCar2 = new Car(color(0,0,0),-300,20,0.05,100);
}
void draw() {
background(70);
myCar1.drive();
myCar1.display();
myCar2.drive();
myCar2.display();
}
// Even though there are multiple objects, we still only need one class.
// No matter how many cookies we make, only one cookie cutter is needed.
class Car {
color c;
float xi;
float yi;
float N;
float R;
float speed;
float count=0;
float jen;
float jenS;
float size;
// The Constructor is defined with arguments.
Car(color tempC, float Ri, float Ni,float speedi, float sizei) {
c = tempC;
N = Ni;
R=Ri;
speed=speedi;
jen=R/(N/speed);
size=sizei;
jenS=size/(N/speed);
}
void display() {
stroke(1);
fill(c);
ellipse(xc+R*cos(count*2*PI/N),yc+R*sin(count*2*PI/N),size,size);
}
void drive() {
R-=jen;
size-=jenS;
count +=speed;
if (count >= N) {
count = 0;
R=jen*(N/speed);
size=jenS*(N/speed);
}
}
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言