float eSize = 40.0; //オブジェクトのサイズ float speedy = 0.3; //オブジェクトのスピード float speedx = 2.0; float y = 0.0; //オブジェクトのy座標 float x = 0.0; float accY = 0.0; //acceleration 加速 float accX = 0.0; //acceleration 加速 float Ymouse; float Xmouse; int swY; //switch int swX; //switch void setup() { size(400, 400); noStroke(); //輪郭を描かない fill(0); //オブジェクトは黒 y = 200.0; } void draw() { background(255); /* 軌跡を残す場合は、下の3行をON、backgoundをOFFにする fill(255, 50); //透明度のあるrectを描画 rect(0, 0, width, height); fill(0); //オブジェクトは黒 */ ellipse(x, y, eSize, eSize); //円を描く; ellipse(y, x, eSize, eSize); ellipse(width-x, height-y, eSize, eSize); ellipse(width-y, height-x, eSize, eSize); speedy = Ymouse; accY += speedy; //加速yxにspeedyの値を足す speedx = Xmouse; accX += speedx; y = accY*accY; //y軸の動きを加減速する様に掛け合わしている x = accX*accX; if (y>= height) swY = 1; else if (y<=10)swY = 0; if (swY == 1)Ymouse = map(-(height-mouseY), 0, height, 0, 1); else if (swY == 0)Ymouse = map((height-mouseY), 0, height, 0, 1); if (x>= width)swX = 1; else if (x<=10)swX = 0; if (swX == 1) Xmouse = map(-mouseX, 0, height, 0, 1); else if (swX == 0) Xmouse = map(mouseX, 0, height, 0, 1); }