**問1 [#eb890585] ウインドウの四隅でボールがバウンドするように,以下のプログラムを完成させよ. #ref(./q1.wmv); //ボールの初期位置 float px = 100; float py = 100; //ボールの速度 float vx = 2; float vy = 1; //ボールの直径 float r = 10; void setup() { size(200, 200); noStroke(); smooth(); fill(0, 0, 0); } void draw() { background(255, 255, 255); //ボールが四隅に接触してバウンドする処理を記述 ellipse(px, py, r, r); } **問2 [#r72ab209] 配列とfor文を使用し,問1のボールを30個にせよ. #ref(./q2.wmv); //ボールの位置 int numball = 30; float[] px = new float[numball]; float[] py = new float[numball]; //ボールの速度 float[] vx = new float[numball]; float[] vy = new float[numball]; //ボールの直径 float r = 10; void setup() { size(200, 200); noStroke(); smooth(); fill(0, 0, 0); //ボールの位置,速度をランダムに初期化 } void draw() { background(255, 255, 255); //ボールが四隅に接触してバウンドする処理を記述 //ボールを描画 } **問3 [#t1623627] 5つのボールの内,最大の大きさのボールを赤で描くようにせよ. #ref(./q3.png); size(200, 200); background(255, 255, 255); smooth(); noStroke(); fill(0, 0, 0); //直径を初期化 float[] r = new float[5]; for(int i = 0; i < 5; i++) { r[i] = random(1,30); } //最大の直径の円が何番目かを探す float maxr = 0; int maxindex = 0; ??? //円を描く for(int i = 0; i < 5; i++) { if (i == maxindex) fill(255, 0, 0); else fill(0, 0, 0); ellipse((i+1) * 30, 100, r[i], r[i]); } **問4 [#webc8b75] textを利用し,問3のボールの直径を表示せよ. #ref(./q4.png); **問5 [#z01ce71e] 配列とfor文を利用し,以下のようにスクロールする波形のようなアニメーションを描画せよ. #ref(./q5.wmv);