一方向運動リストに戻る    印刷する

一方向の直線運動…ひとつ(大きさ変化)

ひとつの円が、水平に一定速度で運動します。 動きは、ひとつ(軌跡なし)と同じですが、大きさが変化します。位置が変化するとともに、円の直径を大きくします。

Your browser does not support the canvas tag.

クリックで停止⇔再開
【リスト Straight3】
float s = 3; // 移動速度
float x; // 位置(x座標)
float d = 2; // 円の直径

void setup() {
  size(150, 150);
  fill(0);
}

void draw() { 
   background(255);   //画面背景を白でクリア
    x = x+s ;  // 位置を変化
    d = d+1;   // 大きさを変化
    if(x>=width+d/2) { //右端を越えたら、元に戻す
       d=2;
       x=-d/2;
    }
     ellipse(x, height/2, d, d);
}

arigat アットマーク acm.org / copyright © info