int n=1;
void setup() {
size(150, 350);
}
void draw() {
frameRate(10);//make it slow
background(0);
cal_result();
if (keyPressed) {/// can change the number///
if (key=='w') {
n=n+1;
} else if (key=='s')
n=n-1;
}
}
void cal_result() {//////// calculation function///////
int count=12;
int mN=1;
int posY=70;
fill(255);
textSize(15);
text("Multiple Table", 20, 40);
while (mN<=count) {
int ans=n*mN;
textSize(12);
text(n+" x "+mN+" = "+ans, 20, posY);
posY=posY+20;
mN=mN+1;
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น