-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
417 lines (368 loc) · 14.9 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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Invaders!</title>
<link rel="icon" type="image/webp" href="favicon.webp">
<style>
html, body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
background-color: #000000;
overflow: hidden;
color: white;
font-family: 'Arial', sans-serif;
}
body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
background-color: #000000;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
#gameContainer {
position: relative;
width: 1024px;
height: 576px;
}
#gameCanvas {
position: absolute;
left: 0;
top: 0;
}
#score, #version-info {
position: absolute;
color: #39FF14;
z-index: 1;
font-family: Arial, sans-serif;
}
#score {
left: 10px;
top: 10px;
}
#version-info {
right: 10px;
top: 30px;
color: #888;
}
#copyright {
position: fixed;
top: 10px;
right: 10px;
color: #888;
font-size: 12px;
}
#legend {
position: relative;
color: white;
font-size: 18px;
line-height: 1.4;
text-align: center;
margin: 20px auto;
width: min(600px, 90%);
padding: 20px;
background: rgba(0, 0, 0, 0.3);
border-radius: 15px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
margin-bottom: 60px;
}
#legend-title {
color: rgb(84, 206, 70);
font-size: 32px;
font-weight: bold;
text-align: center;
margin: 10px 0;
text-shadow: 0 0 15px rgba(84, 206, 70, 0.5);
letter-spacing: 2px;
}
.screenshot {
width: min(400px, 100%);
height: auto;
display: block;
border-radius: 10px;
}
.screenshot-frame {
background: linear-gradient(145deg, #2a2a2a, #333);
border: 2px solid #444;
border-radius: 12px;
padding: 10px;
width: fit-content;
margin: 20px auto;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
transform: perspective(1000px) rotateX(5deg);
transition: transform 0.3s ease;
}
.screenshot-frame:hover {
transform: perspective(1000px) rotateX(0deg);
}
#legend p {
margin: 8px 0;
padding: 5px;
background: rgba(255, 255, 255, 0.05);
border-radius: 5px;
transition: background-color 0.3s ease;
}
#legend p:hover {
background: rgba(255, 255, 255, 0.1);
}
.key-instruction {
display: inline-block;
padding: 3px 8px;
background: rgba(255, 255, 255, 0.1);
border-radius: 4px;
margin: 0 5px;
font-weight: bold;
}
/* Touch controls styling updates */
#touch-controls {
position: fixed;
bottom: 40px;
left: 0;
right: 0;
z-index: 1000;
display: flex;
justify-content: space-between;
padding: 0 20px;
}
.touch-button {
background: rgba(255, 255, 255, 0.15);
border: 2px solid rgba(255, 255, 255, 0.3);
color: white;
padding: 15px 30px;
margin: 5px;
border-radius: 8px;
font-size: 20px;
cursor: pointer;
backdrop-filter: blur(5px);
transition: all 0.3s ease;
}
.touch-button:active {
transform: scale(0.95);
background: rgba(255, 255, 255, 0.25);
}
.fire-button {
background: rgba(255, 50, 50, 0.2);
border-color: rgba(255, 50, 50, 0.4);
}
/* Media queries for better responsiveness */
@media (max-width: 768px) {
#legend {
font-size: 16px;
padding: 15px;
}
#legend-title {
font-size: 28px;
}
.touch-button {
padding: 12px 24px;
font-size: 18px;
}
}
@media (max-width: 480px) {
#legend {
font-size: 14px;
padding: 10px;
}
#legend-title {
font-size: 24px;
}
.touch-button {
padding: 10px 20px;
font-size: 16px;
}
}
.hits-counter {
position: fixed;
bottom: 20px;
left: 20px;
z-index: 1000;
opacity: 1;
pointer-events: all;
}
.game-header {
display: none;
}
#legend p:last-child {
margin-bottom: 0;
}
</style>
</head>
<body>
<div id="score">Score: 0</div>
<div id="version-info"></div>
<div id="copyright">© hot dog studios</div>
<div id="legend">
<div class="screenshot-frame">
<img src="screenshot.png" alt="Game Screenshot" class="screenshot">
</div>
<div id="legend-title">Invaders!</div>
<p>Use <span style="color: cyan;">cursor</span> keys, or <span style="color: cyan;">A</span> and <span style="color: cyan;">D</span></p>
<p><span style="color: cyan;">Space</span> to shoot - <span style="color: cyan;">M</span> to mute/unmute</p>
<p><span style="color: cyan;">P</span> to pause - <span style="color: cyan;">F1</span> AI mode!</p>
<p style="color: red; margin-top: 20px;">press any key to start</p>
</div>
<div class="hits-counter">
<a href="https://hits.seeyoufarm.com">
<img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fmoshix.github.io%2FeyeBMinvaders%2F&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/>
</a>
</div>
<canvas id="gameCanvas"></canvas>
<div id="touch-controls">
<div id="left-controls">
<button id="touch-left" class="touch-button">◀</button>
<button id="touch-fire-left" class="touch-button fire-button">🔥</button>
</div>
<div id="right-controls">
<button id="touch-fire-right" class="touch-button fire-button">🔥</button>
<button id="touch-right" class="touch-button">▶</button>
</div>
</div>
<button id="touch-start" class="touch-button">Start Game</button>
<script>
// More precise device detection
function detectDevice() {
const isMobile = /iPhone|Android/i.test(navigator.userAgent);
const isTablet = /(iPad|Android(?!.*Mobile))/i.test(navigator.userAgent);
const isPC = !isMobile && !isTablet;
const screenWidth = window.innerWidth;
return {
isMobile,
isTablet,
isPC,
screenWidth
};
}
// Handle device-specific display
function handleDeviceSpecificDisplay() {
const device = detectDevice();
const touchControls = document.getElementById('touch-controls');
const touchStart = document.getElementById('touch-start');
const legend = document.getElementById('legend');
// Get user's language
const userLanguage = navigator.language || navigator.userLanguage;
const isUnsupportedLocale = /^(ar|zh|ga|no|nb|nn|es)/i.test(userLanguage);
// Hide touch controls on PC
if (touchControls) touchControls.style.display = 'none';
if (touchStart) touchStart.style.display = 'none';
if (device.isMobile || (device.screenWidth < 768) || isUnsupportedLocale) {
// Show message for phones, narrow screens, or unsupported locales
legend.innerHTML = `
<div style="
padding: 20px;
background: rgba(255, 0, 0, 0.1);
border: 2px solid rgba(255, 0, 0, 0.3);
border-radius: 10px;
margin: 20px;
text-align: center;
font-size: 18px;
color: #fff;
">
<h2 style="color: #ff6b6b; margin-bottom: 15px;">Device Not Supported</h2>
eyeBMInvaders needs a wide enough screen.<br>
Try it now on your PC or tablet!<br>
Thank you!
</div>`;
} else if (device.isTablet) {
// Show touch controls only for tablets
if (touchControls) touchControls.style.display = 'flex';
if (touchStart) touchStart.style.display = 'block';
}
}
// Run on page load
document.addEventListener('DOMContentLoaded', handleDeviceSpecificDisplay);
// Run on resize
window.addEventListener('resize', handleDeviceSpecificDisplay);
</script>
<script>
// Proper touch device detection
function isTouchTablet() {
// Check if device has touch capability
const hasTouch = (('ontouchstart' in window) ||
(navigator.maxTouchPoints > 0) ||
(navigator.msMaxTouchPoints > 0));
// Check if it's not a desktop/laptop
const isNotDesktop = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
return hasTouch && isNotDesktop;
}
// Only show touch controls if we're on a tablet
if (isTouchTablet()) {
document.getElementById('touch-controls').style.display = 'block';
document.getElementById('touch-start').style.display = 'block';
// Remove the "press any key" text for touch devices
const keyPrompt = document.querySelector('#legend p[style*="color: red"]');
if (keyPrompt) {
keyPrompt.style.display = 'none';
}
}
</script>
<script>
function startGame() {
// Remove the hits counter completely from the DOM before transitioning
const hitsCounter = document.querySelector('.hits-counter');
if (hitsCounter) {
hitsCounter.remove();
}
// Hide the legend and start button
document.getElementById('legend').style.display = 'none';
document.getElementById('touch-start').style.display = 'none';
// Create and show firebirds.html in an iframe
const iframe = document.createElement('iframe');
iframe.style.width = '100%';
iframe.style.height = '100vh';
iframe.style.border = 'none';
iframe.src = 'firebirds.html';
document.body.appendChild(iframe);
// After 3 seconds, remove iframe and start the game
setTimeout(() => {
// Remove the iframe
iframe.remove();
// Show the canvas
const canvas = document.getElementById('gameCanvas');
canvas.style.display = 'block';
// Load and start game.js
const gameScript = document.createElement('script');
gameScript.src = 'game.js';
gameScript.onload = () => {
console.log('Game script loaded');
// Initialize the game after script loads
createEnemies();
startGameSound.currentTime = 0;
startGameSound.play();
requestAnimationFrame(gameLoop);
};
document.body.appendChild(gameScript);
}, 3000);
}
// Add debug logs
document.addEventListener('keydown', function(e) {
if (document.getElementById('legend').style.display !== 'none') {
console.log('Starting game sequence'); // Debug log
startGame();
}
});
</script>
<script>
// Set version on page load
document.addEventListener('DOMContentLoaded', () => {
const versionInfo = document.getElementById('version-info');
if (versionInfo) {
fetch('game.js')
.then(response => response.text())
.then(text => {
const versionMatch = text.match(/const VERSION = ["'](.+?)["']/);
if (versionMatch) {
versionInfo.textContent = versionMatch[1];
}
});
}
});
</script>
</body>
</html>