66 lines
1.6 KiB
JavaScript
66 lines
1.6 KiB
JavaScript
import { runGame } from "./Game.js";
|
|
|
|
window.addEventListener("load", () => main());
|
|
|
|
/**
|
|
* Load the menu
|
|
*/
|
|
const main = () => {
|
|
document.body.style = "background-color: black;";
|
|
|
|
let titleGame = document.createElement("p");
|
|
titleGame.textContent = "GeometryDash 3D";
|
|
titleGame.style =
|
|
"background: none; \
|
|
color: white; \
|
|
font-size: 400%;";
|
|
document.body.appendChild(titleGame);
|
|
|
|
let normalGame = document.createElement("button");
|
|
normalGame.textContent = "Partie normale";
|
|
normalGame.style =
|
|
"position: absolute; \
|
|
top: 30%; \
|
|
left: 35%; \
|
|
border: none; \
|
|
background: none; \
|
|
color: white; \
|
|
font-size: 400%;";
|
|
document.body.appendChild(normalGame);
|
|
|
|
let demoGame = document.createElement("button");
|
|
demoGame.textContent = "Partie démo";
|
|
demoGame.style =
|
|
"position: absolute; \
|
|
top: 40%; \
|
|
left: 37%; \
|
|
border: none; \
|
|
background: none; \
|
|
color: white; \
|
|
font-size: 400%;";
|
|
document.body.appendChild(demoGame);
|
|
|
|
const removeMenu = () => {
|
|
document.body.removeChild(titleGame);
|
|
document.body.removeChild(normalGame);
|
|
document.body.removeChild(demoGame);
|
|
};
|
|
|
|
normalGame.addEventListener(
|
|
"click",
|
|
() => {
|
|
removeMenu();
|
|
runGame(false);
|
|
},
|
|
{ once: true }
|
|
);
|
|
|
|
demoGame.addEventListener(
|
|
"click",
|
|
() => {
|
|
removeMenu();
|
|
runGame(true);
|
|
},
|
|
{ once: true }
|
|
);
|
|
};
|