xxxxxxxxxx
54
// https://www.numberempire.com/6
let properties = [
'2 is a factor',
'3 is a factor',
'is not prime',
'is not a Fibonacci number',
'is a factorial',
'is a perfect number',
'is a triangular number',
'is a regular number'
];
let currentProperty=-1;
let myInput;
let myGuess = 6;
let hintShowing = false;
function setup() {
createCanvas(400, 400);
myInput = createInput();
myInput.elt.size = 5;
myInput.input( ()=>{
hintShowing = false;
currentProperty=-1;
});
myInput.position(200,65);
}
function draw() {
background("rgb(255,154,255)");
text('What number am I thinking about?',10,80);
text('... between 1 and 1000',10,98);
let msg = myInput.value();
if (int(msg)==myGuess){
text('!!! WOW, you won !!!!',100,350);
noLoop();
} else if (properties.length>=1){
if (!hintShowing){
currentProperty = int(random(0,properties.length));
hintShowing = true;
}
if (currentProperty>=0){
text(properties[currentProperty],
100+sin(frameCount/120)*100,250);
}
} else {
text('Sorry, you lost! :(',100,350);
noLoop();
}
}