|
1 | 1 | <!DOCTYPE html>
|
2 | 2 | <html lang="en">
|
3 | 3 | <head>
|
4 |
| - <meta charset="UTF-8"> |
5 |
| - <title>Emoji Shooter 🔫</title> |
6 |
| - <link rel="stylesheet" href="./main.css"> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | + <meta name="description" content="Authors: Andrii Doroshenko (@itsdorosh) and Kate Fastovets (@katfastovets); |
| 7 | + A minimalistic first-person shooter in which you have to shoot emojis flying at you. 😈 |
| 8 | + Game has support for gamepads."> |
| 9 | + <title>Emoji Shooter</title> |
| 10 | + <link rel="icon" href="assets/favicon.ico" type="image/x-icon"/> |
| 11 | + <link rel="stylesheet" href="./main.css"> |
7 | 12 | </head>
|
8 | 13 | <body>
|
9 |
| -<div id="inGameButtons" class="position-absolute hide"> |
10 |
| - <p id="pointsCount">Count: 0</p> |
11 |
| - <button id="pauseButton">Pause ⏸</button> |
| 14 | +<div id="headerContainer" class="position-absolute"> |
| 15 | + <p id="pointsCount">Count: 0</p> |
| 16 | + <button id="pauseButton">Pause ⏸</button> |
12 | 17 | </div>
|
13 | 18 |
|
14 |
| -<div id="gameButtons" class="position-absolute"> |
15 |
| - <h1 id="greetingCaption">Emoji Shooter 🔫</h1> |
16 |
| - <h1 id="gameOverCaption" class="hide">GAME OVER</h1> |
17 |
| - <button id="playButton">Play ▶️</button> |
18 |
| - <button id="restartButton" class="hide">Restart 🔄</button> |
| 19 | +<div id="menuContainer" class="position-absolute"> |
| 20 | + <h1 id="greetingCaption">Emoji Shooter 🔫</h1> |
| 21 | + <h1 id="gameOverCaption" class="hidden">GAME OVER</h1> |
| 22 | + <button id="playButton">Play ▶️</button> |
| 23 | + <button id="restartButton" class="hidden">Restart 🔄</button> |
19 | 24 | </div>
|
20 | 25 |
|
21 |
| -<div id="generalButtons" class="position-absolute"> |
22 |
| - <span id="fullscreenMode" onclick="toggleFullScreen()">📺️</span> |
23 |
| - <span id="gamepad" class="hide">🎮</span> |
24 |
| - <span id="mouse" class="hide">🖱</span> |
| 26 | +<div id="toolbarContainer" class="position-absolute"> |
| 27 | + <button id="gamepad">🎮</button> |
| 28 | + <button id="mouse">🖱</button> |
| 29 | + <button id="fullscreen">📺️</button> |
25 | 30 | </div>
|
26 | 31 |
|
27 | 32 | <div id="canvasContainer"></div>
|
28 | 33 |
|
29 |
| -<script src=" https://unpkg.com/[email protected]/build/three.js" ></script> |
30 |
| -<script src="./src/constants.js"></script> |
31 |
| -<script src="src/enemies.js"></script> |
32 |
| -<script src="./src/helpers.js"></script> |
33 |
| -<script src="./src/controls.js"></script> |
34 |
| -<script src="./src/raycaster.js"></script> |
35 |
| -<script src="./src/viewer.js"></script> |
36 |
| -<script src="./src/engine.js"></script> |
37 |
| - |
38 |
| -<script> |
39 |
| - // containers |
40 |
| - const canvasContainer = document.getElementById('canvasContainer'); |
41 |
| - const inGameButtons = document.getElementById('inGameButtons'); |
42 |
| - const gameButtons = document.getElementById('gameButtons'); |
43 |
| - |
44 |
| - // buttons |
45 |
| - const playButton = document.getElementById('playButton'); |
46 |
| - const pauseButton = document.getElementById('pauseButton'); |
47 |
| - const restartButton = document.getElementById('restartButton'); |
48 |
| - const gamepadButton = document.getElementById('gamepad'); |
49 |
| - const mouseButton = document.getElementById('mouse'); |
50 |
| - |
51 |
| - // captions |
52 |
| - const greetingCaption = document.getElementById('greetingCaption'); |
53 |
| - const gameOverCaption = document.getElementById('gameOverCaption'); |
54 |
| - |
55 |
| - const viewer = new Viewer(canvasContainer); |
56 |
| - const controls = new Controls(canvasContainer); |
57 |
| - const raycaster = new Raycaster(viewer.camera); |
58 |
| - const engine = new Engine(viewer, controls, raycaster); |
59 |
| - |
60 |
| - engine.onPointCountUpdate((count) => { |
61 |
| - document.getElementById('pointsCount').innerText = `Count: ${count}`; |
62 |
| - }); |
63 |
| - |
64 |
| - engine.onGameOver(() => { |
65 |
| - hide(greetingCaption, playButton); |
66 |
| - show(gameButtons, gameOverCaption, restartButton); |
67 |
| - }); |
68 |
| - |
69 |
| - playButton.addEventListener('click', () => { |
70 |
| - hide(gameButtons); |
71 |
| - show(inGameButtons); |
72 |
| - engine.play(); |
73 |
| - }); |
74 |
| - |
75 |
| - pauseButton.addEventListener('click', () => { |
76 |
| - show(gameButtons, restartButton, playButton); |
77 |
| - engine.pause(); |
78 |
| - }); |
79 |
| - |
80 |
| - restartButton.addEventListener('click', () => { |
81 |
| - hide(gameOverCaption, gameButtons); |
82 |
| - show(greetingCaption); |
83 |
| - engine.restart(); |
84 |
| - }); |
85 |
| - |
86 |
| - gamepadButton.addEventListener('click', () => controls.switchControlsMode(CONTROLS_MODES.GAMEPAD_MODE)); |
87 |
| - |
88 |
| - mouseButton.addEventListener('click', () => controls.switchControlsMode(CONTROLS_MODES.MOUSE_MODE)); |
89 |
| - |
90 |
| - controls.on('gamepadconnected', () => { |
91 |
| - controls.switchControlsMode(CONTROLS_MODES.MOUSE_MODE); |
92 |
| - }); |
93 |
| - |
94 |
| - controls.on('gamepaddisconnected', () => { |
95 |
| - controls.switchControlsMode(CONTROLS_MODES.NO_MODE); |
96 |
| - }); |
97 |
| - |
98 |
| - controls.on('controlsModeSwitched', (mode) => { |
99 |
| - switch (mode) { |
100 |
| - case CONTROLS_MODES.MOUSE_MODE: { |
101 |
| - hide(mouseButton); |
102 |
| - show(gamepadButton); |
103 |
| - break; |
104 |
| - } |
105 |
| - |
106 |
| - case CONTROLS_MODES.GAMEPAD_MODE: { |
107 |
| - hide(gamepadButton); |
108 |
| - show(mouseButton); |
109 |
| - break; |
110 |
| - } |
111 |
| - |
112 |
| - case CONTROLS_MODES.NO_MODE: { |
113 |
| - hide(mouseButton, gamepadButton); |
114 |
| - break; |
115 |
| - } |
116 |
| - } |
117 |
| - }); |
118 |
| - |
119 |
| - function toggleFullScreen() { |
120 |
| - if (!document.fullscreenElement) { |
121 |
| - document.documentElement.requestFullscreen(); |
122 |
| - } else { |
123 |
| - if (document.exitFullscreen) { |
124 |
| - document.exitFullscreen(); |
125 |
| - } |
126 |
| - } |
127 |
| - } |
128 |
| -</script> |
| 34 | +<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.js"></script> |
| 35 | +<script type="module" src="src/main.js"></script> |
129 | 36 | </body>
|
130 | 37 | </html>
|
0 commit comments