ユーザ名: anonymous

[課題]: 円が周期的に大きくなったり小さくなり,キーを押していると鼓動が早くなって離すとゆっくりになるアニメーションを作成しましょう

Q. 🎉正解です🎉

正解出力:

Image of problem

あなたの出力:

あなたのコード:

1let size = 50;
2let count = 0;
3let cycle = 100;
4let increment = 1;
5function setup(){
6  createCanvas(200, 200);
7}
8function draw(){
9  background(160, 192, 255);
10  count = (count + increment) % cycle;
11  if (keyIsPressed) {
12    increment = 2;
13  } else {
14    increment = 1;
15  }
16  if (count < cycle/2) {
17    size = count + 50;
18  } else {
19    size = (cycle - count) + 50;
20  }
21  ellipse(width/2, height/2, size);
22}

あなたの方針: