Created
December 3, 2012 02:24
-
-
Save nappa7878/4192202 to your computer and use it in GitHub Desktop.
1けたのたし算ランダム表示 (iPad PR0C0D1N6用)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/***************************************** | |
* 1けたのたし算ランダム表示 (iPad PR0C0D1N6用) | |
* 横置き | |
* ボタンクリックで表示の切替 | |
* Hiroyuki Nakano | |
* 2012.12.03 | |
*****************************************/ | |
String[] Quest = new String[81]; | |
int[] Ans = new int[81]; | |
int[] rS = new int[81]; | |
int dflag = -1; | |
int qCount = 0; | |
PFont font=createFont("FFScala", 32); | |
void setup() { | |
size(screen.width,screen.height); | |
colorMode(RGB, 100); | |
randSeed(rS); | |
QuestionMake(); | |
} | |
void draw(){ | |
switch (dflag){ | |
case -1: | |
background(255,255,255); | |
Start(); | |
break; | |
case 0: | |
background(255,255,255); | |
Question(); | |
break; | |
case 1: | |
background(255,255,255); | |
Answer(); | |
break; | |
case 2: | |
background(255,255,255); | |
End(); | |
break; | |
} | |
} | |
void Start(){ | |
float fontSize = 150; | |
fill(0,255,0); | |
textFont(font,fontSize); | |
text("はじめるよ!" , screen.width / 2 - fontSize * 2, screen.height / 2); | |
} | |
void End(){ | |
float fontSize = 150; | |
fill(255,0,0); | |
textFont(font,fontSize); | |
text("がんばった!" , screen.width / 2 - fontSize * 2, screen.height / 2); | |
} | |
void QuestionMake(){ | |
for(int i=1;i<10;i++){ | |
for(int j=1;j<10;j++){ | |
Quest[qCount] = i+"+"+j; | |
Ans[qCount] = i + j; | |
qCount++; | |
} | |
} | |
qCount = -1; | |
} | |
void Question(){ | |
float fontSize = 500; | |
fill(0,0,0); | |
textFont(font,fontSize); | |
text(Quest[rS[qCount]] , screen.width / 2 - fontSize / 2, screen.height / 2); | |
} | |
void Answer(){ | |
float fontSize = 500; | |
fill(0,0,255); | |
textFont(font,fontSize); | |
text(Ans[rS[qCount]] , screen.width / 2 - fontSize / 2 + 150, screen.height / 2); | |
} | |
void mousePressed(){ | |
dflag++; | |
dflag = dflag % 2; | |
if(dflag == 0) qCount++; | |
if(qCount == 81) dflag = 2; | |
} | |
void randSeed(int rS[]){ | |
int dummy; | |
randomSeed(second()); | |
for(int i=0;i<rS.length;i++){ | |
rS[i] = i; | |
} | |
for(int j=0;j<10000;j++){ | |
int r1 = (int) random(0,81); | |
int r2 = (int) random(0,81); | |
dummy = rS[r1]; | |
rS[r1] = rS[r2]; | |
rS[r2] = dummy; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment