#gpa-next-button {
font-family: 'Space Mono', monospace;
color: white;
font-size: 3vw;
z-index: 8;
position: absolute;
white-space: nowrap;
left: 50%;
top: 150vw;
transform: translate(-50%, -50%);
display: none; /* Initially hidden */
}
#gpa-result {
font-family: 'Space Mono', monospace;
color: white;
font-size: 5vw;
z-index: 9;
position: absolute;
white-space: nowrap;
left: 50%;
top: 150vw;
transform: translate(-50%, -50%);
display: none; /* Initially hidden */
}```
And last but not least the JS:
const result = document.getElementById("gpa-result");
const startBtn = document.getElementById("gpa-start-button");
const nextBtn = document.getElementById("gpa-next-button");
const gameArea = document.getElementById("gpa-game-area");
let iteration = 1;
function gpaStartFunction() {
console.log('Started!');
startBtn.style.visibility = "hidden"; // Hide it
nextBtn.style.display = "block"; // Make it visible
gpaNextFunction();
}
function gpaNextFunction() {
if (iteration >= 10) {
nextBtn.style.visibility = "hidden"; // Hide it
result.style.display = "block"; // Make it visible
}
const randomX = randomInRange(0, gameArea.clientWidth);
const randomY = randomInRange(0, gameArea.clientWidth);
nextBtn.animate({
left: `${randomX}px`,
top: `${randomY}px`
}, {duration: 250, fill: "forwards"});
console.log(nextBtn.style.transform);
iteration++;
}
function randomInRange(min, max) {
return(Math.floor((Math.random() * (max - min) + 1) + min));
}```