Skip to content

Instantly share code, notes, and snippets.

@ronieremarques
Created June 15, 2024 11:36
Show Gist options
  • Save ronieremarques/6cebd51f3005a94f529427ecce50ce63 to your computer and use it in GitHub Desktop.
Save ronieremarques/6cebd51f3005a94f529427ecce50ce63 to your computer and use it in GitHub Desktop.
let campoIdade;
let campoFantasia;
let campoAventura;
function setup() {
createCanvas(800, 400);
createElement("h2", "Recomendador de filmes");
createSpan("Sua idade:");
campoIdade = createInput("5");
campoFantasia = createCheckbox("Gosta de fantasia?");
campoAventura = createCheckbox("Gosta de aventura?");
}
function draw() {
background("white");
let idade = campoIdade.value();
let gostaDeFantasia = campoFantasia.checked();
let gostaDeAventura = campoAventura.checked();
let recomendacao = geraRecomendacao(idade, gostaDeFantasia, gostaDeAventura);
fill(color(76, 0, 115));
textAlign(CENTER, CENTER);
textSize(38);
text(recomendacao, width / 2, height / 2);
}
function geraRecomendacao(idade, gostaDeFantasia, gostaDeAventura) {
if (idade >= 10) {
if (idade >= 14) {
return "O menino que descobriu o vento";
} else {
if (idade >= 12) {
if(gostaDeFantasia || gostaDeAventura) {
return "Homem aranha: no aranhaverso";
} else{
return "Ladrões de bicicleta";
}
} else {
if (gostaDeFantasia) {
return "As aventuras de pi";
} else {
return "Depois da chuva";
}
}
}
} else {
if (gostaDeFantasia) {
return "A viagem de chihiro";
} else {
return "O feitiço do tempo";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment