Skip to content

Instantly share code, notes, and snippets.

@nappa7878
Created December 21, 2012 05:24
Show Gist options
  • Select an option

  • Save nappa7878/4350846 to your computer and use it in GitHub Desktop.

Select an option

Save nappa7878/4350846 to your computer and use it in GitHub Desktop.
小学校算数 九九 自動作成した問題をマウスクリックで連続表示
// **********************************************
// 自動作成したな問題を
// マウスクリックで連続表示
//
// **********************************************
//フォントを準備する
PFont font = createFont("FFScale",32);
//問題設定
String[] Qstr = new String[81];
//表示している問題番号
int Qcount = 0;
void setup(){
size(640,480);
colorMode(RGB,255);
MakeQuestion();
}
void draw(){
Question();
//ループを止める
noLoop();
}
void MakeQuestion(){
//作成する問題番号
int Mcount = 0;
for(int j=0;j<9;j++){
for(int i=0;i<9;i++){
Qstr[Mcount] = (j+1) + "×" + (i+1);
Mcount++;
}
}
//j = 0、i = 0 のとき、Qstr[0] = (0+1) + "×" + (0+1) = "1×1"
//j = 0、i = 1 のとき、Qstr[1] = (0+1) + "×" + (1+1) = "1×2"
//j = 0、i = 2 のとき、Qstr[2] = (0+1) + "×" + (0+1) = "1×3"
//
//j = 1、i = 0 のとき、Qstr[9] = (1+1) + "×" + (0+1) = "2×1"
//j = 1、i = 1 のとき、Qstr[10] = (1+1) + "×" + (1+1) = "2×2"
//
//j = 8、i = 8 のとき、Qstr[80] = (8+1) + "×" + (8+1) = "9×9"
}
void Question(){
background(255,255,255);
fill(0,0,0);
textFont(font,250);
textAlign(CENTER,CENTER);
text( Qstr[Qcount] ,width/2,height/2);
}
void mousePressed(){
//ループを始める
loop();
Qcount++;
if(Qcount>Qstr.length-1){
Qcount = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment