int eSize; //オブジェクトのサイズ int speed = 5; //オブジェクトのスピード int x; //オブジェクトのx座標 int y; int x1 = eSize; void setup() { size(400, 400); noStroke(); //輪郭を描かない fill(0); //オブジェクトは黒 y = height/2; } void draw() { background(255); // 軌跡を残す場合は、下の3行をON、backgoundをOFFにする /* fill(255, 50); //透明度のあるrectを描画 rect(0, 0, width, height); fill(0); //オブジェクトは黒 */ eSize = 20; ellipse(200, mouseX, eSize, eSize); //円を描く eSize =30; ellipse(mouseY,x, eSize, eSize); //円を描く x += speed; //x座標にspeedの値を足す //もし、xの値が画面の幅以上になったら、xを0に戻す if (x >= width) { x = 0; } } void mousePressed(){ x = mouseX; y = mouseY; }