問題

重力によって落下し,床で跳ね返るボールを描いてください.

  • キャンバスサイズは (500, 500) とし,ボールの直径は40ピクセルとします.
  • ボールの位置 position ,速度 velocity ,重力加速度 gravity を,それぞれ PVector で表します.
  • ボールは,初期位置 (100, 50) から,初速度 (2, 0) (右向き)で動き始めます.
  • 重力加速度は (0, 0.3) (下向き)とします.
  • 速度の y 成分の向きを反転させ,大きさを0.8倍にします.

ヒント

PVector position;
PVector velocity;
PVector grabity;

void setup(){
  size(500,500);
  position = new PVector(100,50);
  velocity = new PVector(2,0);
  gravity = new PVector(0,0.3);
}

`

実行例