Upload index.html
Browse files- index.html +14 -7
index.html
CHANGED
|
@@ -11,9 +11,8 @@
|
|
| 11 |
text-shadow:0 2px 6px rgba(0,0,0,.45);pointer-events:none}
|
| 12 |
#hud b{font-size:13px;letter-spacing:.12em}
|
| 13 |
#hudText{animation:fade 1.2s ease 15s forwards}
|
| 14 |
-
@keyframes fade{ to{ opacity:0 } }
|
| 15 |
-
|
| 16 |
-
#fill{height:100%;width:0;background:#79d2ff;border-radius:3px}
|
| 17 |
#menu{position:fixed;right:16px;top:14px;width:250px;padding:12px 14px;pointer-events:auto;
|
| 18 |
background:rgba(10,37,64,.86);border:1px solid rgba(233,245,255,.22);border-radius:8px;
|
| 19 |
color:#e9f5ff;font:12px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;
|
|
@@ -32,7 +31,6 @@
|
|
| 32 |
<b>PUTT-PUTT ON THE GREAT SEA</b><br>
|
| 33 |
WASD or arrows throttle · A/D rudder · drag = camera · wheel = zoom · R = reset · M = menu
|
| 34 |
</div>
|
| 35 |
-
<div id="bar"><div id="fill"></div></div>
|
| 36 |
</div>
|
| 37 |
<div id="menu">
|
| 38 |
<b>MENU</b>
|
|
@@ -43,7 +41,6 @@
|
|
| 43 |
|
| 44 |
/* ================= gl ================= */
|
| 45 |
const cv = document.getElementById("c");
|
| 46 |
-
const fillEl = document.getElementById("fill");
|
| 47 |
const gl = cv.getContext("webgl2", { antialias: true });
|
| 48 |
if (!gl) { document.body.innerHTML = "<p style='color:#fff;font-family:monospace;padding:20px'>WebGL2 is required.</p>"; throw new Error("no webgl2"); }
|
| 49 |
|
|
@@ -961,6 +958,17 @@ const stopDrag = e=>{
|
|
| 961 |
};
|
| 962 |
cv.addEventListener("pointerup", stopDrag);
|
| 963 |
cv.addEventListener("pointercancel", stopDrag);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 964 |
addEventListener("pointermove", e=>{
|
| 965 |
if(!dragging) return;
|
| 966 |
dragYaw += (e.clientX-lastX)*0.006;
|
|
@@ -1259,8 +1267,7 @@ function frame(nowMs){
|
|
| 1259 |
}
|
| 1260 |
puffs = puffs.filter(p=>p.life < p.max);
|
| 1261 |
|
| 1262 |
-
/* ---
|
| 1263 |
-
fillEl.style.width = Math.round(Math.abs(boat.throttle)*100) + "%";
|
| 1264 |
if(AC){
|
| 1265 |
const lvl = Math.abs(boat.throttle);
|
| 1266 |
// the candle is always heating something, so at rest there is a soft idle chug rather than silence
|
|
|
|
| 11 |
text-shadow:0 2px 6px rgba(0,0,0,.45);pointer-events:none}
|
| 12 |
#hud b{font-size:13px;letter-spacing:.12em}
|
| 13 |
#hudText{animation:fade 1.2s ease 15s forwards}
|
| 14 |
+
@keyframes fade{ to{ opacity:0; visibility:hidden } }
|
| 15 |
+
canvas.idle{cursor:none}
|
|
|
|
| 16 |
#menu{position:fixed;right:16px;top:14px;width:250px;padding:12px 14px;pointer-events:auto;
|
| 17 |
background:rgba(10,37,64,.86);border:1px solid rgba(233,245,255,.22);border-radius:8px;
|
| 18 |
color:#e9f5ff;font:12px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;
|
|
|
|
| 31 |
<b>PUTT-PUTT ON THE GREAT SEA</b><br>
|
| 32 |
WASD or arrows throttle · A/D rudder · drag = camera · wheel = zoom · R = reset · M = menu
|
| 33 |
</div>
|
|
|
|
| 34 |
</div>
|
| 35 |
<div id="menu">
|
| 36 |
<b>MENU</b>
|
|
|
|
| 41 |
|
| 42 |
/* ================= gl ================= */
|
| 43 |
const cv = document.getElementById("c");
|
|
|
|
| 44 |
const gl = cv.getContext("webgl2", { antialias: true });
|
| 45 |
if (!gl) { document.body.innerHTML = "<p style='color:#fff;font-family:monospace;padding:20px'>WebGL2 is required.</p>"; throw new Error("no webgl2"); }
|
| 46 |
|
|
|
|
| 958 |
};
|
| 959 |
cv.addEventListener("pointerup", stopDrag);
|
| 960 |
cv.addEventListener("pointercancel", stopDrag);
|
| 961 |
+
// A cursor cannot be transitioned - it is drawn by the browser, not by the page - so it can only
|
| 962 |
+
// appear or disappear. It comes back on any movement, and stays put while you are dragging.
|
| 963 |
+
let cursorTimer = null;
|
| 964 |
+
function showCursor(){
|
| 965 |
+
cv.classList.remove("idle");
|
| 966 |
+
clearTimeout(cursorTimer);
|
| 967 |
+
cursorTimer = setTimeout(()=>{ if(!dragging) cv.classList.add("idle"); }, 1200);
|
| 968 |
+
}
|
| 969 |
+
cv.addEventListener("pointermove", showCursor);
|
| 970 |
+
cv.addEventListener("pointerleave", ()=>{ clearTimeout(cursorTimer); cv.classList.remove("idle"); });
|
| 971 |
+
cv.addEventListener("pointerdown", showCursor);
|
| 972 |
addEventListener("pointermove", e=>{
|
| 973 |
if(!dragging) return;
|
| 974 |
dragYaw += (e.clientX-lastX)*0.006;
|
|
|
|
| 1267 |
}
|
| 1268 |
puffs = puffs.filter(p=>p.life < p.max);
|
| 1269 |
|
| 1270 |
+
/* --- engine hum / water hiss levels --- */
|
|
|
|
| 1271 |
if(AC){
|
| 1272 |
const lvl = Math.abs(boat.throttle);
|
| 1273 |
// the candle is always heating something, so at rest there is a soft idle chug rather than silence
|