-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.html
377 lines (326 loc) · 11 KB
/
index.html
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-title" content="SYNTH*BLAST"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1"/>
<meta name="format-detection" content="telephone=no"/>
<link rel="apple-touch-icon" sizes="150x150" href="assets/img/apple-touch-icon.png">
<title>SYNTH * BLAST</title>
<style>
body, html {
margin: 0;
padding: 0;
position: fixed;
/*https://stackoverflow.com/questions/15829172/stop-chrome-back-forward-two-finger-swipe*/
overscroll-behavior-x: none;
background-color: #000000;
}
canvas {
width: 100%;
height: 100%;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
outline: none;
-webkit-tap-highlight-color: rgba(255, 255, 255, 0); /* mobile webkit */
}
</style>
<!-- <script data-ad-client="ca-pub-0228360753064464" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>-->
</head>
<body>
<!--<script src='js/Facebook.js'></script>-->
<script src='node_modules/stats.js/build/stats.min.js'></script>
<script src='lib/pixi.min.js'></script>
<script type="module">
import * as THREE from "./lib/three/build/three.module.js";
import Game from "./js/classes/Game.js";
import LevelScreen from "./js/classes/ui/LevelScreen.js";
import MenuScreen from "./js/classes/ui/MenuScreen.js";
// The state we will save and load
// when making a purchase, this state is sent to the servers,
// the servers modify and persist the state and a new state is retrieved
let playerState = {
activeGame: {
hp: {
value: 10,
max: 10
},
shields: {
value: 0,
max: 5
},
level: 1,
},
gamesPlayed: 0,
highScore: 0,
coins: 0,
settings: {
sound: true,
music: true
},
};
// Music
// let motel_bedroom = new Audio('music/motel_bedroom.mp3');
// if (motel_bedroom) motel_bedroom.loop = true;
let take_the_world = new Audio('music/taketheworld-outro.mp3');
if (take_the_world) take_the_world.loop = true;
let musicOn = true;
let songs = {
isSongPlaying: false,
motel_bedroom: take_the_world
};
// Sounds
let audioContext = null;
let soundsLoaded = false;
let sounds = {
pew: new Audio('assets/audio/pip2.wav'),
point: new Audio('assets/audio/point.wav'),
hit: new Audio('assets/audio/hit.wav'),
explosion: new Audio('assets/audio/explosion2.wav'),
impact: new Audio('assets/audio/impact.wav'),
flip: new Audio('assets/audio/flip.wav'),
shield: new Audio('assets/audio/shield.wav'),
launch: new Audio('assets/audio/launch.wav'),
energy: new Audio('assets/audio/energy3.wav')
};
// Renderers
let rendererThree;
let rendererPixi;
let game = null;
// screens
let levelUi = null;
let menuScreen = null;
let activeScreen = null;
let frameCount = 0;
let frameTimes = [];
let fpsAdjustment = 1;
// stats
let stats = new Stats();
stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
document.body.appendChild(stats.dom);
init();
animate();
function animate() {
stats.begin();
rendererThree.state.reset();
render3d();
rendererThree.state.reset();
rendererPixi.reset();
render2d();
rendererPixi.reset();
calculateFps();
stats.end();
requestAnimationFrame(animate);
}
function init() {
let canvas = document.getElementById("screen");
rendererThree = new THREE.WebGLRenderer({
canvas: canvas
});
rendererPixi = new PIXI.Renderer({
view: canvas,
context: rendererThree.getContext()
});
newGame();
// listeners
window.addEventListener('resize', resize, false);
document.addEventListener('keydown', keyDown, false);
document.addEventListener('keyup', keyUp, false);
document.addEventListener('touchstart', touchStart, {passive: false});
document.addEventListener('touchend', touchEnd, {passive: false});
document.body.addEventListener('touchmove', touchStart, {passive: false});
document.addEventListener('mousedown', mouseDown, false);
document.addEventListener('mouseup', mouseUp, false);
}
function newGame() {
let uiCallbacks = {
pressPlay: pressPlay,
newGame: newGame
};
game = new Game(rendererThree, sounds, window.innerWidth, window.innerHeight);
levelUi = new LevelScreen(game, rendererPixi, sounds, uiCallbacks);
menuScreen = new MenuScreen(game, rendererPixi, sounds, uiCallbacks);
activeScreen = menuScreen;
}
function keyDown(event) {
startAudio();
activeScreen.onDocumentKeyDown(event);
}
function keyUp(event) {
activeScreen.onDocumentKeyUp(event);
}
function touchStart(event) {
startAudio();
activeScreen.touchStart(event);
event.stopImmediatePropagation();
event.preventDefault();
}
function touchEnd(event) {
activeScreen.touchEnd(event);
}
function mouseDown(event) {
activeScreen.mouseDown(event);
}
function mouseUp(event) {
activeScreen.mouseUp(event);
}
function render3d() {
game.render(fpsAdjustment);
}
function render2d() {
activeScreen.render();
}
function pressPlay() {
activeScreen = levelUi;
}
function resize() {
game.updateWidthHeight(window.innerWidth, window.innerHeight);
game.level.camera.aspect = game.width / game.height;
game.level.camera.updateProjectionMatrix();
rendererThree.setSize(game.width, game.height);
activeScreen.init();
}
function startAudio() {
if (!audioContext) {
// https://stackoverflow.com/questions/9811429/html5-audio-tag-on-safari-has-a-delay
const AudioContext = window.AudioContext || window.webkitAudioContext;
audioContext = new AudioContext();
}
if (sounds && !soundsLoaded) {
for (let audio of Object.values(sounds)) {
audio.play();
audio.pause();
audio.currentTime = 0;
}
soundsLoaded = true;
}
if (musicOn && !songs.isSongPlaying) {
// gapless audio loop
// https://stackoverflow.com/questions/7330023/gapless-looping-audio-html5
songs.motel_bedroom.addEventListener('timeupdate', function () {
let buffer = .4;
if (this.currentTime > this.duration - buffer) {
this.currentTime = 0;
this.play();
}
}, false);
songs.motel_bedroom.play();
songs.isSongPlaying = true;
}
}
function calculateFps() {
frameCount++;
if (frameCount < 10) {
frameTimes.push((new Date()).getTime());
} else {
let frameIndex = frameCount % 10;
let now = (new Date()).getTime();
let then = frameTimes[frameIndex];
frameTimes[frameIndex] = now;
let fps = 10.0 / ((now - then) / 1000);
if (fps > 1) {
fpsAdjustment = 60 / fps;
}
}
}
function getHighScores() {
let url = 'https://example.com';
fetch(url)
.then(res => res.json())
.then((out) => {
console.log('Checkout this JSON! ', out);
})
.catch(err => {
throw err
});
}
</script>
<canvas id="screen">
<h1>SYNTH BLAST</h1>
<h2>Retro Shooter Cyberpunk Tank Game: Battlezone + Blade Runner 2049 + Synthwave</h2>
<p>
The goal of Synth Blast is to complete as many levels as possible as quickly as possible. Levels are policed
by malevolent tanks that home in on your position.
</p>
<p>
SYNTH BLAST is inspired by the first-person, futuristic tank shooter games of the 80's and early 90's as well as
classic synthesizer music. The neon colors, the Miami nights, the music, the
trees lining the road, the infinite road trip into the sunset that extends all through the night...
What's not to love about the 80's?
</p>
<p>
Games similar to Synth Blast:
<ul>
<li>Tank 1974</li>
<li>Battlezone 1980</li>
<li>Battle City 1985</li>
<li>Stellar 7 1983</li>
<li>Arcticfox 1986</li>
<li>Bolo 1987</li>
<li>Spectre 1990</li>
</ul>
</p>
<h3>
Features
</h3>
<p>
<ul>
<li>Top-down mode: "flip pad" launch you into a third-person perspective. Hitting another flip pad brings you
back down to first-person
</li>
<li>
Coin Magnets: pulls energy cubes (coins) to you if they are within a certain radius of your character. The
radius can be expanded with upgrades.
</li>
<li>
Shield Magnet: similar to the energy cube coin magnet, this will pull shields towards you. Pro tip: upgrade
this along with your shield maximum capacity.
</li>
</ul>
</p>
<h3>
Synth*Blast: Soundtrack
</h3>
<p>
Synth*Blast soundtrack: The hit retro sound of swirling, driving synthesizers and ethereal vocals.
Songs about love, alienation, longing and the expanse of eternity.
</p>
<h3>
Merchandise
</h3>
<p>
<ul>
<li>Hoodies</li>
<li>T-Shirts</li>
</ul>
</p>
</canvas>
<style>
#banner {
width: 320px;
height: 50px;
background-color: #000000;
margin-left: auto;
margin-right: auto;
}
</style>
<div id="banner">
<!-- <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>-->
<!-- <!– Synthblast responsive –>-->
<!-- <ins class="adsbygoogle"-->
<!-- style="display:block"-->
<!-- data-ad-client="ca-pub-0228360753064464"-->
<!-- data-ad-slot="3958750446"-->
<!-- data-ad-format="auto"-->
<!-- data-full-width-responsive="true"></ins>-->
<!-- <script>-->
<!-- (adsbygoogle = window.adsbygoogle || []).push({});-->
<!-- </script>-->
</div>
</body>
</html>