for loopA for loop repeats the same code a certain number of times.
for loop 会让电脑按照设定的次数,重复执行同一段代码。
while loopA while loop keeps repeating while a condition is true.
infinite loop 无限循环
I first thought c = 0 means c will always stay 0, but now I understand that c++ changes its value every time the loop runs.
for loop
is useful when I already know how many times I want to repeat something.
while loop
continues as long as a condition is true.
if比如 hover 后:
左边变蓝,右边变红。
if (mouseX > c * 20 && mouseX < c * 20 + 20) {
if (c < 10) {
fill(0, 0, 255);
} else {
fill(255, 0, 0);
}
} else {
fill(255);
}
这里有两层判断:
第一层:
Is the mouse hovering over this column?
鼠标有没有在这个 column 上?
第二层: