-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.js
More file actions
43 lines (40 loc) · 1.2 KB
/
menu.js
File metadata and controls
43 lines (40 loc) · 1.2 KB
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
class Menu{
constructor(){
this.setupMenu();
this.setupEventListeners();
}
setupMenu() {
// const $menuText = $('#menuText');
const $menu = $('#menu');
const title = $('<h1>Connect 4</h1>');
$menu.append(title);
const instruction = $('<h2>Choose a gamemode:</h2>');
$menu.append(instruction);
const $menuButtons = $('<div id="menuButtons"></div>');
const normalButton = $('<button id="normalButton">Normal</button>')
.addClass('normalButton')
$menuButtons.append(normalButton);
const $timedButton = $('<button id="timedButton">Timed</button>')
.addClass('timedButton')
$menuButtons.append($timedButton);
$menu.append($menuButtons);
}
setupEventListeners() {
const $menu = $('#menu');
$menu.on('click', '.normalButton', function() {
const $menu = $('#menu');
connect4.changeMode('normal');
$menu.empty();
connect4.createGrid();
connect4.createGameButtons();
});
$menu.on('click', '.timedButton', function() {
const $menu = $('#menu');
$menu.empty();
connect4.changeMode('timed');
connect4.createGrid();
connect4.createGameButtons();
timer.setupTimer();
});
}
}