Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
119 lines (111 loc) · 4.68 KB
/
Copy pathindex.html
File metadata and controls
119 lines (111 loc) · 4.68 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
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
<!doctype html>
<html>
<head>
<title>Pique Catch — Online</title>
<link rel="icon" href="data:," />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
<style>
html, body {
background-color: #232426;
margin: 0;
height: 100%;
overflow: hidden;
font-family: -apple-system, Segoe UI, Roboto, sans-serif;
color: #f0f0f0;
-webkit-user-select: none;
user-select: none;
}
#game { width: 100%; height: 100%; }
canvas { display: block; }
/* ---- login ---- */
#login {
position: fixed; inset: 0; z-index: 20;
display: flex; flex-direction: column;
align-items: center; justify-content: center; gap: 18px;
padding: 16px; box-sizing: border-box; text-align: center;
background: radial-gradient(circle at 50% 35%, #2e2e30, #1a1b1c);
}
#login h1 { margin: 0; font-size: 42px; letter-spacing: 2px; color: #66c64b; text-shadow: 0 3px 0 #1f5a17; }
#login p { margin: 0; opacity: 0.7; font-size: 14px; }
#nick {
width: 280px; max-width: 80vw; padding: 14px 16px; font-size: 18px; text-align: center;
border: 2px solid #66c64b; border-radius: 8px; background: #18191a; color: #fff; outline: none;
}
#play {
width: 280px; max-width: 80vw; padding: 14px 16px; font-size: 18px; font-weight: 700;
border: none; border-radius: 8px; background: #66c64b; color: #10240b; cursor: pointer;
}
#play:active { transform: translateY(2px); }
#hint { font-size: 12px; opacity: 0.55; }
/* ---- touch controls ---- */
#touch {
position: fixed; inset: 0; z-index: 10; display: none;
pointer-events: none; /* only the buttons are interactive */
}
.tbtn {
position: absolute; bottom: 24px;
width: 84px; height: 84px; border-radius: 50%;
border: 2px solid rgba(255,255,255,0.5); background: rgba(255,255,255,0.18);
color: #fff; font-size: 30px; font-weight: 700;
display: flex; align-items: center; justify-content: center;
pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent;
}
.tbtn:active { background: rgba(255,255,255,0.4); }
#btn-left { left: 24px; }
#btn-right { left: 128px; }
#btn-jump { right: 24px; width: 96px; height: 96px; font-size: 18px; background: rgba(102,198,75,0.35); }
</style>
</head>
<body>
<div id="game"></div>
<div id="touch">
<button id="btn-left" class="tbtn" data-act="left">◀</button>
<button id="btn-right" class="tbtn" data-act="right">▶</button>
<button id="btn-jump" class="tbtn" data-act="jump">JUMP</button>
</div>
<div id="login">
<h1>PIQUE CATCH</h1>
<p>Global server — everyone plays together</p>
<input id="nick" maxlength="16" placeholder="Enter your nickname" autocomplete="off" autofocus />
<button id="play">PLAY</button>
<span id="hint">PC: A / D to move · W or Space to jump · Mobile: on-screen buttons</span>
</div>
<script type="module" src="/src/index.ts"></script>
<script>
(function () {
var input = document.getElementById('nick');
var login = document.getElementById('login');
var touch = document.getElementById('touch');
var isTouch = ('ontouchstart' in window) || navigator.maxTouchPoints > 0;
// --- touch controls -> shared flags read by the game (gameScene)
window.touchControls = { left: false, right: false, jump: false };
function bind(btn) {
var act = btn.getAttribute('data-act');
var down = function (e) { window.touchControls[act] = true; };
var up = function (e) { window.touchControls[act] = false; };
btn.addEventListener('pointerdown', down);
btn.addEventListener('pointerup', up);
btn.addEventListener('pointercancel', up);
btn.addEventListener('pointerleave', up);
}
var btns = document.querySelectorAll('.tbtn');
for (var i = 0; i < btns.length; i++) bind(btns[i]);
function start() {
var name = (input.value || '').trim();
if (!name) { input.focus(); return; }
if (typeof window.startGame === 'function') {
window.startGame(name); // exposed by the bundle (src/index.ts)
} else {
// bundle still loading — queue it; index.ts starts as soon as it loads
window.__pendingName = name;
var btn = document.getElementById('play');
btn.textContent = 'Loading…';
btn.disabled = true;
}
}
document.getElementById('play').addEventListener('click', start);
input.addEventListener('keydown', function (e) { if (e.key === 'Enter') start(); });
})();
</script>
</body>
</html>