-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
49 lines (40 loc) · 1.37 KB
/
main.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
45
46
47
48
49
import Interface from './interface.js'
import Game from './game.js'
import './main.css';
class Main {
constructor() {
// interface
this.interface = new Interface(this);
// game
this.game = null;
// instructions
this.wrapper = document.createElement('div');
this.wrapper.setAttribute('class', 'wrapper');
document.body.appendChild(this.wrapper);
this.instructions = document.createElement('h1');
this.instructions.innerText = 'Loading...';
this.wrapper.appendChild(this.instructions);
// tongue icon
this.tongue = document.createElement('div');
this.tongue.setAttribute('class', 'tongue loading');
this.tongue.innerText = '👅';
this.wrapper.appendChild(this.tongue);
// count down
this.count = document.createElement('div');
this.count.setAttribute('class', 'count');
document.body.appendChild(this.count);
// training progress
this.progress = document.createElement('div');
this.progress.setAttribute('class', 'progress');
document.body.appendChild(this.progress);
}
playGame() {
this.instructions.innerText = 'Play Game !';
this.tongue.setAttribute('class', 'play tongue');
this.interface.view.setAttribute('class', 'view');
this.count.innerText = '';
this.interface.playing = true;
this.game = new Game(this);
}
}
window.addEventListener('load', () => new Main());