float x,y; PFont myFont; float x1,x2,x3,x4; float x5,x6,x7,x8; float y1,y2,y3,y4; float y5,y6,y7,y8; int cnt; void setup(){ size(500,500); frameRate(40); myFont =createFont("MS Gothic",48); textFont(myFont); x1 = 250; x2 = 350; x3 = 450; x4 = 550; x=width/2; y=width/2; cnt = 0; } void draw(){ background(214,255,248); //背景色 fill(0);//文字色 textAlign(CENTER); textSize(20); text("マウスを動かすと金魚がついてきます",width/2,30); y1 = 100 + sin(radians(frameCount))*50; y2 = 100 + sin(radians(frameCount-90))*100; y3 = 100 + sin(radians(frameCount-180))*100; y4 = 100 + sin(radians(frameCount-270))*50; strokeWeight(1); noFill(); stroke(255,245,0);//黄色 ellipse(x3-400,y1+20,50,50); stroke(180,20,250);//紫 ellipse(x3-120,y2+75,10,10); stroke(255,100,5);//オレンジ ellipse(x2-170,y3+250,20,20); stroke(45,255,30);//緑 ellipse(x2+100,y4+200,25,25); noStroke(); fill(255,250,140);//黄色 ellipse(x3+50,y1,20,20); fill(230,180,255);//紫 ellipse(x3-340,y2+300,15,15); fill(255,155,100);//オレンジ ellipse(x2+50,y3,30,30); fill(150,255,145);//緑 ellipse(x2-100,y4+100,20,20); strokeWeight(1); noFill(); stroke(40,150,255,100); bezier(x1,y1,x2,y2,x3,y3,x4,y4);//水の流れ bezier(x1,y1,x2,y2+10,x3,y3+10,x4,y4); stroke(30,90,155,100); bezier(x1-250,y1+290,x2-250,y2+290,x3-250,y3+290,x4-250,y4+290);//水の流れ2 bezier(x1-250,y1+290,x2-250,y2+300,x3-250,y3+300,x4-250,y4+290); if (mouseY -y<1) y--; if (mouseY -y>1) y++; if (mouseX -x>1) x++; if (mouseX -x<1) x--; kin(x,y); hirahira(x,y); } void kin(float x,float y){ fill(255,30,0,150);//金魚の色 noStroke();//線はなし ellipse(x,y,100,35);//金魚の体↓ fill(0); ellipse(x-30,y-13,4,3);//右目 ellipse(x-30,y+13,4,3);//左目 fill(255,30,0,150);//金魚の色 noStroke();//線はなし triangle(x+47, y, x+90, y-20, x+70, y);//尻尾 triangle(x+47, y, x+85, y+20, x+70, y); } void hirahira(float x,float y){ x5 = x; x6 = x; x7 = x; x8 = x; y5 = y + sin(radians(frameCount))*0; y6 = y + sin(radians(frameCount-90))*3; y7 = y + sin(radians(frameCount-180))*6; y8 = y + sin(radians(frameCount-270))*9; bezier(x5+47,y5,x6+72,y6-2,x7+82,y7-2,x8+97,y8);//尻尾↓ bezier(x5+47,y5,x6+72,y6+2,x7+82,y7+2,x8+97,y8); bezier(x5-5,y5-16,x6,y6-20,x7+5,y7-25,x8+25,y8-25);//ヒレ上↓ bezier(x5-5,y5-16,x6,y6-20,x7+5,y7-15,x8+25,y8-25); y5 = y + sin(radians(frameCount))*0; y6 = y + sin(radians(frameCount+90))*3; y7 = y + sin(radians(frameCount+180))*6; y8 = y + sin(radians(frameCount+270))*9; bezier(x5-5,y5+16,x6,y6+20,x7+5,y7+15,x8+25,y8+25);//ヒレ下↓ bezier(x5-5,y5+16,x6,y6+20,x7+5,y7+25,x8+25,y8+25); y5 = y + sin(radians(frameCount))*0; y6 = y + sin(radians(frameCount-90))*3; y7 = y + sin(radians(frameCount-180))*6; y8 = y + sin(radians(frameCount-270))*0; bezier(x5-10,y5,x6-15,y6-2,x7+15,y7-2,x8+30,y8);//背ビレ↓ bezier(x5-10,y5,x6-15,y6+2,x7+15,y7+2,x8+30,y8); }