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

74 lines
1.9 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-03 22:04:28 +01:00
let titleGame = document.createElement("h1");
2022-12-02 16:32:52 +01:00
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-03 22:04:28 +01:00
let demoGame = document.createElement("button");
demoGame.textContent = "Partie démo";
demoGame.style =
"margin: 10%; \
display: block; \
margin-left: auto; \
margin-right: auto; \
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-03 22:04:28 +01:00
document.body.appendChild(demoGame);
2022-12-02 00:15:37 +01:00
2022-12-03 22:04:28 +01:00
let normalGame = document.createElement("button");
normalGame.textContent = "Partie normale";
normalGame.style =
"margin: 10%; \
display: block; \
margin-left: auto; \
margin-right: auto; \
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-03 22:04:28 +01:00
document.body.appendChild(normalGame);
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
};