-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.js
44 lines (36 loc) · 1.06 KB
/
game.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { createHTMLElement } from "./helpers";
import { GridInit } from "./gridInit";
import { Homepage } from "./homepage";
export class Game {
constructor({ wrapSelector, slider }) {
this.wrap = document.querySelector(wrapSelector);
this.wrapSelector = wrapSelector;
this.slider = slider;
this.gridSize = this.slider.gridSize;
this.init();
}
createGameHTML() {
this.grid = new GridInit({
wrapSelector: this.wrapSelector,
slider: this.slider,
});
const header = createHTMLElement("div", { className: "header" });
const menuButton = createHTMLElement("button", {
className: "button menu-button",
textContent: "Back to menu",
});
header.appendChild(menuButton);
this.wrap.appendChild(header);
}
listeners() {
this.menuButton = document.querySelector(".menu-button");
this.menuButton.addEventListener("click", () => {
this.wrap.innerHTML = "";
new Homepage({ wrapSelector: this.wrapSelector });
});
}
init() {
this.createGameHTML();
this.listeners();
}
}