This repository has been archived on 2022-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
GeometryDash3D/js/main.js

70 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-12-02 16:32:52 +01:00
import { runGame } from "./Game.js";
2022-11-07 09:10:20 +01:00
window.addEventListener("load", () => main());
2022-12-02 16:32:52 +01:00
/**
* Load the menu
*/
2022-11-07 09:10:20 +01:00
const main = () => {
2022-12-02 16:32:52 +01:00
document.body.style = "background-color: black;";
2022-11-08 09:43:37 +01:00
2022-12-02 16:32:52 +01:00
let titleGame = document.createElement("p");
titleGame.textContent = "GeometryDash 3D";
titleGame.style =
2022-12-02 22:46:22 +01:00
"-webkit-animation-name: animTitle; \
-webkit-animation-iteration-count: infinite; \
-webkit-animation-duration: 2s; \
background: none; \
2022-12-02 16:32:52 +01:00
color: white; \
font-size: 400%;";
document.body.appendChild(titleGame);
2022-11-24 19:45:20 +01:00
2022-12-02 16:32:52 +01:00
let normalGame = document.createElement("button");
normalGame.textContent = "Partie normale";
normalGame.style =
2022-12-02 22:46:22 +01:00
"margin-top: 20%; \
2022-12-02 16:32:52 +01:00
border: none; \
background: none; \
color: white; \
2022-12-02 22:46:22 +01:00
font-size: 400%; \
cursor: pointer;";
2022-12-02 16:32:52 +01:00
document.body.appendChild(normalGame);
2022-12-02 00:15:37 +01:00
2022-12-02 16:32:52 +01:00
let demoGame = document.createElement("button");
demoGame.textContent = "Partie démo";
demoGame.style =
"position: absolute; \
top: 40%; \
left: 37%; \
border: none; \
background: none; \
color: white; \
2022-12-02 22:46:22 +01:00
font-size: 400%; \
cursor: pointer;";
2022-12-02 16:32:52 +01:00
document.body.appendChild(demoGame);
2022-12-02 16:32:52 +01:00
const removeMenu = () => {
document.body.removeChild(titleGame);
document.body.removeChild(normalGame);
document.body.removeChild(demoGame);
};
2022-11-08 09:43:37 +01:00
2022-12-02 16:32:52 +01:00
normalGame.addEventListener(
"click",
() => {
removeMenu();
runGame(false);
},
{ once: true }
);
demoGame.addEventListener(
"click",
() => {
removeMenu();
runGame(true);
},
{ once: true }
);
2022-11-07 09:10:20 +01:00
};