2010年6月21日 星期一

HW4 B9530007

完整網頁請點這裡
請以滑鼠點選中心點位置開始machine action

B9610119_HW1



因為圖檔不知為什無法上傳至Blogger,所以我把10張圖放在一張A4了

B9610119_HW1

2010年6月20日 星期日

2010年6月14日 星期一

HW4. (final) Abstract Machine

HW4. (with processing)
Define several machine elements.
Compose abstract machine with these elements.
Deadline:
2010/6/21 pm 2:00

2010年6月7日 星期一

machine activation sample codes

wheel object1;
wheel2 object2;
int state = 0;
void setup()
{
size(640, 360);
background(255);
smooth();
object1 = new wheel(100, 100);
object2 = new wheel2(300, 100);

}
void draw()
{
if ((mousePressed) && (mouseX> width/2))
{
state= 1;
object1.input();
}
if (state ==1)
{
object1.update();
object1.display();
}
if (state == 2)
{

object2.update();
object2.display();
}


}



class wheel
{
int x, y;
float angle;
int nRotate;

wheel(int xc, int yc)
{
x= xc;
y= yc;
angle = 0;


}

void input()
{
nRotate= 0;
}
void update()
{
nRotate ++;
angle= angle + 10;
if (nRotate >50)
output();
display();


}

void display()
{
pushMatrix();
translate(x, y);
rotate(radians(angle));
rect(-10, -10, 20, 20);

popMatrix();

}
void output()
{
state = 2;
object2.input();
}


}
class wheel2
{
int x, y;
float angle;
int nRotate;

wheel2(int xc, int yc)
{
x= xc;
y= yc;
angle = 0;


}

void input()
{
nRotate= 0;
}
void update()
{
nRotate ++;
angle= angle + 10;
if (nRotate >50)
output();
display();


}

void display()
{

pushMatrix();
translate(x, y);
rotate(radians(angle));
rect(-10, -10, 20, 20);

popMatrix();

}
void output()
{
state = 1;
object1.input();
}


}

HW3 B9610119