-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
68 lines (51 loc) 路 1.77 KB
/
Copy pathindex.js
File metadata and controls
68 lines (51 loc) 路 1.77 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const canvas = document.getElementById("myCanvas");
const ctx = canvas.getContext("2d");
// TITLE #####################################################################
ctx.font = "150px Courier";
ctx.fillStyle = "white";
ctx.textAlign = 'center';
ctx.fillText(`Security Console`, 750, 150);
// START THE GAME ############################################################
function startNight() {
button1.style.display = "none";
button2.style.display = "none";
ctx.font = "200px Courier";
ctx.fillStyle = "white";
ctx.textAlign = 'center';
ctx.clearRect(0, 0, 1500, 800);
ctx.fillText(`Night ${localStorage.getItem('Night')}`, 750, 300);
function reloadFile(file_name) {
let head = document.getElementsByTagName('head')[0];
let script = document.createElement('script');
script.src = `${file_name}.js`
head.appendChild(script);
}
reloadFile('data/player');
reloadFile('data/bots');
reloadFile('data/calls');
setTimeout(() => {
gameStart();
}, 3000);
}
// GET INPUTS #############################################################
let button1 = document.getElementById('button1');
button1.addEventListener('click', function handleClick() {
if (button1.innerHTML === 'Menu') {
location.reload();
} else if (button1.innerHTML === 'New Game') {
localStorage.setItem("Night", 1);
startNight();
}
});
let button2 = document.getElementById('button2');
button2.addEventListener('click', function handleClick() {
startNight();
});
let commandInput = document.getElementById("textInput");
commandInput.style.display = "none";
commandInput.addEventListener('keydown', (e) => {
if (e.key == 'Enter') {
command(commandInput.value);
commandInput.value = "";
}
});