PImage haikei,purin01,purin02,purin03,sara01,sara02,sakura,mado,table,spoon,tokei,kumo; float theta;//(参考01) int r; int length;// 棒の長さ(参考02) float angle = -PI/5;// 新基準軸のスタート回転角(参考02) float angular_velocity = 0.0/60;// 角速度(参考02) float angular_acceleration;//加速度(参考02) PFont myfont; String j ="プリンを長押し♥"; void setup(){ size(500,500); haikei=loadImage("haikei.png");//背景 purin01=loadImage("purin01.png");//プリン01 purin02=loadImage("purin02.png");//プリン02 purin03=loadImage("purin03.png");//プリン03 sara01=loadImage("sara01.png");//お皿01 sara02=loadImage("sara02.png");//お皿02 sakura=loadImage("sakura.png");//さくらんぼ,ホイップ mado=loadImage("mado.png");//窓 table=loadImage("table.png");//テーブル spoon=loadImage("spoon.png");//スプーン tokei=loadImage("tokei.png");//時計 kumo=loadImage("kumo.png");//雲 theta = 0; r = 12; noStroke(); frameRate(30); length = 50;// 棒の長さ(参考02) myfont = createFont("MS Gothic",48); textFont(myfont); } void draw() { image(haikei,0,0);//背景 image(mado,350,130);//窓 image(table,0,385);//テーブル image(tokei,45,130);//時計 image(kumo,310,350);//雲 if(mousePressed && mouseX>=180 && mouseX<=350 && mouseY>=180 && mouseY<=300){ float x; theta += 0.3; x = r*sin(theta);//プリン01揺れ(参考01) float y; theta += 0.15; y = r*sin(theta);//プリン02揺れ(参考01) float z; theta += 0.1; z = r*sin(theta);//プリン03揺れ(参考01) image(sara02,150,283);//お皿02 image(purin01,x+192,215);//プリン01 image(purin02,y+185,258);//プリン02 image(purin03,z+178,290);//プリン03 fill(#502A06); ellipse(x+250,220,100,30);//プリンソース image(sara01,150,300);//お皿01 image(sakura,x+230,180);//さくらんぼ,ホイップ }else{ image(sara02,150,283);//お皿02 image(purin01,192,215);//プリン01 image(purin02,185,258);//プリン02 image(purin03,178,290);//プリン03 fill(#502A06);//プリンソース(色) ellipse(250,220,100,30);//プリンソース image(sara01,150,300);//お皿01 image(sakura,230,180);//さくらんぼ,ホイップ } image(spoon,mouseX-23, mouseY-45);//マウス,スプーン textAlign(CENTER,BOTTOM); textSize(17);//文字の大きさ text(j,397,400);//文字位置 angular_acceleration = -2.0/60*sin(angle)/length;//角加速度(参考02) translate(93,225);// 振り子位置(参考02) rotate(angle+PI/2);// 図形の原点を中心に回転(参考02) stroke(#7A524C); strokeWeight(3);//線の太さ line(0, 0, length, 0);// 棒 fill(#804D4D); noStroke(); ellipse(length, 0, 20, 20);//振り子のボール angular_velocity = angular_velocity + angular_acceleration;//(参考02) angle = angle + angular_velocity;//(参考02) //参考01(http://www.cp.cmc.osaka-u.ac.jp/~kikuchi/kougi/simulation2009/processing8.html#SEC1) //参考02(http://monge.tec.fukuoka-u.ac.jp/cg_processing/03_polar_coordinates01c.html) }