xxxxxxxxxx
let questionList = [
8, 7, 1, 0, 0, 0, 5, 6, 4,
0, 9, 5, 0, 1, 7, 2, 3, 8,
2, 0, 3, 4, 5, 8, 0, 7, 1,
0, 2, 0, 1, 0, 3, 7, 9, 5,
0, 1, 9, 2, 7, 0, 8, 4, 3,
7, 0, 4, 0, 8, 5, 0, 0, 2,
1, 5, 0, 0, 0, 4, 3, 8, 0,
0, 8, 7, 5, 0, 0, 0, 0, 6,
0, 0, 0, 0, 3, 2, 1, 0, 7,
];
let checkList = [
"0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0",
];
let buttonList = [
"1", "2", "3", "4", "5", "6", "7", "8", "9",
];
let reds_x = 0;
let reds_y = 0;
let reds_flag = 0;
let button_flag = 0;
let judge = 0;
let reds = 0;
let p1s = 0;
let sum = 0;
function setup() {
createCanvas(540, 700);
textAlign(CENTER, CENTER);
textSize(50);
}
function draw() {
background(200,10);
for(let i=0; i<81; i++){
let x = i % 9 * 60;
let y = int(i/9) * 60;
fill(255);
rect(x, y, 60, 60);
fill(0);
if(questionList[i] != 0){
text(questionList[i], x+30, y+30);
}else if(questionList[i] == 0){
}
}
text(sum ,270, 300);
for(let i=0; i<9; i++){
fill(255);
let button_x = i % 9 * 60;
let button_y = 600;
rect(button_x, button_y, 60, 60);
fill(0);
text(buttonList[i], button_x + 30,button_y + 30);
}
if(button_flag == 1){
questionList[reds] = judge;
button_flag = 0;
}
if(reds_flag == 1){
fill(255, 20, 0, 100);
rect(reds_x, reds_y, 60, 60);
}
}
function mousePressed(){
for(let i=0; i<9; i++){
let button_x = i % 9 * 60;
let button_y = 600;
if(mouseX > button_x && mouseX < button_x + 60){
if(mouseY > button_y && mouseY < button_y + 60){
button_flag = 1;
judge = buttonList[i];
if(is45_yoko(reds) == 1){
//Stroke(255,100, 10);
}
}
}
}
for(let i=0; i<81; i++){
let x = i % 9 * 60;
let y = int(i / 9) * 60;
if(mouseX > x && mouseX < x + 60){
if(mouseY > y && mouseY < y + 60){
reds_flag = 1;
reds_x = x;
reds_y = y;
reds = i;
}
}
}
}
function is45_yoko(p1){
sum += int(questionList[p1]);
p1s = 1 - p1;
for(let i = 0; i < 9; i++){
sum += int(questionList[p1 + p1s + i]);
}
if(sum == 45){
Stroke(255, 0 ,0);
return 1;
}
return 0;
}