Spaces:
Running
Running
Upload Custom Game_Sila.html
Browse files- Custom Game_Sila.html +769 -0
Custom Game_Sila.html
ADDED
|
@@ -0,0 +1,769 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 6 |
+
<title>Blox Haven β Collect, Build, Belong</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/baloo-2@5.0.20/index.css">
|
| 8 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/rubik@5.0.20/index.css">
|
| 9 |
+
<style>
|
| 10 |
+
*{margin:0;padding:0;box-sizing:border-box}
|
| 11 |
+
html,body{height:100%;overflow:hidden;background:#0b1020;font-family:'Rubik',system-ui,sans-serif;color:#fff;-webkit-user-select:none;user-select:none;touch-action:manipulation}
|
| 12 |
+
#game{position:fixed;inset:0;display:block}
|
| 13 |
+
.hidden{display:none!important}
|
| 14 |
+
.gold{color:#ffc531}
|
| 15 |
+
/* ---------- HUD ---------- */
|
| 16 |
+
#hud{position:fixed;inset:0;pointer-events:none;z-index:10}
|
| 17 |
+
#topbar{position:absolute;top:10px;left:10px;right:10px;display:flex;justify-content:space-between;align-items:flex-start;gap:8px}
|
| 18 |
+
.cluster{display:flex;gap:8px;align-items:center;flex-wrap:wrap;max-width:52%}
|
| 19 |
+
#menuBtns{justify-content:flex-end}
|
| 20 |
+
.panel{background:rgba(16,22,40,.85);border:1px solid rgba(255,255,255,.08);border-radius:14px;backdrop-filter:blur(6px);box-shadow:0 6px 20px rgba(0,0,0,.35)}
|
| 21 |
+
.pill{display:flex;align-items:center;gap:8px;padding:8px 14px;font-weight:700;font-size:15px}
|
| 22 |
+
.pill .ico{font-size:18px}
|
| 23 |
+
#lvBadge{width:48px;height:48px;border-radius:50%;display:flex;flex-direction:column;align-items:center;justify-content:center;background:linear-gradient(135deg,#00a2ff,#0066ff);font-family:'Baloo 2';box-shadow:0 4px 0 #003f99,0 6px 14px rgba(0,0,0,.35)}
|
| 24 |
+
#lvBadge span{font-size:18px;font-weight:800;line-height:1}
|
| 25 |
+
#lvBadge small{font-size:9px;opacity:.85;letter-spacing:1px}
|
| 26 |
+
#xpWrap{padding:8px 12px;min-width:150px}
|
| 27 |
+
#xpText{font-size:11px;font-weight:700;color:#cdd6f0}
|
| 28 |
+
#xpBarOuter{height:8px;background:rgba(255,255,255,.12);border-radius:99px;overflow:hidden;margin-top:5px}
|
| 29 |
+
#xpBar{height:100%;width:0%;background:linear-gradient(90deg,#00e5ff,#00ffa3);border-radius:99px;transition:width .3s}
|
| 30 |
+
.iconbtn{pointer-events:auto;width:46px;height:46px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:22px;cursor:pointer;background:rgba(16,22,40,.85);border:1px solid rgba(255,255,255,.1);box-shadow:0 4px 0 rgba(0,0,0,.4);transition:transform .08s}
|
| 31 |
+
.iconbtn:active{transform:translateY(2px);box-shadow:0 2px 0 rgba(0,0,0,.4)}
|
| 32 |
+
.iconbtn.pulse{animation:pulse 1.2s infinite}
|
| 33 |
+
@keyframes pulse{0%,100%{box-shadow:0 4px 0 rgba(0,0,0,.4),0 0 0 0 rgba(255,193,7,.7)}50%{box-shadow:0 4px 0 rgba(0,0,0,.4),0 0 0 9px rgba(255,193,7,0)}}
|
| 34 |
+
/* ---------- buttons ---------- */
|
| 35 |
+
.btn{font-family:'Baloo 2';border:none;border-radius:12px;padding:10px 20px;font-size:16px;font-weight:800;cursor:pointer;color:#fff;background:linear-gradient(180deg,#00b3ff,#0084ff);box-shadow:0 4px 0 #005ecb,0 6px 14px rgba(0,0,0,.3);transition:transform .08s}
|
| 36 |
+
.btn:active{transform:translateY(3px);box-shadow:0 1px 0 #005ecb}
|
| 37 |
+
.btn.green{background:linear-gradient(180deg,#2ee06e,#0fbf57);box-shadow:0 4px 0 #0a8a3e}
|
| 38 |
+
.btn.gold{background:linear-gradient(180deg,#ffd23f,#ff9a1f);box-shadow:0 4px 0 #c26a00;color:#3a2300}
|
| 39 |
+
.btn.gray{background:linear-gradient(180deg,#4b5577,#363f5e);box-shadow:0 4px 0 #232a44}
|
| 40 |
+
.btn.sm{padding:7px 14px;font-size:13px}
|
| 41 |
+
.btn.big{padding:14px 44px;font-size:20px}
|
| 42 |
+
.btn:disabled{filter:grayscale(.7);opacity:.55;cursor:not-allowed;transform:none}
|
| 43 |
+
.tag{display:inline-block;padding:4px 10px;border-radius:99px;background:#2a3354;font-size:12px;font-weight:700}
|
| 44 |
+
.tag.green{background:#0fbf57;color:#fff}
|
| 45 |
+
.tag.gray{opacity:.6}
|
| 46 |
+
/* ---------- prompt / tutorial / hints ---------- */
|
| 47 |
+
#prompt{position:fixed;bottom:90px;left:50%;transform:translateX(-50%);z-index:15;padding:10px 18px;border-radius:12px;font-weight:700;display:none;background:rgba(16,22,40,.92);border:1px solid rgba(255,255,255,.12);box-shadow:0 6px 20px rgba(0,0,0,.4)}
|
| 48 |
+
#prompt .key{background:#fff;color:#111;border-radius:6px;padding:2px 9px;font-family:'Baloo 2';margin-right:8px;font-weight:800}
|
| 49 |
+
#tutorial{position:fixed;top:74px;left:50%;transform:translateX(-50%);z-index:15;padding:12px 20px;max-width:min(540px,92vw);text-align:center}
|
| 50 |
+
.ttxt{font-size:15px;line-height:1.45}
|
| 51 |
+
.ttxt b{color:#7fd8ff}
|
| 52 |
+
.tdot{display:flex;gap:5px;justify-content:center;margin-bottom:8px}
|
| 53 |
+
.tdot i{width:8px;height:8px;border-radius:50%;background:#39406a;display:inline-block}
|
| 54 |
+
.tdot i.done{background:#2ee06e}.tdot i.cur{background:#ffc531;animation:pulse2 1s infinite}
|
| 55 |
+
@keyframes pulse2{50%{transform:scale(1.5)}}
|
| 56 |
+
#hints{position:fixed;right:12px;bottom:12px;z-index:12;padding:8px 14px;font-size:12px;color:#aab6d8;pointer-events:none}
|
| 57 |
+
/* ---------- toasts / floaters ---------- */
|
| 58 |
+
#toasts{position:fixed;left:12px;bottom:12px;z-index:30;display:flex;flex-direction:column;gap:8px;pointer-events:none;max-width:320px}
|
| 59 |
+
.toast{display:flex;gap:8px;align-items:center;font-size:14px;padding:10px 14px;animation:slideIn .3s}
|
| 60 |
+
@keyframes slideIn{from{transform:translateX(-16px);opacity:0}}
|
| 61 |
+
.toast.out{opacity:0;transform:translateX(-10px);transition:all .4s}
|
| 62 |
+
#floaters{position:fixed;inset:0;pointer-events:none;z-index:20;overflow:hidden}
|
| 63 |
+
.floater{position:absolute;font-family:'Baloo 2';font-weight:800;font-size:18px;text-shadow:0 2px 4px rgba(0,0,0,.6);white-space:nowrap}
|
| 64 |
+
.floater span{display:inline-block;transform:translate(-50%,-50%);animation:floatUp 1.2s ease-out forwards}
|
| 65 |
+
@keyframes floatUp{0%{opacity:0;transform:translate(-50%,-50%) translateY(8px)}15%{opacity:1}100%{opacity:0;transform:translate(-50%,-50%) translateY(-56px)}}
|
| 66 |
+
/* ---------- modal ---------- */
|
| 67 |
+
#modalRoot{position:fixed;inset:0;z-index:50;display:none;align-items:center;justify-content:center;background:rgba(5,8,18,.6);backdrop-filter:blur(3px);padding:14px}
|
| 68 |
+
#modalRoot.open{display:flex}
|
| 69 |
+
.modal{width:min(560px,94vw);max-height:88vh;overflow:auto;border-radius:20px;padding:22px;background:linear-gradient(180deg,#1a2342,#131a33);border:1px solid rgba(255,255,255,.1);box-shadow:0 20px 60px rgba(0,0,0,.6);animation:pop .25s}
|
| 70 |
+
@keyframes pop{from{transform:scale(.85);opacity:0}}
|
| 71 |
+
.mhead{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px}
|
| 72 |
+
.mhead h2{font-family:'Baloo 2';font-size:24px}
|
| 73 |
+
.mclose{width:34px;height:34px;border-radius:10px;border:none;background:#2a3354;color:#fff;font-size:18px;cursor:pointer}
|
| 74 |
+
.sub{color:#9aa5c0;font-size:14px;margin-bottom:12px}
|
| 75 |
+
.mrow{display:flex;gap:10px;justify-content:center;margin-top:16px;flex-wrap:wrap}
|
| 76 |
+
.tabs{display:flex;gap:6px;margin-bottom:12px}
|
| 77 |
+
.tab{flex:1;padding:8px;border-radius:10px;background:#202a4d;border:none;color:#aab;font-weight:700;cursor:pointer;font-family:'Rubik'}
|
| 78 |
+
.tab.on{background:linear-gradient(180deg,#00b3ff,#0084ff);color:#fff}
|
| 79 |
+
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(118px,1fr));gap:10px}
|
| 80 |
+
.item{background:#1c2547;border:2px solid #2a3354;border-radius:14px;padding:12px 8px;text-align:center}
|
| 81 |
+
.item.eq{border-color:#ffc531;box-shadow:0 0 0 2px rgba(255,193,7,.25)}
|
| 82 |
+
.iprev{font-size:34px;height:42px;display:flex;align-items:center;justify-content:center}
|
| 83 |
+
.iname{font-size:13px;font-weight:700;margin:4px 0 8px}
|
| 84 |
+
.swrow{margin-bottom:14px}
|
| 85 |
+
.swlabel{font-size:13px;font-weight:700;color:#9aa5c0;margin-bottom:6px}
|
| 86 |
+
.sws{display:flex;gap:8px;flex-wrap:wrap}
|
| 87 |
+
.sw{width:38px;height:38px;border-radius:10px;border:3px solid transparent;cursor:pointer}
|
| 88 |
+
.sw.on{border-color:#fff;transform:scale(1.08)}
|
| 89 |
+
.pack{background:#1c2547;border:2px solid #2a3354;border-radius:14px;padding:14px;text-align:center}
|
| 90 |
+
.pack .pv{font-size:22px;font-weight:800;font-family:'Baloo 2'}
|
| 91 |
+
.pack .pp{color:#9aa5c0;font-size:12px;margin:4px 0 8px}
|
| 92 |
+
.pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(128px,1fr));gap:10px}
|
| 93 |
+
.pcard{background:#1c2547;border:2px solid #2a3354;border-radius:14px;padding:12px 8px;text-align:center}
|
| 94 |
+
.pcard.eq{box-shadow:0 0 0 2px rgba(46,224,110,.35)}
|
| 95 |
+
.pcard.locked{opacity:.5}
|
| 96 |
+
.pemoji{font-size:38px;height:46px;display:flex;align-items:center;justify-content:center}
|
| 97 |
+
.pname{font-size:13px;font-weight:700;margin-top:2px}
|
| 98 |
+
.prarity{font-size:11px;font-weight:700;margin-top:2px}
|
| 99 |
+
.pmult{font-size:11px;color:#9aa5c0;margin:4px 0 8px}
|
| 100 |
+
.rc-Common{color:#c3cbd6}.rc-Rare{color:#5cb0ff}.rc-Epic{color:#c884ff}.rc-Legendary{color:#ffc531}.rc-Mythic{color:#ff6b8a}
|
| 101 |
+
.bc-Common{border-color:#5a6472}.bc-Rare{border-color:#3b9dff}.bc-Epic{border-color:#b45cff}.bc-Legendary{border-color:#ffb52e}.bc-Mythic{border-color:#ff4d6d}
|
| 102 |
+
.qrow{display:flex;gap:12px;align-items:center;background:#1c2547;border-radius:12px;padding:12px;margin-bottom:8px}
|
| 103 |
+
.qrow.done{opacity:.55}
|
| 104 |
+
.qico{font-size:26px}
|
| 105 |
+
.qmain{flex:1;min-width:0}
|
| 106 |
+
.qtxt{font-size:14px;font-weight:700}
|
| 107 |
+
.qbar{height:8px;background:#0e1430;border-radius:99px;overflow:hidden;margin:6px 0 4px}
|
| 108 |
+
.qbar i{display:block;height:100%;background:linear-gradient(90deg,#2ee06e,#00e5ff);border-radius:99px;transition:width .3s}
|
| 109 |
+
.qmeta{font-size:11px;color:#9aa5c0}
|
| 110 |
+
.srow{display:flex;gap:12px;align-items:center;background:#1c2547;border-radius:12px;padding:10px 12px;margin-bottom:6px}
|
| 111 |
+
.srow.done{opacity:.55}.srow.can{border:1px solid #2ee06e}
|
| 112 |
+
.snum{width:30px;height:30px;border-radius:50%;background:#2a3354;display:flex;align-items:center;justify-content:center;font-weight:800;font-family:'Baloo 2'}
|
| 113 |
+
.srew{flex:1;font-size:14px;font-weight:700}
|
| 114 |
+
.frow{display:flex;gap:12px;align-items:center;background:#1c2547;border-radius:12px;padding:12px;margin-bottom:8px}
|
| 115 |
+
.fava{width:42px;height:42px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:800;font-family:'Baloo 2';color:#1b2440}
|
| 116 |
+
.fmain{flex:1}
|
| 117 |
+
.fname{font-weight:700;font-size:14px}
|
| 118 |
+
.fstatus{font-size:11px;margin-left:6px}
|
| 119 |
+
.fstatus.on{color:#2ee06e}.fstatus.off{color:#7d87a8}
|
| 120 |
+
.fsub{font-size:12px;color:#9aa5c0;margin-top:2px}
|
| 121 |
+
.brow{display:flex;gap:12px;align-items:center;background:#1c2547;border-radius:10px;padding:9px 12px;margin-bottom:5px}
|
| 122 |
+
.brow.me{background:#243363;border:1px solid #00a2ff}
|
| 123 |
+
.brank{width:34px;font-weight:800;font-family:'Baloo 2';text-align:center}
|
| 124 |
+
.bname{flex:1;font-weight:700}
|
| 125 |
+
.bval{font-weight:700;color:#ffe066}
|
| 126 |
+
.days{display:grid;grid-template-columns:repeat(7,1fr);gap:6px;margin:12px 0}
|
| 127 |
+
.day{background:#1c2547;border-radius:10px;padding:8px 4px;text-align:center;position:relative;border:2px solid transparent}
|
| 128 |
+
.day.past{opacity:.45}.day.now{border-color:#ffc531;background:#2a3364}
|
| 129 |
+
.dnum{font-size:10px;color:#9aa5c0;font-weight:700}.drew{font-size:14px;font-weight:800;margin-top:4px}
|
| 130 |
+
.dtag{position:absolute;top:-8px;left:50%;transform:translateX(-50%);background:#ffc531;color:#3a2a00;font-size:9px;font-weight:800;padding:2px 6px;border-radius:99px;white-space:nowrap}
|
| 131 |
+
.miles{display:flex;gap:8px;margin-bottom:12px}
|
| 132 |
+
.mile{flex:1;background:#1c2547;border-radius:10px;padding:10px;text-align:center;font-size:12px}
|
| 133 |
+
.mile.locked{opacity:.55}
|
| 134 |
+
.streak{font-family:'Baloo 2';font-size:18px;text-align:center;margin-bottom:6px}
|
| 135 |
+
.statsline{margin-top:14px;padding-top:12px;border-top:1px solid rgba(255,255,255,.08);font-size:12px;color:#9aa5c0}
|
| 136 |
+
.reveal{text-align:center;padding:6px 0}
|
| 137 |
+
.raritytag{display:inline-block;padding:4px 14px;border-radius:99px;font-weight:800;font-size:12px;letter-spacing:1px;background:#0e1430;border:1px solid currentColor}
|
| 138 |
+
.bigemoji{font-size:88px;margin:14px 0 6px;animation:floaty 2s ease-in-out infinite;text-shadow:0 0 34px currentColor}
|
| 139 |
+
@keyframes floaty{0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)}}
|
| 140 |
+
.newtag{background:#2ee06e;color:#04331a;padding:3px 10px;border-radius:99px;font-weight:800;font-size:12px}
|
| 141 |
+
.rmult{color:#9aa5c0;margin:8px 0 4px}
|
| 142 |
+
.rebirthbox{text-align:center}
|
| 143 |
+
.rebirthbox .rbig{font-family:'Baloo 2';font-size:26px;color:#ffc531;margin-bottom:8px}
|
| 144 |
+
.rebirthbox p{color:#c7d0e8;margin:8px 0;font-size:14px}
|
| 145 |
+
.rnums{font-family:'Baloo 2';font-size:20px;margin:10px 0}
|
| 146 |
+
.keep{font-size:12px;color:#9aa5c0}
|
| 147 |
+
/* ---------- touch ---------- */
|
| 148 |
+
#touchUI{display:none}
|
| 149 |
+
@media(pointer:coarse){#touchUI{display:block}#hints{display:none}}
|
| 150 |
+
#joyBase{position:fixed;left:22px;bottom:26px;width:120px;height:120px;border-radius:50%;background:rgba(255,255,255,.12);border:2px solid rgba(255,255,255,.25);z-index:25;touch-action:none}
|
| 151 |
+
#joyKnob{position:absolute;left:50%;top:50%;width:52px;height:52px;margin:-26px;border-radius:50%;background:rgba(255,255,255,.5);pointer-events:none}
|
| 152 |
+
.tbtn{position:fixed;z-index:25;width:64px;height:64px;border-radius:50%;border:none;font-size:24px;font-weight:800;color:#fff;background:rgba(16,22,40,.7);border:2px solid rgba(255,255,255,.25);touch-action:none;font-family:'Baloo 2'}
|
| 153 |
+
#btnJump{right:26px;bottom:96px}
|
| 154 |
+
#btnAct{right:96px;bottom:26px}
|
| 155 |
+
/* ---------- loader ---------- */
|
| 156 |
+
#loader{position:fixed;inset:0;z-index:100;display:flex;flex-direction:column;align-items:center;justify-content:center;background:#0b1020 url('https://image.qwenlm.ai/public_source/22ea2f6a-3a3d-474a-9ee6-162831fd4867/1efafcdb1-4fce-40b8-a476-264c140fd94e.png') center/cover no-repeat;transition:opacity .6s}
|
| 157 |
+
#loader::before{content:'';position:absolute;inset:0;background:linear-gradient(180deg,rgba(8,12,26,.55),rgba(8,12,26,.9))}
|
| 158 |
+
#loader.done{opacity:0;pointer-events:none}
|
| 159 |
+
.lcontent{position:relative;z-index:2;display:flex;flex-direction:column;align-items:center;text-align:center;padding:20px}
|
| 160 |
+
.logo{font-family:'Baloo 2';font-size:clamp(44px,9vw,84px);font-weight:800;letter-spacing:2px;filter:drop-shadow(0 4px 0 rgba(0,0,0,.4));line-height:1}
|
| 161 |
+
.l1{background:linear-gradient(180deg,#ffe259,#ff9a3d);-webkit-background-clip:text;background-clip:text;color:transparent}
|
| 162 |
+
.l2{background:linear-gradient(180deg,#59d2ff,#3d7bff);-webkit-background-clip:text;background-clip:text;color:transparent}
|
| 163 |
+
.tagline{color:#dbe4ff;margin-top:8px;font-size:15px}
|
| 164 |
+
.chips{display:flex;gap:8px;flex-wrap:wrap;justify-content:center;margin:18px 0}
|
| 165 |
+
.chip{background:rgba(10,14,28,.7);border:1px solid rgba(255,255,255,.15);padding:6px 12px;border-radius:99px;font-size:13px;font-weight:600}
|
| 166 |
+
#nameInput{padding:12px 16px;border-radius:12px;border:2px solid rgba(255,255,255,.2);background:rgba(10,14,28,.8);color:#fff;font-size:16px;width:min(300px,80vw);text-align:center;font-family:'Rubik';margin-bottom:14px;outline:none}
|
| 167 |
+
#nameInput:focus{border-color:#00e5ff}
|
| 168 |
+
.hint{margin-top:16px;color:#c7d0e8;font-size:13px}
|
| 169 |
+
.fineprint{margin-top:10px;color:#7d87a8;font-size:11px;max-width:80vw}
|
| 170 |
+
@media(max-width:720px){.iconbtn{width:40px;height:40px;font-size:18px}#xpWrap{min-width:110px}.pill{padding:6px 10px;font-size:13px}.cluster{max-width:58%}}
|
| 171 |
+
</style>
|
| 172 |
+
</head>
|
| 173 |
+
<body>
|
| 174 |
+
<canvas id="game"></canvas>
|
| 175 |
+
|
| 176 |
+
<div id="hud">
|
| 177 |
+
<div id="topbar">
|
| 178 |
+
<div class="cluster">
|
| 179 |
+
<div id="lvBadge" class="panel"><span id="lvNum">1</span><small>LV</small></div>
|
| 180 |
+
<div id="xpWrap" class="panel"><div id="xpText">0/40 XP</div><div id="xpBarOuter"><div id="xpBar"></div></div></div>
|
| 181 |
+
<div class="pill panel"><span class="ico">πͺ</span><span id="coinVal">0</span></div>
|
| 182 |
+
<div class="pill panel"><span class="ico">π </span><span id="buxVal">0</span></div>
|
| 183 |
+
</div>
|
| 184 |
+
<div class="cluster" id="menuBtns">
|
| 185 |
+
<button class="iconbtn" id="btnDaily" onclick="openDaily()" title="Daily Rewards">π</button>
|
| 186 |
+
<button class="iconbtn" id="btnQuests" onclick="openQuests()" title="Quests">π</button>
|
| 187 |
+
<button class="iconbtn" onclick="openPets()" title="Pets">πΎ</button>
|
| 188 |
+
<button class="iconbtn" onclick="openShop('hats')" title="Shop">ποΈ</button>
|
| 189 |
+
<button class="iconbtn" onclick="openSeason()" title="Season Pass">π</button>
|
| 190 |
+
<button class="iconbtn" onclick="openFriends()" title="Friends">π₯</button>
|
| 191 |
+
<button class="iconbtn" onclick="openBoard('daily')" title="Leaderboard">π</button>
|
| 192 |
+
<button class="iconbtn" id="btnRebirth" onclick="useStatueModal()" title="Rebirth" style="display:none">β</button>
|
| 193 |
+
<button class="iconbtn" id="btnMute" onclick="toggleMute()" title="Sound">π</button>
|
| 194 |
+
</div>
|
| 195 |
+
</div>
|
| 196 |
+
</div>
|
| 197 |
+
|
| 198 |
+
<div id="tutorial" class="panel hidden"></div>
|
| 199 |
+
<div id="prompt"></div>
|
| 200 |
+
<div id="hints" class="panel">WASD move Β· SPACE jump Β· E interact</div>
|
| 201 |
+
<div id="floaters"></div>
|
| 202 |
+
<div id="toasts"></div>
|
| 203 |
+
|
| 204 |
+
<div id="touchUI">
|
| 205 |
+
<div id="joyBase"><div id="joyKnob"></div></div>
|
| 206 |
+
<button id="btnJump" class="tbtn">β¬</button>
|
| 207 |
+
<button id="btnAct" class="tbtn">E</button>
|
| 208 |
+
</div>
|
| 209 |
+
|
| 210 |
+
<div id="modalRoot"></div>
|
| 211 |
+
|
| 212 |
+
<div id="loader">
|
| 213 |
+
<div class="lcontent">
|
| 214 |
+
<div class="logo"><span class="l1">BLOX</span> <span class="l2">HAVEN</span></div>
|
| 215 |
+
<div class="tagline">Collect pets Β· Build your legend Β· Hang with friends</div>
|
| 216 |
+
<div class="chips"><span class="chip">πΎ 15 Pets</span><span class="chip">π Mystery Boxes</span><span class="chip">π Season 3</span><span class="chip">β Rebirth</span></div>
|
| 217 |
+
<input id="nameInput" maxlength="16" placeholder="Enter your username...">
|
| 218 |
+
<button id="playBtn" class="btn green big">βΆ PLAY</button>
|
| 219 |
+
<div class="hint">WASD to move Β· SPACE to jump Β· E to interact</div>
|
| 220 |
+
<div class="fineprint">Fan-made playable demo inspired by Roblox Β· Progress saves in your browser Β· All purchases are simulated (no real money)</div>
|
| 221 |
+
</div>
|
| 222 |
+
</div>
|
| 223 |
+
|
| 224 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
| 225 |
+
<script>
|
| 226 |
+
'use strict';
|
| 227 |
+
/* ============================= HELPERS ============================= */
|
| 228 |
+
const $=s=>document.querySelector(s);
|
| 229 |
+
const clamp=(v,a,b)=>Math.max(a,Math.min(b,v));
|
| 230 |
+
const rand=(a,b)=>a+Math.random()*(b-a);
|
| 231 |
+
const ri=(a,b)=>Math.floor(rand(a,b+1));
|
| 232 |
+
const pick=a=>a[Math.floor(Math.random()*a.length)];
|
| 233 |
+
const fmt=n=>n>=1e6?(n/1e6).toFixed(1)+'M':n>=1e3?(n/1e3).toFixed(1)+'k':''+Math.floor(n);
|
| 234 |
+
const todayStr=()=>new Date().toDateString();
|
| 235 |
+
const mmss=s=>{s=Math.max(0,Math.ceil(s));return Math.floor(s/60)+':'+String(s%60).padStart(2,'0')};
|
| 236 |
+
const getWeek=()=>Math.floor(Date.now()/6048e5);
|
| 237 |
+
const dist2D=(a,b)=>Math.hypot(a.x-b.x,a.z-b.z);
|
| 238 |
+
function lerpAngle(a,b,t){let d=(b-a)%(Math.PI*2);if(d>Math.PI)d-=Math.PI*2;if(d<-Math.PI)d+=Math.PI*2;return a+d*t}
|
| 239 |
+
function rr(x,a,b,w,h,r){x.beginPath();x.moveTo(a+r,b);x.arcTo(a+w,b,a+w,b+h,r);x.arcTo(a+w,b+h,a,b+h,r);x.arcTo(a,b+h,a,b,r);x.arcTo(a,b,a+w,b,r);x.closePath()}
|
| 240 |
+
|
| 241 |
+
/* ============================= DATA ============================= */
|
| 242 |
+
const RARITY_ORDER=[['Common',55],['Rare',25],['Epic',12],['Legendary',6],['Mythic',2]];
|
| 243 |
+
const RARITY_HEX={Common:0x9aa5b1,Rare:0x3b9dff,Epic:0xb45cff,Legendary:0xffb52e,Mythic:0xff4d6d};
|
| 244 |
+
const RARITY_CSS={Common:'#c3cbd6',Rare:'#5cb0ff',Epic:'#c884ff',Legendary:'#ffc531',Mythic:'#ff6b8a'};
|
| 245 |
+
const PETS=[
|
| 246 |
+
{id:'pup',name:'Blocky Pup',emoji:'πΆ',rarity:'Common',mult:1.15,body:0xc98a5b},
|
| 247 |
+
{id:'kit',name:'Pixel Kitty',emoji:'π±',rarity:'Common',mult:1.20,body:0x9aa5b1},
|
| 248 |
+
{id:'duk',name:'Quacko',emoji:'π¦',rarity:'Common',mult:1.10,body:0xffd23f},
|
| 249 |
+
{id:'bun',name:'Hoppy',emoji:'π°',rarity:'Common',mult:1.25,body:0xf5f0e8},
|
| 250 |
+
{id:'fox',name:'Ember Fox',emoji:'π¦',rarity:'Rare',mult:1.50,body:0xff7a3d},
|
| 251 |
+
{id:'pan',name:'Bamboo',emoji:'πΌ',rarity:'Rare',mult:1.60,body:0xe8e8e8},
|
| 252 |
+
{id:'bot',name:'B0T-4',emoji:'π€',rarity:'Rare',mult:1.70,body:0x8fa3b8},
|
| 253 |
+
{id:'frg',name:'Croak',emoji:'πΈ',rarity:'Rare',mult:1.55,body:0x58c95c},
|
| 254 |
+
{id:'drg',name:'Spark Dragon',emoji:'π²',rarity:'Epic',mult:2.30,body:0x37b24d},
|
| 255 |
+
{id:'uni',name:'Starlight',emoji:'π¦',rarity:'Epic',mult:2.50,body:0xf7a8d8},
|
| 256 |
+
{id:'gho',name:'Boo',emoji:'π»',rarity:'Epic',mult:2.20,body:0xdfe6ee},
|
| 257 |
+
{id:'gol',name:'Golden Golem',emoji:'πΏ',rarity:'Legendary',mult:3.60,body:0xf5b73d},
|
| 258 |
+
{id:'gal',name:'Galaxy Fox',emoji:'π',rarity:'Legendary',mult:4.00,body:0x5f3dc4},
|
| 259 |
+
{id:'rbw',name:'Rainbow Slime',emoji:'π',rarity:'Mythic',mult:6.50,body:0xff5d8f},
|
| 260 |
+
{id:'vod',name:'Void Wyvern',emoji:'π',rarity:'Mythic',mult:8.00,body:0x2b2f44}
|
| 261 |
+
];
|
| 262 |
+
const petById=id=>PETS.find(p=>p.id===id);
|
| 263 |
+
const HATS=[
|
| 264 |
+
{id:'none',name:'No Hat',price:0},{id:'cap',name:'Red Cap',price:50},{id:'top',name:'Top Hat',price:120},
|
| 265 |
+
{id:'prop',name:'Propeller',price:180},{id:'crown',name:'Royal Crown',price:250},{id:'halo',name:'Angel Halo',price:400}
|
| 266 |
+
];
|
| 267 |
+
const HAT_EMOJI={none:'π«',cap:'π§’',top:'π©',prop:'π',crown:'π',halo:'π'};
|
| 268 |
+
const TRAILS=[
|
| 269 |
+
{id:'none',name:'None',price:0},{id:'fire',name:'Fire Trail',price:150},{id:'ice',name:'Ice Trail',price:150},
|
| 270 |
+
{id:'gold',name:'Gold Trail',price:200},{id:'rainbow',name:'Rainbow Trail',price:250}
|
| 271 |
+
];
|
| 272 |
+
const TRAIL_EMOJI={none:'π«',fire:'π₯',ice:'βοΈ',gold:'β¨',rainbow:'π'};
|
| 273 |
+
const TRAIL_HEX={fire:0xff6b35,ice:0x7fd8ff,gold:0xffd700};
|
| 274 |
+
const SHIRT_COLORS=[0xe33b3b,0x3b9dff,0x2ee06e,0xffc531,0x9b59f5,0xff7a3d,0xf7a8d8,0x232734];
|
| 275 |
+
const SKINS=[0xf2c58f,0xe0ac69,0xc68642,0x8d5524,0xffdbac];
|
| 276 |
+
const PANTS_COLORS=[0x2e4a8f,0x232734,0x6b4a2f,0x557a3d,0x8f2e4a];
|
| 277 |
+
const SEASON=[
|
| 278 |
+
{t:1,r:{coins:200}},{t:2,r:{bux:50}},{t:3,r:{coins:500}},{t:4,r:{bux:100}},{t:5,r:{pet:'uni'}},
|
| 279 |
+
{t:6,r:{coins:1000}},{t:7,r:{bux:200}},{t:8,r:{coins:2000}},{t:9,r:{bux:300}},{t:10,r:{pet:'gal'}}
|
| 280 |
+
];
|
| 281 |
+
const NPC_NAMES=['NoobMaster69','xX_Blazer_Xx','PixelPirate','CoolCarla','BuilderBob','ShadowNinja','GlitterQueen','TurboTurtle','MegaMason','QueenBee','DriftKing','StarFox'];
|
| 282 |
+
const FRIENDS=[
|
| 283 |
+
{id:'luna',name:'Luna',color:'#f7a8d8',online:true,x:-24,z:14,wall:0xffd9a0,roof:0xe33b3b},
|
| 284 |
+
{id:'max',name:'Max',color:'#4da3ff',online:false,x:26,z:-12,wall:0xa8d0f0,roof:0x2e4a8f},
|
| 285 |
+
{id:'zoe',name:'Zoe',color:'#2ee06e',online:true,x:16,z:26,wall:0xc9f0c0,roof:0x2f9e44}
|
| 286 |
+
];
|
| 287 |
+
const SOCIAL=[
|
| 288 |
+
'{n} joined the server π','{n} opened a Legendary box! π','{n} reached Level {l} π',
|
| 289 |
+
'{n} adopted a Mythic pet! π','{n} is dominating the leaderboard π','{n} found a Rainbow Slime! π'
|
| 290 |
+
];
|
| 291 |
+
const PACKS=[{b:100,p:'$0.99'},{b:500,p:'$3.99'},{b:1200,p:'$7.99'}];
|
| 292 |
+
const FTUE=[
|
| 293 |
+
{txt:'Welcome to <b>Blox Haven</b>! π΄ Move with <b>WASD</b> (or the joystick) and explore the island a bit.'},
|
| 294 |
+
{txt:'Collect <b>5 coins</b> β just walk into them! <b>({n}/5)</b>'},
|
| 295 |
+
{txt:'Open your <b>FREE Mystery Box</b> at the purple station to adopt your first pet! πΎ'},
|
| 296 |
+
{txt:'Claim your <b>Daily Reward</b> β tap the π button up top.'},
|
| 297 |
+
{txt:'Visit a friend! Walk to <b>Luna\'s</b> or <b>Zoe\'s</b> house and press <b>E</b> at the green door ring.'}
|
| 298 |
+
];
|
| 299 |
+
function dailyReward(day){
|
| 300 |
+
const base=[{coins:100},{coins:150},{bux:50},{coins:250},{coins:300},{bux:75},{coins:1000,bux:100}];
|
| 301 |
+
if(day<=7)return base[day-1];
|
| 302 |
+
if(day===14)return {bux:200};
|
| 303 |
+
if(day===30)return {pet:'rbw'};
|
| 304 |
+
return {coins:200+day*10};
|
| 305 |
+
}
|
| 306 |
+
function rwText(r){const p=[];if(r.coins)p.push('πͺ '+r.coins);if(r.bux)p.push('π '+r.bux);if(r.pet)p.push(petById(r.pet).emoji+' pet');return p.join(' + ')}
|
| 307 |
+
function rwIcon(r){const p=[];if(r.coins)p.push('πͺ'+fmt(r.coins));if(r.bux)p.push('π '+fmt(r.bux));if(r.pet)p.push(petById(r.pet).emoji);return p.join(' ')}
|
| 308 |
+
|
| 309 |
+
/* ============================= STATE ============================= */
|
| 310 |
+
const SAVE_KEY='bloxhaven_v1';
|
| 311 |
+
const DEF={name:'',coins:0,bux:0,level:1,xp:0,totalCoins:0,coinsToday:0,
|
| 312 |
+
pets:{},activePet:null,hats:['none'],hat:'none',trails:['none'],trail:'none',
|
| 313 |
+
shirt:0x3b9dff,skin:0xf2c58f,pants:0x2e4a8f,
|
| 314 |
+
streak:0,lastLogin:'',dailyClaimedDate:'',
|
| 315 |
+
questDate:'',qProg:{coins:0,boxes:0,houses:0},qClaim:{},qNotified:{},
|
| 316 |
+
seasonPoints:0,seasonClaimed:[],
|
| 317 |
+
rebirths:0,firstBoxUsed:false,freeBoxAt:0,houseCd:{},boxesOpened:0,
|
| 318 |
+
ftueStep:0,ftueDist:0,ftueCoins:0,ftueVisit:0,muted:false};
|
| 319 |
+
let S=Object.assign({},DEF);
|
| 320 |
+
try{const p=JSON.parse(localStorage.getItem(SAVE_KEY)||'{}');for(const k in p)S[k]=p[k]}catch(e){}
|
| 321 |
+
function save(){try{localStorage.setItem(SAVE_KEY,JSON.stringify(S))}catch(e){}}
|
| 322 |
+
|
| 323 |
+
/* ============================= AUDIO ============================= */
|
| 324 |
+
let actx=null;
|
| 325 |
+
function audioInit(){if(!actx){try{actx=new (window.AudioContext||window.webkitAudioContext)()}catch(e){}}}
|
| 326 |
+
function tone(f,d,type,g,dl){if(!actx||S.muted)return;type=type||'square';g=g||.05;dl=dl||0;const t=actx.currentTime+dl,o=actx.createOscillator(),ga=actx.createGain();o.type=type;o.frequency.value=f;ga.gain.setValueAtTime(g,t);ga.gain.exponentialRampToValueAtTime(.0001,t+d);o.connect(ga);ga.connect(actx.destination);o.start(t);o.stop(t+d+.02)}
|
| 327 |
+
const sfx={
|
| 328 |
+
coin(){tone(950,.06,'square',.04);tone(1420,.08,'square',.04,.05)},
|
| 329 |
+
click(){tone(620,.04,'square',.03)},
|
| 330 |
+
err(){tone(170,.18,'sawtooth',.06)},
|
| 331 |
+
level(){[523,659,784,1046].forEach((f,i)=>tone(f,.12,'square',.05,i*.09))},
|
| 332 |
+
box(){tone(240,.12,'sawtooth',.05);tone(180,.12,'sawtooth',.05,.1)},
|
| 333 |
+
reveal(r){const base={Common:[660,880],Rare:[660,880,1100],Epic:[660,880,1100,1320],Legendary:[523,659,784,1046,1318],Mythic:[523,659,784,1046,1318,1568]}[r]||[660,880];base.forEach((f,i)=>tone(f,.14,'triangle',.06,i*.1))},
|
| 334 |
+
visit(){tone(700,.08,'triangle',.05);tone(940,.1,'triangle',.05,.08)},
|
| 335 |
+
buy(){tone(880,.07,'square',.04);tone(1174,.09,'square',.04,.06)},
|
| 336 |
+
rebirth(){[262,330,392,523,659,784].forEach((f,i)=>tone(f,.2,'sawtooth',.05,i*.12))}
|
| 337 |
+
};
|
| 338 |
+
|
| 339 |
+
/* ============================= THREE SETUP ============================= */
|
| 340 |
+
const canvas=$('#game');
|
| 341 |
+
const renderer=new THREE.WebGLRenderer({canvas,antialias:true});
|
| 342 |
+
renderer.setPixelRatio(Math.min(devicePixelRatio,2));
|
| 343 |
+
renderer.setSize(innerWidth,innerHeight);
|
| 344 |
+
renderer.shadowMap.enabled=true;renderer.shadowMap.type=THREE.PCFSoftShadowMap;
|
| 345 |
+
const scene=new THREE.Scene();
|
| 346 |
+
scene.background=new THREE.Color(0x87ceeb);
|
| 347 |
+
scene.fog=new THREE.Fog(0x87ceeb,55,150);
|
| 348 |
+
const camera=new THREE.PerspectiveCamera(60,innerWidth/innerHeight,.1,300);
|
| 349 |
+
camera.position.set(0,14,22);
|
| 350 |
+
const sun=new THREE.DirectionalLight(0xffffff,.95);
|
| 351 |
+
sun.position.set(30,50,20);sun.castShadow=true;
|
| 352 |
+
sun.shadow.mapSize.set(2048,2048);sun.shadow.camera.left=-60;sun.shadow.camera.right=60;sun.shadow.camera.top=60;sun.shadow.camera.bottom=-60;sun.shadow.camera.far=160;sun.shadow.bias=-.0005;
|
| 353 |
+
scene.add(sun);
|
| 354 |
+
scene.add(new THREE.HemisphereLight(0xbfe3ff,0x3f7d3a,.78));
|
| 355 |
+
const world=new THREE.Group();scene.add(world);
|
| 356 |
+
|
| 357 |
+
const matCache={};function mat(c){if(!matCache[c])matCache[c]=new THREE.MeshLambertMaterial({color:c});return matCache[c]}
|
| 358 |
+
|
| 359 |
+
/* ============================= TEXTURES ============================= */
|
| 360 |
+
function grassTexture(){const c=document.createElement('canvas');c.width=c.height=128;const x=c.getContext('2d');x.fillStyle='#67c04c';x.fillRect(0,0,128,128);for(let i=0;i<90;i++){x.fillStyle=Math.random()<.5?'#5db344':'#72cb57';const s=ri(4,10);x.fillRect(ri(0,122),ri(0,122),s,s)}const t=new THREE.CanvasTexture(c);t.wrapS=t.wrapT=THREE.RepeatWrapping;t.repeat.set(20,20);t.magFilter=THREE.NearestFilter;return t}
|
| 361 |
+
function qTexture(bg,fg,ch){const c=document.createElement('canvas');c.width=c.height=128;const x=c.getContext('2d');x.fillStyle=bg;x.fillRect(0,0,128,128);x.strokeStyle='rgba(255,255,255,.35)';x.lineWidth=6;x.strokeRect(6,6,116,116);x.fillStyle=fg;x.font='900 90px "Baloo 2",sans-serif';x.textAlign='center';x.textBaseline='middle';x.fillText(ch,64,72);return new THREE.CanvasTexture(c)}
|
| 362 |
+
function signMesh(text,bg,fg,w,h){const c=document.createElement('canvas');c.width=512;c.height=128;const x=c.getContext('2d');x.fillStyle=bg;rr(x,6,10,500,108,26);x.fill();x.strokeStyle='rgba(255,255,255,.25)';x.lineWidth=4;rr(x,6,10,500,108,26);x.stroke();x.fillStyle=fg;x.font='800 56px "Baloo 2",sans-serif';x.textAlign='center';x.textBaseline='middle';x.fillText(text,256,70);const t=new THREE.CanvasTexture(c);const m=new THREE.Mesh(new THREE.PlaneGeometry(w,h),new THREE.MeshBasicMaterial({map:t,transparent:true,side:THREE.DoubleSide}));return m}
|
| 363 |
+
function nameSprite(text,color,scale){const c=document.createElement('canvas');c.width=256;c.height=72;const x=c.getContext('2d');x.fillStyle='rgba(10,14,28,.72)';rr(x,4,8,248,56,16);x.fill();x.font='700 30px Rubik,sans-serif';x.textAlign='center';x.textBaseline='middle';x.fillStyle=color||'#fff';x.fillText((text||'').slice(0,14),128,38);const t=new THREE.CanvasTexture(c);const s=new THREE.Sprite(new THREE.SpriteMaterial({map:t,transparent:true,depthTest:false}));s.scale.set(2.6*(scale||1),.72*(scale||1),1);s.renderOrder=999;return s}
|
| 364 |
+
|
| 365 |
+
/* ============================= AVATAR / HAT / PET ============================= */
|
| 366 |
+
function buildAvatar(cfg){
|
| 367 |
+
const g=new THREE.Group();
|
| 368 |
+
const skin=mat(cfg.skin),shirt=mat(cfg.shirt),pants=mat(cfg.pants);
|
| 369 |
+
const legGeo=new THREE.BoxGeometry(.42,.95,.42);legGeo.translate(0,-.475,0);
|
| 370 |
+
const ll=new THREE.Mesh(legGeo,pants);ll.position.set(-.26,.95,0);
|
| 371 |
+
const rl=new THREE.Mesh(legGeo,pants);rl.position.set(.26,.95,0);
|
| 372 |
+
const torso=new THREE.Mesh(new THREE.BoxGeometry(.95,1.05,.5),shirt);torso.position.y=1.5;
|
| 373 |
+
const armGeo=new THREE.BoxGeometry(.38,1,.38);armGeo.translate(0,-.45,0);
|
| 374 |
+
const la=new THREE.Mesh(armGeo,skin);la.position.set(-.68,1.95,0);
|
| 375 |
+
const ra=new THREE.Mesh(armGeo,skin);ra.position.set(.68,1.95,0);
|
| 376 |
+
const head=new THREE.Mesh(new THREE.BoxGeometry(.72,.72,.72),skin);head.position.y=2.42;
|
| 377 |
+
const eyeGeo=new THREE.BoxGeometry(.09,.15,.03);const eyeM=mat(0x1c1c1c);
|
| 378 |
+
const le=new THREE.Mesh(eyeGeo,eyeM);le.position.set(-.16,2.5,.37);
|
| 379 |
+
const re=new THREE.Mesh(eyeGeo,eyeM);re.position.set(.16,2.5,.37);
|
| 380 |
+
const smile=new THREE.Mesh(new THREE.BoxGeometry(.24,.05,.03),eyeM);smile.position.set(0,2.32,.37);
|
| 381 |
+
g.add(ll,rl,torso,la,ra,head,le,re,smile);
|
| 382 |
+
g.traverse(o=>{if(o.isMesh)o.castShadow=true});
|
| 383 |
+
g.userData={ll,rl,la,ra};
|
| 384 |
+
return g;
|
| 385 |
+
}
|
| 386 |
+
function buildHat(id){
|
| 387 |
+
const h=new THREE.Group();
|
| 388 |
+
if(id==='cap'){const c=new THREE.Mesh(new THREE.BoxGeometry(.78,.18,.78),mat(0xe33b3b));c.position.y=.42;const brim=new THREE.Mesh(new THREE.BoxGeometry(.8,.06,.4),mat(0xb52c2c));brim.position.set(0,.36,.5);h.add(c,brim)}
|
| 389 |
+
else if(id==='top'){const b=new THREE.Mesh(new THREE.CylinderGeometry(.42,.42,.5,12),mat(0x22252e));b.position.y=.6;const br=new THREE.Mesh(new THREE.CylinderGeometry(.58,.58,.08,12),mat(0x22252e));br.position.y=.38;h.add(b,br)}
|
| 390 |
+
else if(id==='crown'){const base=new THREE.Mesh(new THREE.CylinderGeometry(.4,.44,.28,8),mat(0xffc531));base.position.y=.48;h.add(base);for(let i=0;i<4;i++){const s=new THREE.Mesh(new THREE.BoxGeometry(.12,.22,.12),mat(0xffc531));const a=i/4*Math.PI*2;s.position.set(Math.cos(a)*.3,.72,Math.sin(a)*.3);h.add(s)}}
|
| 391 |
+
else if(id==='prop'){const stick=new THREE.Mesh(new THREE.CylinderGeometry(.04,.04,.3,6),mat(0x888888));stick.position.y=.5;const blades=new THREE.Group();blades.position.y=.68;const b1=new THREE.Mesh(new THREE.BoxGeometry(.9,.05,.14),mat(0xff5d5d));const b2=new THREE.Mesh(new THREE.BoxGeometry(.14,.05,.9),mat(0x5db9ff));blades.add(b1,b2);h.add(stick,blades);h.userData.spin=blades}
|
| 392 |
+
else if(id==='halo'){const t=new THREE.Mesh(new THREE.TorusGeometry(.32,.06,8,20),mat(0xffe066));t.rotation.x=Math.PI/2;t.position.y=.62;h.add(t)}
|
| 393 |
+
h.traverse(o=>{if(o.isMesh)o.castShadow=true});
|
| 394 |
+
return h;
|
| 395 |
+
}
|
| 396 |
+
function buildPet(def){
|
| 397 |
+
const g=new THREE.Group();
|
| 398 |
+
const body=new THREE.Mesh(new THREE.BoxGeometry(.7,.6,.8),mat(def.body));body.position.y=.45;
|
| 399 |
+
const head=new THREE.Mesh(new THREE.BoxGeometry(.55,.5,.55),mat(def.body));head.position.set(0,.95,.15);
|
| 400 |
+
const eyeGeo=new THREE.BoxGeometry(.08,.1,.03);const eyeM=mat(0x1c1c1c);
|
| 401 |
+
const le=new THREE.Mesh(eyeGeo,eyeM);le.position.set(-.13,1,.43);
|
| 402 |
+
const re=new THREE.Mesh(eyeGeo,eyeM);re.position.set(.13,1,.43);
|
| 403 |
+
const e1=new THREE.Mesh(new THREE.BoxGeometry(.12,.22,.12),mat(def.body));e1.position.set(-.18,1.28,.15);
|
| 404 |
+
const e2=new THREE.Mesh(new THREE.BoxGeometry(.12,.22,.12),mat(def.body));e2.position.set(.18,1.28,.15);
|
| 405 |
+
g.add(body,head,le,re,e1,e2);
|
| 406 |
+
g.traverse(o=>{if(o.isMesh)o.castShadow=true});
|
| 407 |
+
return g;
|
| 408 |
+
}
|
| 409 |
+
function setLimbSwing(p,s){if(!p)return;p.ll.rotation.x=s;p.rl.rotation.x=-s;p.la.rotation.x=-s*.8;p.ra.rotation.x=s*.8}
|
| 410 |
+
|
| 411 |
+
/* ============================= WORLD BUILD ============================= */
|
| 412 |
+
const obstacles=[];const interactables=[];const npcs=[];const coins=[];const parts=[];const floats=[];
|
| 413 |
+
let mysteryBoxMesh,giftBoxMesh,stationRing,giftRing;
|
| 414 |
+
const BOX_POS=new THREE.Vector3(-12,0,-14),GIFT_POS=new THREE.Vector3(12,0,-16),STATUE_POS=new THREE.Vector3(0,0,-28);
|
| 415 |
+
const KEY_POINTS=[[0,6],[-12,-14],[12,-16],[0,-28],...FRIENDS.map(f=>[f.x,f.z])];
|
| 416 |
+
function farFromKey(x,z,min){return KEY_POINTS.every(p=>Math.hypot(x-p[0],z-p[1])>min)}
|
| 417 |
+
|
| 418 |
+
function buildWorld(){
|
| 419 |
+
const gtex=grassTexture();
|
| 420 |
+
const ground=new THREE.Mesh(new THREE.PlaneGeometry(120,120),new THREE.MeshLambertMaterial({map:gtex}));
|
| 421 |
+
ground.rotation.x=-Math.PI/2;ground.receiveShadow=true;world.add(ground);
|
| 422 |
+
const water=new THREE.Mesh(new THREE.PlaneGeometry(600,600),new THREE.MeshLambertMaterial({color:0x2ea8e0}));
|
| 423 |
+
water.rotation.x=-Math.PI/2;water.position.y=-.6;world.add(water);
|
| 424 |
+
const pad=new THREE.Mesh(new THREE.CylinderGeometry(4,4.3,.12,24),mat(0xd8d9dd));pad.position.set(0,.06,6);pad.receiveShadow=true;world.add(pad);
|
| 425 |
+
const padSign=signMesh('SPAWN','#1b2440','#7fd8ff',2.4,.6);padSign.position.set(0,1.4,9.6);world.add(padSign);
|
| 426 |
+
// trees
|
| 427 |
+
const trees=[];
|
| 428 |
+
for(let i=0;i<26;i++){let tries=0,x,z;do{x=rand(-46,46);z=rand(-46,46);tries++}while((!farFromKey(x,z,7)||trees.some(t=>Math.hypot(t.x-x,t.z-z)<4))&&tries<40);if(tries<40){trees.push({x,z});addTree(x,z)}}
|
| 429 |
+
for(let i=0;i<40;i++){let x=rand(-44,44),z=rand(-44,44);if(farFromKey(x,z,3)){const f=new THREE.Mesh(new THREE.BoxGeometry(.3,.3,.3),mat(pick([0xff5d8f,0xffd23f,0xffffff,0xc06bff])));f.position.set(x,.15,z);world.add(f)}}
|
| 430 |
+
for(let i=0;i<10;i++){let x=rand(-44,44),z=rand(-44,44);if(farFromKey(x,z,3)){const r=new THREE.Mesh(new THREE.BoxGeometry(1.2,.8,1.2),mat(0x8a909c));r.position.set(x,.4,z);r.rotation.y=rand(0,3);r.castShadow=true;world.add(r);obstacles.push({x,z,r:1})}}
|
| 431 |
+
FRIENDS.forEach(buildHouse);
|
| 432 |
+
buildStation(BOX_POS,'box');
|
| 433 |
+
buildStation(GIFT_POS,'gift');
|
| 434 |
+
buildStatue();
|
| 435 |
+
}
|
| 436 |
+
function addTree(x,z){const s=rand(.8,1.4);const t=new THREE.Group();const trunk=new THREE.Mesh(new THREE.BoxGeometry(.5*s,1.8*s,.5*s),mat(0x8a5a33));trunk.position.y=.9*s;const lv=new THREE.Mesh(new THREE.BoxGeometry(2.2*s,2.2*s,2.2*s),mat(pick([0x3f9b3f,0x57b849,0x2f8f4e])));lv.position.y=2.6*s;t.add(trunk,lv);t.position.set(x,0,z);t.traverse(o=>{if(o.isMesh)o.castShadow=true});world.add(t);obstacles.push({x,z,r:1.6*s})}
|
| 437 |
+
function buildHouse(f){
|
| 438 |
+
const g=new THREE.Group();
|
| 439 |
+
const base=new THREE.Mesh(new THREE.BoxGeometry(6,4,6),mat(f.wall));base.position.y=2;
|
| 440 |
+
const roof=new THREE.Mesh(new THREE.ConeGeometry(4.7,2.6,4),mat(f.roof));roof.position.y=5.3;roof.rotation.y=Math.PI/4;
|
| 441 |
+
const door=new THREE.Mesh(new THREE.BoxGeometry(1.5,2.5,.25),mat(0x5a3d28));door.position.set(0,1.25,3.0);
|
| 442 |
+
const w1=new THREE.Mesh(new THREE.BoxGeometry(1.1,1.1,.12),mat(0xbfe6ff));w1.position.set(-1.9,2.5,3.02);
|
| 443 |
+
const w2=w1.clone();w2.position.x=1.9;
|
| 444 |
+
g.add(base,roof,door,w1,w2);
|
| 445 |
+
const sign=signMesh(f.name+"'s House",'#1b2440','#ffffff',3.6,.95);sign.position.set(0,4.7,3.3);g.add(sign);
|
| 446 |
+
g.traverse(o=>{if(o.isMesh)o.castShadow=true});sign.castShadow=false;
|
| 447 |
+
g.position.set(f.x,0,f.z);g.rotation.y=Math.atan2(-f.x,-f.z);
|
| 448 |
+
world.add(g);obstacles.push({x:f.x,z:f.z,r:4.8});
|
| 449 |
+
f.sign=sign;f.bounce=0;
|
| 450 |
+
f.doorPos=new THREE.Vector3(f.x+Math.sin(g.rotation.y)*4.1,0,f.z+Math.cos(g.rotation.y)*4.1);
|
| 451 |
+
const ring=new THREE.Mesh(new THREE.RingGeometry(.7,1,20),new THREE.MeshBasicMaterial({color:0x2ee06e,transparent:true,opacity:.7,side:THREE.DoubleSide}));ring.rotation.x=-Math.PI/2;ring.position.set(f.doorPos.x,.05,f.doorPos.z);world.add(ring);
|
| 452 |
+
interactables.push({id:'house_'+f.id,pos:f.doorPos,r:3.6,label:()=>houseLabel(f),onUse:()=>useHouse(f)});
|
| 453 |
+
}
|
| 454 |
+
function buildStation(pos,kind){
|
| 455 |
+
const g=new THREE.Group();g.position.copy(pos);
|
| 456 |
+
const ped=new THREE.Mesh(new THREE.CylinderGeometry(1.7,1.9,.6,18),mat(0xb9bcc4));ped.position.y=.3;ped.castShadow=true;ped.receiveShadow=true;
|
| 457 |
+
const ring=new THREE.Mesh(new THREE.RingGeometry(2,2.5,24),new THREE.MeshBasicMaterial({color:kind==='box'?0xb45cff:0x2ee06e,transparent:true,opacity:.6,side:THREE.DoubleSide}));ring.rotation.x=-Math.PI/2;ring.position.y=.05;
|
| 458 |
+
const box=new THREE.Mesh(new THREE.BoxGeometry(1.3,1.3,1.3),new THREE.MeshLambertMaterial({map:qTexture(kind==='box'?'#7b2ff2':'#12b76a','#fff',kind==='box'?'?':'!')}));box.position.y=1.7;box.castShadow=true;
|
| 459 |
+
const sign=signMesh(kind==='box'?'MYSTERY BOX':'FREE GIFT',kind==='box'?'#3a1470':'#0a5a35','#ffffff',3,.8);sign.position.y=3.2;
|
| 460 |
+
g.add(ped,ring,box,sign);world.add(g);
|
| 461 |
+
if(kind==='box'){mysteryBoxMesh=box;stationRing=ring}else{giftBoxMesh=box;giftRing=ring}
|
| 462 |
+
obstacles.push({x:pos.x,z:pos.z,r:2.2});
|
| 463 |
+
interactables.push({id:kind,pos,r:3.6,label:()=>kind==='box'?boxLabel():giftLabel(),onUse:()=>kind==='box'?useBox():useGift()});
|
| 464 |
+
}
|
| 465 |
+
function buildStatue(){
|
| 466 |
+
const g=new THREE.Group();g.position.copy(STATUE_POS);
|
| 467 |
+
const base=new THREE.Mesh(new THREE.BoxGeometry(3.4,1,3.4),mat(0x9aa0ad));base.position.y=.5;base.castShadow=true;base.receiveShadow=true;
|
| 468 |
+
const ob=new THREE.Mesh(new THREE.BoxGeometry(1.2,4.8,1.2),mat(0xffc531));ob.position.y=3.4;ob.castShadow=true;
|
| 469 |
+
const tip=new THREE.Mesh(new THREE.ConeGeometry(.85,1.2,4),mat(0xffd768));tip.position.y=6.4;tip.rotation.y=Math.PI/4;
|
| 470 |
+
const sign=signMesh('STATUE OF LEGENDS','#1b2440','#ffd700',4,.9);sign.position.y=7.8;
|
| 471 |
+
const ring=new THREE.Mesh(new THREE.RingGeometry(2.4,2.9,24),new THREE.MeshBasicMaterial({color:0xffc531,transparent:true,opacity:.5,side:THREE.DoubleSide}));ring.rotation.x=-Math.PI/2;ring.position.y=.06;
|
| 472 |
+
g.add(base,ob,tip,sign,ring);g.traverse(o=>{if(o.isMesh)o.castShadow=true});sign.castShadow=false;
|
| 473 |
+
world.add(g);obstacles.push({x:0,z:-28,r:2.4});
|
| 474 |
+
interactables.push({id:'statue',pos:STATUE_POS,r:3.6,label:()=>statueLabel(),onUse:()=>useStatueModal()});
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
/* ============================= COINS / NPC / PARTICLES ============================= */
|
| 478 |
+
const coinGeo=new THREE.CylinderGeometry(.42,.42,.13,18);coinGeo.rotateZ(Math.PI/2);
|
| 479 |
+
const coinMat=new THREE.MeshLambertMaterial({color:0xffc531,emissive:0x7a5c00});
|
| 480 |
+
function spawnCoin(near){let x,z,tries=0;do{if(near){x=rand(-5,5);z=rand(1,11)}else{x=rand(-42,42);z=rand(-42,42)}tries++}while(!farFromKey(x,z,2.5)&&tries<25);const g=new THREE.Group();const m=new THREE.Mesh(coinGeo,coinMat);m.castShadow=true;g.add(m);g.position.set(x,.75,z);world.add(g);coins.push({g,phase:rand(0,6)})}
|
| 481 |
+
function spawnNPC(name){const cfg={skin:pick(SKINS),shirt:pick(SHIRT_COLORS),pants:pick(PANTS_COLORS)};const av=buildAvatar(cfg);const spr=nameSprite(name,'#cfd6e4',.8);spr.position.y=3.4;av.add(spr);av.position.set(rand(-30,30),0,rand(-30,30));world.add(av);npcs.push({av,parts:av.userData,name,tgt:new THREE.Vector3(rand(-38,38),0,rand(-38,38)),idle:rand(0,3),speed:rand(2.2,3.2),walkT:0})}
|
| 482 |
+
const partGeo=new THREE.BoxGeometry(.14,.14,.14);const partMats={};function pmat(c){if(!partMats[c])partMats[c]=new THREE.MeshBasicMaterial({color:c});return partMats[c]}
|
| 483 |
+
const RAINBOW=[];for(let i=0;i<12;i++)RAINBOW.push(new THREE.Color().setHSL(i/12,1,.6).getHex());
|
| 484 |
+
function burst(pos,color,n,spd){if(parts.length>260)return;for(let i=0;i<n;i++){const m=new THREE.Mesh(partGeo,pmat(color));m.position.copy(pos);const v=new THREE.Vector3(rand(-1,1),rand(.4,1.4),rand(-1,1)).normalize().multiplyScalar(rand(.5,1)*spd);parts.push({m,v,life:rand(.5,.9),max:.9});scene.add(m)}}
|
| 485 |
+
function confetti(pos,n){const cols=[0xffc531,0xff5d5d,0x5db9ff,0x2ee06e,0xc06bff,0xff7a3d];for(let i=0;i<n;i++)burst(pos,cols[i%cols.length],1,5)}
|
| 486 |
+
const _fv=new THREE.Vector3();
|
| 487 |
+
function floater(pos,text,color){const el=document.createElement('div');el.className='floater';el.innerHTML='<span>'+text+'</span>';el.style.color=color||'#ffe066';$('#floaters').appendChild(el);floats.push({el,p:pos.clone?pos.clone():new THREE.Vector3(pos.x,pos.y,pos.z),life:1.2})}
|
| 488 |
+
|
| 489 |
+
/* ============================= ECONOMY / PROGRESSION ============================= */
|
| 490 |
+
function xpNeed(l){return Math.floor(40*Math.pow(l,1.4))}
|
| 491 |
+
function petMultOf(d,l){return d.mult*(1+(l-1)*.15)}
|
| 492 |
+
function petMult(){if(!S.activePet)return 1;const d=petById(S.activePet);return petMultOf(d,S.pets[S.activePet]||1)}
|
| 493 |
+
function multTotal(){return petMult()*(1+.25*S.rebirths)}
|
| 494 |
+
function addCoins(n){S.coins+=n;S.totalCoins+=n;S.coinsToday+=n;S.qProg.coins+=n}
|
| 495 |
+
function gainXP(n){S.xp+=n;let need=xpNeed(S.level);while(S.xp>=need){S.xp-=need;S.level++;S.seasonPoints++;const rw=100*S.level;S.coins+=rw;S.coinsToday+=rw;S.totalCoins+=rw;sfx.level();toast('π Level '+S.level+'! +'+rw+' coins');confetti(player.position.clone().add(new THREE.Vector3(0,2.5,0)),24);floater(player.position.clone().add(new THREE.Vector3(0,3,0)),'LEVEL UP!','#7CFF6B');need=xpNeed(S.level)}updateHUD()}
|
| 496 |
+
function rollRarity(){let r=Math.random()*100;for(const [name,odds] of RARITY_ORDER){if(r<odds)return name;r-=odds}return 'Common'}
|
| 497 |
+
function grantRewards(r){if(r.coins){S.coins+=r.coins;S.totalCoins+=r.coins;S.coinsToday+=r.coins}if(r.bux)S.bux+=r.bux;if(r.pet){const d=petById(r.pet);grantPet(d,false,true)}}
|
| 498 |
+
function grantPet(def,viaBox,quiet){
|
| 499 |
+
const before=S.pets[def.id]||0;S.pets[def.id]=before+1;const lvl=S.pets[def.id];
|
| 500 |
+
if(!S.activePet){S.activePet=def.id;refreshPetMesh()}
|
| 501 |
+
if(quiet){toast('πΎ New pet: '+def.emoji+' '+def.name+'!');updateHUD();save();return}
|
| 502 |
+
sfx.reveal(def.rarity);
|
| 503 |
+
burst(BOX_POS.clone().setY(1.5),RARITY_HEX[def.rarity],26,5);
|
| 504 |
+
const isNew=before===0;
|
| 505 |
+
openModal('<div class="reveal"><div class="raritytag rc-'+def.rarity+'">'+def.rarity.toUpperCase()+'</div><div class="bigemoji rc-'+def.rarity+'">'+def.emoji+'</div><h2 class="rc-'+def.rarity+'">'+def.name+'</h2><div class="rsub">'+(isNew?'<span class="newtag">NEW PET!</span>':'Level Up β Lv '+lvl+' (Γ'+petMultOf(def,lvl).toFixed(1)+' coins)')+'</div><div class="rmult">Coin multiplier Γ'+petMultOf(def,lvl).toFixed(1)+'</div><div class="mrow"><button class="btn gold" onclick="closeModal();useBox()">Open Another'+(S.firstBoxUsed?' (250 πͺ)':'')+'</button><button class="btn" onclick="closeModal();openPets()">My Pets</button><button class="btn gray" onclick="closeModal()">Close</button></div></div>');
|
| 506 |
+
updateHUD();save();
|
| 507 |
+
}
|
| 508 |
+
function collectCoin(c){const amt=Math.round(5*multTotal());addCoins(amt);gainXP(2);S.ftueCoins++;sfx.coin();floater(c.g.position,'+'+amt,'#ffe066');burst(c.g.position,0xffc531,6,3);world.remove(c.g);const i=coins.indexOf(c);if(i>=0)coins.splice(i,1);checkFTUE();checkQuests();if(S.ftueStep===1)renderTutorial();updateHUD()}
|
| 509 |
+
|
| 510 |
+
/* ============================= INTERACTIONS ============================= */
|
| 511 |
+
function boxLabel(){if(!S.firstBoxUsed)return 'π FREE Mystery Box β adopt a pet!';return S.coins>=250?'π Mystery Box β 250 πͺ':'π Mystery Box β need 250 πͺ'}
|
| 512 |
+
function giftLabel(){const rem=(S.freeBoxAt-Date.now())/1000;return rem>0?'π Gift recharging β '+mmss(rem):'π Open your Free Gift!'}
|
| 513 |
+
function statueLabel(){return S.level>=15?'β Statue of Legends β REBIRTH available!':'β Statue of Legends β reach Lv 15 (now '+S.level+')'}
|
| 514 |
+
function houseLabel(f){if(!f.online)return 'π€ '+f.name+' is away';const rem=(S.houseCd[f.id]||0)-Date.now();if(rem>0)return 'π '+f.name+"'s House β next visit in "+mmss(rem/1000);return 'π Visit '+f.name+"'s House"}
|
| 515 |
+
function useBox(){
|
| 516 |
+
const cost=S.firstBoxUsed?250:0;
|
| 517 |
+
if(S.coins<cost){sfx.err();toast('Not enough coins! Collect more πͺ');return}
|
| 518 |
+
S.coins-=cost;S.boxesOpened++;S.qProg.boxes++;if(!S.firstBoxUsed)S.firstBoxUsed=true;
|
| 519 |
+
sfx.box();const rar=rollRarity();const def=pick(PETS.filter(p=>p.rarity===rar));
|
| 520 |
+
grantPet(def,true,false);checkQuests();checkFTUE();updateHUD();save();
|
| 521 |
+
}
|
| 522 |
+
let giftNotified=false;
|
| 523 |
+
function useGift(){
|
| 524 |
+
const now=Date.now();if(now<S.freeBoxAt){sfx.err();toast('β³ Gift recharging β '+mmss((S.freeBoxAt-now)/1000));return}
|
| 525 |
+
S.freeBoxAt=now+120000;giftNotified=false;sfx.buy();burst(GIFT_POS.clone().setY(1.5),0x2ee06e,18,4);
|
| 526 |
+
if(Math.random()<.15){const def=pick(PETS.filter(p=>p.rarity==='Common'||p.rarity==='Rare'));grantPet(def,false,true)}
|
| 527 |
+
else{const amt=ri(75,200);addCoins(amt);gainXP(8);floater(GIFT_POS.clone().setY(1.5),'+'+amt,'#7CFF6B');toast('π Free gift: +'+amt+' coins!')}
|
| 528 |
+
checkQuests();updateHUD();save();
|
| 529 |
+
}
|
| 530 |
+
function useHouse(f){
|
| 531 |
+
if(!f.online){toast(f.name+' is away right now π€');sfx.err();return}
|
| 532 |
+
const now=Date.now();const cd=S.houseCd[f.id]||0;if(now<cd){sfx.err();return}
|
| 533 |
+
S.houseCd[f.id]=now+90000;const amt=Math.round(30*multTotal());addCoins(amt);gainXP(15);S.qProg.houses++;S.ftueVisit++;
|
| 534 |
+
sfx.visit();toast('π '+f.name+' thanks you! +'+amt+' coins');floater(f.doorPos.clone().setY(1.5),'+'+amt,'#ffe066');f.bounce=2.5;checkQuests();checkFTUE();updateHUD();save();
|
| 535 |
+
}
|
| 536 |
+
function useStatueModal(){if(S.level>=15)openRebirth();else toast('Reach Level 15 to Rebirth β')}
|
| 537 |
+
function nearestInteract(){let best=null,bd=16;for(const it of interactables){const d=dist2D(player.position,it.pos);if(d<it.r&&d<bd){bd=d;best=it}}return best}
|
| 538 |
+
function tryInteract(){if(!gameStarted||modalOpen)return;const it=nearestInteract();if(it)it.onUse()}
|
| 539 |
+
|
| 540 |
+
/* ============================= MODAL SYSTEM ============================= */
|
| 541 |
+
const modalRoot=$('#modalRoot');let modalOpen=false;let shopTab='hats',boardTab='daily';
|
| 542 |
+
function mh(t){return '<div class="mhead"><h2>'+t+'</h2><button class="mclose" onclick="closeModal()">β</button></div>'}
|
| 543 |
+
function openModal(html){modalRoot.innerHTML='<div class="modal">'+html+'</div>';modalRoot.classList.add('open');modalOpen=true;sfx.click()}
|
| 544 |
+
function closeModal(){modalRoot.classList.remove('open');modalRoot.innerHTML='';modalOpen=false}
|
| 545 |
+
modalRoot.addEventListener('click',e=>{if(e.target===modalRoot)closeModal()});
|
| 546 |
+
|
| 547 |
+
function openShop(tab){
|
| 548 |
+
shopTab=tab||'hats';let body='';
|
| 549 |
+
if(shopTab==='hats'){body='<div class="grid">'+HATS.map(h=>{const owned=S.hats.includes(h.id);const eq=S.hat===h.id;return '<div class="item '+(eq?'eq':'')+'"><div class="iprev">'+HAT_EMOJI[h.id]+'</div><div class="iname">'+h.name+'</div><div>'+(eq?'<span class="tag green">EQUIPPED</span>':owned?'<button class="btn sm" onclick="buyItem(\'hat\',\''+h.id+'\')">Equip</button>':'<button class="btn sm gold" onclick="buyItem(\'hat\',\''+h.id+'\')">'+h.price+' π </button>')+'</div></div>'}).join('')+'</div>'}
|
| 550 |
+
else if(shopTab==='trails'){body='<div class="grid">'+TRAILS.map(t=>{const owned=S.trails.includes(t.id);const eq=S.trail===t.id;return '<div class="item '+(eq?'eq':'')+'"><div class="iprev">'+TRAIL_EMOJI[t.id]+'</div><div class="iname">'+t.name+'</div><div>'+(eq?'<span class="tag green">EQUIPPED</span>':owned?'<button class="btn sm" onclick="buyItem(\'trail\',\''+t.id+'\')">Equip</button>':'<button class="btn sm gold" onclick="buyItem(\'trail\',\''+t.id+'\')">'+t.price+' π </button>')+'</div></div>'}).join('')+'</div>'}
|
| 551 |
+
else if(shopTab==='colors'){body=swatchRow('Shirt','shirt',SHIRT_COLORS)+swatchRow('Skin','skin',SKINS)+swatchRow('Pants','pants',PANTS_COLORS)}
|
| 552 |
+
else{body='<div class="sub">Simulated store β no real money is charged.</div><div class="grid">'+PACKS.map((p,i)=>'<div class="pack"><div class="pv">π '+p.b+'</div><div class="pp">'+p.p+' (simulated)</div><button class="btn gold sm" onclick="buyBux('+i+')">Get Bux</button></div>').join('')+'</div>'}
|
| 553 |
+
const tabs='<div class="tabs">'+['hats','trails','colors','bux'].map(t=>'<button class="tab '+(shopTab===t?'on':'')+'" onclick="openShop(\''+t+'\')">'+(t==='bux'?'Get Bux':t[0].toUpperCase()+t.slice(1))+'</button>').join('')+'</div>';
|
| 554 |
+
openModal(mh('ποΈ Blox Mart')+'<div class="sub">Cosmetics only β no pay-to-win. You have <b class="gold">'+fmt(S.bux)+' π </b></div>'+tabs+body);
|
| 555 |
+
}
|
| 556 |
+
function swatchRow(label,kind,colors){return '<div class="swrow"><div class="swlabel">'+label+'</div><div class="sws">'+colors.map(c=>'<button class="sw '+(S[kind]===c?'on':'')+'" style="background:#'+c.toString(16).padStart(6,'0')+'" onclick="setColor(\''+kind+'\','+c+')"></button>').join('')+'</div></div>'}
|
| 557 |
+
function setColor(kind,val){S[kind]=val;sfx.click();refreshAvatar();openShop('colors');save()}
|
| 558 |
+
function buyItem(kind,id){
|
| 559 |
+
const list=kind==='hat'?HATS:TRAILS;const it=list.find(x=>x.id===id);const owned=(kind==='hat'?S.hats:S.trails).includes(id);
|
| 560 |
+
if(owned){if(kind==='hat')S.hat=id;else S.trail=id;sfx.click();refreshAvatar();openShop(shopTab);save();return}
|
| 561 |
+
if(S.bux<it.price){sfx.err();toast('Not enough Bux! π ');return}
|
| 562 |
+
S.bux-=it.price;(kind==='hat'?S.hats:S.trails).push(id);if(kind==='hat')S.hat=id;else S.trail=id;
|
| 563 |
+
sfx.buy();toast('ποΈ Purchased '+it.name+'!');refreshAvatar();updateHUD();openShop(shopTab);save();
|
| 564 |
+
}
|
| 565 |
+
function buyBux(i){S.bux+=PACKS[i].b;sfx.buy();toast('π +'+PACKS[i].b+' Bux β simulated purchase, no real money charged!');confetti(player.position.clone().add(new THREE.Vector3(0,2.5,0)),16);updateHUD();openShop('bux');save()}
|
| 566 |
+
function openPets(){
|
| 567 |
+
const owned=Object.keys(S.pets).length;
|
| 568 |
+
const cards=PETS.map(d=>{const has=!!S.pets[d.id];const lvl=S.pets[d.id]||0;const eq=S.activePet===d.id;
|
| 569 |
+
if(!has)return '<div class="pcard locked"><div class="pemoji">β</div><div class="pname">???</div><div class="prarity rc-'+d.rarity+'">'+d.rarity+'</div></div>';
|
| 570 |
+
return '<div class="pcard bc-'+d.rarity+' '+(eq?'eq':'')+'"><div class="pemoji">'+d.emoji+'</div><div class="pname">'+d.name+'</div><div class="prarity rc-'+d.rarity+'">'+d.rarity+' Β· Lv '+lvl+'</div><div class="pmult">Γ'+petMultOf(d,lvl).toFixed(1)+' coins</div><div>'+(eq?'<span class="tag green">ACTIVE</span>':'<button class="btn sm" onclick="equipPet(\''+d.id+'\')">Equip</button>')+'</div></div>'}).join('');
|
| 571 |
+
openModal(mh('πΎ Pet Collection')+'<div class="sub">'+owned+'/'+PETS.length+' collected Β· Active multiplier Γ'+petMult().toFixed(1)+' Β· Duplicates level pets up!</div><div class="pgrid">'+cards+'</div>');
|
| 572 |
+
}
|
| 573 |
+
function equipPet(id){S.activePet=id;refreshPetMesh();sfx.click();openPets();save()}
|
| 574 |
+
function openSeason(){
|
| 575 |
+
const pts=S.seasonPoints;
|
| 576 |
+
const rows=SEASON.map(t=>{const claimed=S.seasonClaimed.includes(t.t);const can=pts>=t.t&&!claimed;return '<div class="srow '+(claimed?'done':can?'can':'')+'"><div class="snum">'+t.t+'</div><div class="srew">'+rwText(t.r)+'</div><div>'+(claimed?'<span class="tag">β</span>':can?'<button class="btn sm green" onclick="claimSeason('+t.t+')">Claim</button>':'<span class="tag gray">π '+t.t+' pt'+(t.t>1?'s':'')+'</span>')+'</div></div>'}).join('');
|
| 577 |
+
openModal(mh('π Season 3 Β· Summer Splash')+'<div class="sub">Earn 1 Tier Point per level-up Β· You have <b class="gold">'+pts+'</b> point'+(pts===1?'':'s')+'</div><div class="strack">'+rows+'</div>');
|
| 578 |
+
}
|
| 579 |
+
function claimSeason(t){const tier=SEASON.find(x=>x.t===t);if(!tier||S.seasonPoints<t||S.seasonClaimed.includes(t))return;S.seasonClaimed.push(t);grantRewards(tier.r);sfx.buy();toast('π Tier '+t+' reward claimed!');updateHUD();save();openSeason()}
|
| 580 |
+
function openQuests(){
|
| 581 |
+
const rows=questDefs().map(q=>{const done=q.prog>=q.target;const claimed=S.qClaim[q.id];return '<div class="qrow '+(claimed?'done':'')+'"><div class="qico">'+q.ico+'</div><div class="qmain"><div class="qtxt">'+q.txt+'</div><div class="qbar"><i style="width:'+clamp(q.prog/q.target*100,0,100)+'%"></i></div><div class="qmeta">'+Math.min(q.prog,q.target)+'/'+q.target+' Β· Reward: '+rwText(q.rw)+'</div></div><div>'+(claimed?'<span class="tag">DONE</span>':done?'<button class="btn sm green" onclick="claimQuest(\''+q.id+'\')">Claim</button>':'<span class="tag gray">IN PROGRESS</span>')+'</div></div>'}).join('');
|
| 582 |
+
openModal(mh('π Daily Quests')+'<div class="sub">Resets daily Β· players with goals retain longer!</div>'+rows+'<div class="statsline">Lifetime coins: πͺ '+fmt(S.totalCoins)+' Β· Today: πͺ '+fmt(S.coinsToday)+' Β· Boxes opened: '+S.boxesOpened+' Β· Rebirths: β '+S.rebirths+'</div>');
|
| 583 |
+
}
|
| 584 |
+
function questDefs(){const t1=100+S.level*20;return[
|
| 585 |
+
{id:'coins',ico:'πͺ',txt:'Collect '+t1+' coins',target:t1,prog:S.qProg.coins,rw:{coins:200,bux:15}},
|
| 586 |
+
{id:'boxes',ico:'π',txt:'Open 2 Mystery Boxes',target:2,prog:S.qProg.boxes,rw:{coins:300,bux:20}},
|
| 587 |
+
{id:'houses',ico:'π ',txt:'Visit 2 friend houses',target:2,prog:S.qProg.houses,rw:{coins:250,bux:15}}]}
|
| 588 |
+
function claimQuest(id){const q=questDefs().find(x=>x.id===id);if(!q||q.prog<q.target||S.qClaim[id])return;S.qClaim[id]=true;grantRewards(q.rw);gainXP(30);sfx.buy();toast('β
Quest reward claimed!');updateHUD();save();openQuests();checkQuests()}
|
| 589 |
+
function checkQuests(){let any=false;for(const q of questDefs()){if(q.prog>=q.target&&!S.qClaim[q.id]){any=true;if(!S.qNotified[q.id]){S.qNotified[q.id]=true;toast('π Quest complete: '+q.txt+' β claim it!');sfx.click()}}}$('#btnQuests').classList.toggle('pulse',any)}
|
| 590 |
+
function dailyAvailable(){return S.dailyClaimedDate!==todayStr()}
|
| 591 |
+
function openDaily(){
|
| 592 |
+
const day=S.streak;const claimed=!dailyAvailable();const cur=clamp(day,1,7);
|
| 593 |
+
let cells='';for(let d=1;d<=7;d++){let cls='future';if(d<cur)cls='past';else if(d===cur)cls=claimed?'past':'now';const r=dailyReward(d);cells+='<div class="day '+cls+'"><div class="dnum">Day '+d+'</div><div class="drew">'+rwIcon(r)+'</div>'+(d===cur&&!claimed?'<div class="dtag">TODAY</div>':'')+'</div>'}
|
| 594 |
+
const m14=S.streak>=14,m30=S.streak>=30;
|
| 595 |
+
openModal(mh('π Daily Rewards')+'<div class="streak">π₯ '+day+'-day streak</div>'+(day>7?'<div class="sub">Streak beyond 7 days keeps paying out! Next milestone: '+(m30?'Day 30 β':m14?'Day 30 ('+day+'/30)':'Day 14 ('+day+'/14)')+'</div>':'<div class="sub">Log in daily β streak resets if you miss a day.</div>')+'<div class="days">'+cells+'</div><div class="miles"><div class="mile '+(m14?'':'locked')+'">Day 14<br>π 200 '+(m14?'β':'('+day+'/14)')+'</div><div class="mile '+(m30?'':'locked')+'">Day 30<br>π Mythic Pet '+(m30?'β':'('+day+'/30)')+'</div></div><button class="btn gold big" onclick="claimDaily()" '+(claimed?'disabled':'')+'>'+(claimed?'β Claimed today β see you tomorrow!':'Claim Day '+day+' Reward')+'</button>');
|
| 596 |
+
}
|
| 597 |
+
function claimDaily(){if(!dailyAvailable())return;const day=S.streak;const r=dailyReward(day);grantRewards(r);S.dailyClaimedDate=todayStr();sfx.buy();toast('π Day '+day+' reward claimed!');confetti(player.position.clone().add(new THREE.Vector3(0,2.5,0)),16);updateHUD();save();closeModal();checkFTUE()}
|
| 598 |
+
function openFriends(){
|
| 599 |
+
const rows=FRIENDS.map(f=>{const rem=(S.houseCd[f.id]||0)-Date.now();return '<div class="frow"><div class="fava" style="background:'+f.color+'">'+f.name[0]+'</div><div class="fmain"><div class="fname">'+f.name+'<span class="fstatus '+(f.online?'on':'off')+'">'+(f.online?'β Online':'β Offline')+'</span></div><div class="fsub">'+(f.online?(rem>0?'House visit ready in '+mmss(rem/1000):'π Visit their house for a gift!'):'Their house is locked for now')+'</div></div><div>'+(f.online?'<button class="btn sm" onclick="locate(\''+f.id+'\')">π Locate</button>':'')+'</div></div>'}).join('');
|
| 600 |
+
openModal(mh('π₯ Friends')+'<div class="sub">Players with friends retain 3β5Γ better β visit houses daily!</div>'+rows);
|
| 601 |
+
}
|
| 602 |
+
function locate(id){const f=FRIENDS.find(x=>x.id===id);if(!f)return;f.bounce=2.5;sfx.click();toast('π '+f.name+"'s house marked β follow the sign!");closeModal()}
|
| 603 |
+
function boardData(tab){
|
| 604 |
+
const seedStr=tab+(tab==='daily'?todayStr():tab==='weekly'?getWeek():'all');let s=0;for(let i=0;i<seedStr.length;i++)s=(s*31+seedStr.charCodeAt(i))>>>0;
|
| 605 |
+
const rng=()=>{s=(s*1664525+1013904223)>>>0;return s/4294967296};
|
| 606 |
+
const pool=[...NPC_NAMES];for(let i=pool.length-1;i>0;i--){const j=Math.floor(rng()*(i+1));[pool[i],pool[j]]=[pool[j],pool[i]]}
|
| 607 |
+
const names=pool.slice(0,9);const ranges={daily:[2000,90000],weekly:[20000,420000],all:[120000,2600000]}[tab];
|
| 608 |
+
const rows=names.map(n=>({name:n,v:Math.floor(ranges[0]+rng()*(ranges[1]-ranges[0]))}));
|
| 609 |
+
const myV=tab==='daily'?S.coinsToday:tab==='weekly'?Math.floor(S.coinsToday*2+S.level*400):S.totalCoins;
|
| 610 |
+
rows.push({name:S.name||'You',v:myV,me:true});rows.sort((a,b)=>b.v-a.v);return rows;
|
| 611 |
+
}
|
| 612 |
+
function openBoard(tab){
|
| 613 |
+
boardTab=tab||'daily';const data=boardData(boardTab);const me=data.findIndex(r=>r.me);
|
| 614 |
+
const rows=data.map((r,i)=>'<div class="brow '+(r.me?'me':'')+'"><div class="brank">'+(i===0?'π₯':i===1?'π₯':i===2?'π₯':'#'+(i+1))+'</div><div class="bname">'+r.name+(r.me?' <span class="tag green">YOU</span>':'')+'</div><div class="bval">πͺ '+fmt(r.v)+'</div></div>').join('');
|
| 615 |
+
const tabs='<div class="tabs">'+['daily','weekly','all'].map(t=>'<button class="tab '+(boardTab===t?'on':'')+'" onclick="openBoard(\''+t+'\')">'+(t==='all'?'All-Time':t[0].toUpperCase()+t.slice(1))+'</button>').join('')+'</div>';
|
| 616 |
+
openModal(mh('π Leaderboard')+tabs+'<div class="sub">Your rank: <b class="gold">#'+(me+1)+'</b> Β· Keep collecting coins to climb the RFY charts!</div><div class="blist">'+rows+'</div>');
|
| 617 |
+
}
|
| 618 |
+
function openRebirth(){
|
| 619 |
+
const cur=(1+.25*S.rebirths),next=(1+.25*(S.rebirths+1));
|
| 620 |
+
openModal(mh('β Rebirth')+'<div class="rebirthbox"><div class="rbig">Become a Legend</div><p>Reset your <b>Level</b> and <b>Coins</b> to gain a permanent <b class="gold">+25% coin multiplier</b>.</p><div class="rnums">Γ'+cur.toFixed(2)+' β <b class="gold">Γ'+next.toFixed(2)+'</b></div><p class="keep">You keep: Pets Β· Bux Β· Cosmetics Β· Season progress</p><div class="mrow"><button class="btn gold big" onclick="doRebirth()">β REBIRTH NOW</button><button class="btn gray" onclick="closeModal()">Not yet</button></div></div>');
|
| 621 |
+
}
|
| 622 |
+
function doRebirth(){S.rebirths++;S.level=1;S.xp=0;S.coins=0;sfx.rebirth();for(let i=0;i<5;i++)burst(player.position.clone().add(new THREE.Vector3(rand(-1,1),rand(1,3),rand(-1,1))),pick([0xffc531,0xff5d5d,0x5db9ff,0x2ee06e,0xc06bff]),14,6);toast('β REBIRTH '+S.rebirths+'! Permanent multiplier Γ'+(1+.25*S.rebirths).toFixed(2));closeModal();updateHUD();save()}
|
| 623 |
+
|
| 624 |
+
/* ============================= FTUE / HUD / TOASTS ============================= */
|
| 625 |
+
function ftueDone(step){switch(step){case 0:return S.ftueDist>12;case 1:return S.ftueCoins>=5;case 2:return S.firstBoxUsed;case 3:return S.dailyClaimedDate===todayStr();case 4:return S.ftueVisit>=1}return true}
|
| 626 |
+
function checkFTUE(){if(S.ftueStep>=FTUE.length)return;if(ftueDone(S.ftueStep)){S.ftueStep++;if(S.ftueStep>=FTUE.length){S.bux+=25;toast('π All set! +25 π bonus Β· Welcome to the community!');updateHUD()}renderTutorial();save()}}
|
| 627 |
+
function renderTutorial(){const el=$('#tutorial');if(S.ftueStep>=FTUE.length){el.classList.add('hidden');return}el.classList.remove('hidden');let txt=FTUE[S.ftueStep].txt;if(S.ftueStep===1)txt=txt.replace('{n}',Math.min(S.ftueCoins,5));el.innerHTML='<div class="tstep"><span class="tdot">'+FTUE.map((_,i)=>'<i class="'+(i<S.ftueStep?'done':i===S.ftueStep?'cur':'')+'"></i>').join('')+'</span><div class="ttxt">'+txt+'</div></div>'}
|
| 628 |
+
function updateHUD(){
|
| 629 |
+
$('#coinVal').textContent=fmt(S.coins);$('#buxVal').textContent=fmt(S.bux);
|
| 630 |
+
$('#lvNum').textContent=S.level;
|
| 631 |
+
const need=xpNeed(S.level);$('#xpBar').style.width=clamp(S.xp/need*100,0,100)+'%';$('#xpText').textContent=Math.floor(S.xp)+'/'+need+' XP';
|
| 632 |
+
$('#btnRebirth').style.display=S.level>=15?'flex':'none';
|
| 633 |
+
$('#btnDaily').classList.toggle('pulse',dailyAvailable());
|
| 634 |
+
$('#btnMute').textContent=S.muted?'π':'';
|
| 635 |
+
}
|
| 636 |
+
function toast(msg){const el=document.createElement('div');el.className='toast panel';el.textContent=msg;$('#toasts').appendChild(el);while($('#toasts').children.length>4)$('#toasts').firstChild.remove();setTimeout(()=>{el.classList.add('out');setTimeout(()=>el.remove(),400)},3600)}
|
| 637 |
+
function scheduleSocial(){setTimeout(()=>{if(!gameStarted)return;toast(pick(SOCIAL).replace('{n}',pick(NPC_NAMES)).replace('{l}',ri(5,40)));scheduleSocial()},ri(22000,42000))}
|
| 638 |
+
|
| 639 |
+
/* ============================= AVATAR REFRESH ============================= */
|
| 640 |
+
let player,playerParts,hatSpin=null,petMesh=null;
|
| 641 |
+
function refreshAvatar(){
|
| 642 |
+
const pos=player?player.position.clone():new THREE.Vector3(0,0,6);const rot=player?player.rotation.y:0;
|
| 643 |
+
if(player)world.remove(player);
|
| 644 |
+
player=buildAvatar({skin:S.skin,shirt:S.shirt,pants:S.pants});player.position.copy(pos);player.rotation.y=rot;playerParts=player.userData;
|
| 645 |
+
if(S.hat!=='none'){const hg=buildHat(S.hat);hg.position.y=2.78;hatSpin=hg.userData.spin||null;player.add(hg)}else hatSpin=null;
|
| 646 |
+
const spr=nameSprite(S.name||'You','#ffe066',1);spr.position.y=3.6;player.add(spr);
|
| 647 |
+
world.add(player);
|
| 648 |
+
}
|
| 649 |
+
function refreshPetMesh(){if(petMesh){world.remove(petMesh);petMesh=null}if(!S.activePet)return;const d=petById(S.activePet);petMesh=buildPet(d);const ring=new THREE.Mesh(new THREE.RingGeometry(.32,.48,20),new THREE.MeshBasicMaterial({color:RARITY_HEX[d.rarity],transparent:true,opacity:.85,side:THREE.DoubleSide}));ring.rotation.x=-Math.PI/2;ring.position.y=.03;petMesh.add(ring);const spr=nameSprite(d.emoji+' '+d.name,RARITY_CSS[d.rarity],.7);spr.position.y=1.8;petMesh.add(spr);world.add(petMesh)}
|
| 650 |
+
|
| 651 |
+
/* ============================= INPUT ============================= */
|
| 652 |
+
const keys={};let touchJump=false;
|
| 653 |
+
const PREVENT=['Space','ArrowUp','ArrowDown','ArrowLeft','ArrowRight'];
|
| 654 |
+
addEventListener('keydown',e=>{if(PREVENT.includes(e.code)&&!(e.target instanceof HTMLInputElement))e.preventDefault();keys[e.code]=true;if(e.code==='KeyE')tryInteract();if(e.code==='Escape')closeModal()});
|
| 655 |
+
addEventListener('keyup',e=>{keys[e.code]=false});
|
| 656 |
+
const joy={active:false,x:0,y:0};
|
| 657 |
+
const jb=$('#joyBase'),jk=$('#joyKnob');
|
| 658 |
+
function moveJoy(e){const r=jb.getBoundingClientRect();let dx=(e.clientX-(r.left+r.width/2))/(r.width/2),dy=(e.clientY-(r.top+r.height/2))/(r.height/2);const l=Math.hypot(dx,dy);if(l>1){dx/=l;dy/=l}joy.x=dx;joy.y=dy;jk.style.transform='translate('+dx*34+'px,'+dy*34+'px)'}
|
| 659 |
+
jb.addEventListener('pointerdown',e=>{joy.active=true;jb.setPointerCapture(e.pointerId);moveJoy(e)});
|
| 660 |
+
jb.addEventListener('pointermove',e=>{if(joy.active)moveJoy(e)});
|
| 661 |
+
jb.addEventListener('pointerup',()=>{joy.active=false;joy.x=joy.y=0;jk.style.transform='translate(0,0)'});
|
| 662 |
+
jb.addEventListener('pointercancel',()=>{joy.active=false;joy.x=joy.y=0;jk.style.transform='translate(0,0)'});
|
| 663 |
+
$('#btnJump').addEventListener('pointerdown',e=>{e.preventDefault();touchJump=true});
|
| 664 |
+
$('#btnJump').addEventListener('pointerup',()=>touchJump=false);
|
| 665 |
+
$('#btnJump').addEventListener('pointerleave',()=>touchJump=false);
|
| 666 |
+
$('#btnAct').addEventListener('pointerdown',e=>{e.preventDefault();tryInteract()});
|
| 667 |
+
|
| 668 |
+
/* ============================= GAME LOOP ============================= */
|
| 669 |
+
let gameStarted=false,T=0,walkT=0,moveF=0,vy=0,grounded=true,coinTimer=1,lastLabel='',trailTimer=0;
|
| 670 |
+
const clock=new THREE.Clock();
|
| 671 |
+
const camOff=new THREE.Vector3(0,11.5,13.5),camTarget=new THREE.Vector3(),camLook=new THREE.Vector3();
|
| 672 |
+
const promptEl=$('#prompt');
|
| 673 |
+
|
| 674 |
+
function updatePlayer(dt){
|
| 675 |
+
let jx=0,jz=0;if(joy.active){jx=joy.x;jz=joy.y}
|
| 676 |
+
let ix=((keys.KeyD||keys.ArrowRight)?1:0)-((keys.KeyA||keys.ArrowLeft)?1:0)+jx;
|
| 677 |
+
let iz=((keys.KeyS||keys.ArrowDown)?1:0)-((keys.KeyW||keys.ArrowUp)?1:0)+jz;
|
| 678 |
+
const len=Math.hypot(ix,iz);if(len>1){ix/=len;iz/=len}
|
| 679 |
+
if(modalOpen||!gameStarted){ix=0;iz=0}
|
| 680 |
+
const moving=Math.hypot(ix,iz)>0.05;
|
| 681 |
+
player.position.x=clamp(player.position.x+ix*8.5*dt,-48,48);
|
| 682 |
+
player.position.z=clamp(player.position.z+iz*8.5*dt,-48,48);
|
| 683 |
+
for(const o of obstacles){const dx=player.position.x-o.x,dz=player.position.z-o.z;const d=Math.hypot(dx,dz);const min=o.r+.6;if(d<min&&d>0.001){player.position.x=o.x+dx/d*min;player.position.z=o.z+dz/d*min}}
|
| 684 |
+
if((keys.Space||touchJump)&&grounded){vy=9.5;grounded=false}
|
| 685 |
+
vy-=26*dt;player.position.y+=vy*dt;if(player.position.y<=0){player.position.y=0;vy=0;grounded=true}
|
| 686 |
+
if(moving){player.rotation.y=lerpAngle(player.rotation.y,Math.atan2(ix,iz),1-Math.exp(-14*dt));walkT+=dt*11;moveF+=(1-moveF)*(1-Math.exp(-10*dt))}else moveF+=(0-moveF)*(1-Math.exp(-8*dt));
|
| 687 |
+
setLimbSwing(playerParts,Math.sin(walkT)*.8*moveF);
|
| 688 |
+
if(hatSpin)hatSpin.rotation.y+=dt*12;
|
| 689 |
+
if(S.ftueStep===0){S.ftueDist+=Math.hypot(ix,iz)*8.5*dt;checkFTUE()}
|
| 690 |
+
if(S.trail!=='none'&&moving){trailTimer-=dt;if(trailTimer<=0){trailTimer=.06;const col=S.trail==='rainbow'?RAINBOW[Math.floor(T*8)%12]:TRAIL_HEX[S.trail];burst(player.position.clone().setY(.2),col,1,1.2)}}
|
| 691 |
+
}
|
| 692 |
+
function updateNPCs(dt){
|
| 693 |
+
for(const n of npcs){
|
| 694 |
+
if(n.idle>0){n.idle-=dt;setLimbSwing(n.parts,0)}
|
| 695 |
+
else{const d=dist2D(n.av.position,n.tgt);
|
| 696 |
+
if(d<1){n.idle=rand(1.5,5);n.tgt.set(rand(-38,38),0,rand(-38,38))}
|
| 697 |
+
else{const dx=(n.tgt.x-n.av.position.x)/d,dz=(n.tgt.z-n.av.position.z)/d;
|
| 698 |
+
n.av.position.x+=dx*n.speed*dt;n.av.position.z+=dz*n.speed*dt;
|
| 699 |
+
for(const o of obstacles){const ox=n.av.position.x-o.x,oz=n.av.position.z-o.z;const od=Math.hypot(ox,oz);const mn=o.r+.5;if(od<mn&&od>0.001){n.av.position.x=o.x+ox/od*mn;n.av.position.z=o.z+oz/od*mn}}
|
| 700 |
+
n.av.rotation.y=lerpAngle(n.av.rotation.y,Math.atan2(dx,dz),1-Math.exp(-8*dt));n.walkT+=dt*9;setLimbSwing(n.parts,Math.sin(n.walkT)*.7)}}
|
| 701 |
+
}
|
| 702 |
+
}
|
| 703 |
+
function updateCoins(dt){
|
| 704 |
+
for(let i=coins.length-1;i>=0;i--){const c=coins[i];c.g.rotation.y+=dt*2.6;c.g.position.y=.75+Math.sin(T*2+c.phase)*.12;if(gameStarted&&dist2D(c.g.position,player.position)<1.4)collectCoin(c)}
|
| 705 |
+
coinTimer-=dt;if(coinTimer<=0){coinTimer=1.1;if(coins.length<25)spawnCoin(false)}
|
| 706 |
+
}
|
| 707 |
+
function updatePet(dt){
|
| 708 |
+
if(!petMesh)return;const rot=player.rotation.y;const fx=Math.sin(rot),fz=Math.cos(rot);const rx=Math.cos(rot),rz=-Math.sin(rot);
|
| 709 |
+
const tx=player.position.x-fx*1.5+rx*.6,tz=player.position.z-fz*1.5+rz*.6;
|
| 710 |
+
petMesh.position.x+=(tx-petMesh.position.x)*(1-Math.exp(-6*dt));petMesh.position.z+=(tz-petMesh.position.z)*(1-Math.exp(-6*dt));
|
| 711 |
+
petMesh.position.y=Math.sin(T*3)*.08;petMesh.rotation.y=lerpAngle(petMesh.rotation.y,rot,1-Math.exp(-6*dt));
|
| 712 |
+
}
|
| 713 |
+
function updateParticles(dt){for(let i=parts.length-1;i>=0;i--){const p=parts[i];p.v.y-=16*dt;p.m.position.addScaledVector(p.v,dt);p.life-=dt;const s=clamp(p.life/p.max,0,1);p.m.scale.setScalar(Math.max(s,.01));if(p.life<=0){scene.remove(p.m);parts.splice(i,1)}}}
|
| 714 |
+
function updateFloaters(dt){for(let i=floats.length-1;i>=0;i--){const f=floats[i];f.life-=dt;_fv.copy(f.p).project(camera);if(_fv.z<1){f.el.style.left=(_fv.x*.5+.5)*innerWidth+'px';f.el.style.top=(-_fv.y*.5+.5)*innerHeight+'px'}if(f.life<=0){f.el.remove();floats.splice(i,1)}}}
|
| 715 |
+
function updateStations(dt){
|
| 716 |
+
if(mysteryBoxMesh){mysteryBoxMesh.rotation.y+=dt*1.2;mysteryBoxMesh.position.y=1.7+Math.sin(T*1.5)*.12;stationRing.scale.setScalar(1+Math.sin(T*2)*.05)}
|
| 717 |
+
if(giftBoxMesh){giftBoxMesh.rotation.y-=dt*1.2;giftBoxMesh.position.y=1.7+Math.sin(T*1.5+1)*.12;giftRing.scale.setScalar(1+Math.sin(T*2+1)*.05)}
|
| 718 |
+
FRIENDS.forEach(f=>{if(f.bounce>0){f.bounce-=dt;f.sign.scale.setScalar(1+Math.sin(T*10)*.15)}else f.sign.scale.setScalar(1)});
|
| 719 |
+
const now=Date.now();if(now>=S.freeBoxAt&&!giftNotified){giftNotified=true;if(gameStarted)toast('π Your Free Gift is ready β press E at the green station!')}
|
| 720 |
+
}
|
| 721 |
+
function updatePrompt(){
|
| 722 |
+
const it=nearestInteract();
|
| 723 |
+
if(it&&gameStarted&&!modalOpen){const l=it.label();if(l!==lastLabel){promptEl.innerHTML='<span class="key">E</span>'+l;lastLabel=l}promptEl.style.display='block'}
|
| 724 |
+
else{promptEl.style.display='none';lastLabel=''}
|
| 725 |
+
}
|
| 726 |
+
function animate(){
|
| 727 |
+
requestAnimationFrame(animate);const dt=Math.min(clock.getDelta(),.05);T+=dt;
|
| 728 |
+
if(gameStarted){updatePlayer(dt);updateNPCs(dt);updateCoins(dt);updatePet(dt)}
|
| 729 |
+
updateParticles(dt);updateFloaters(dt);updateStations(dt);updatePrompt();
|
| 730 |
+
if(player){camLook.set(player.position.x,player.position.y+2,player.position.z);camTarget.copy(player.position).add(camOff);camera.position.lerp(camTarget,1-Math.exp(-6*dt));camera.lookAt(camLook)}
|
| 731 |
+
renderer.render(scene,camera);
|
| 732 |
+
}
|
| 733 |
+
|
| 734 |
+
/* ============================= START ============================= */
|
| 735 |
+
function processLogin(){
|
| 736 |
+
const t=todayStr();
|
| 737 |
+
if(S.lastLogin!==t){const y=new Date(Date.now()-864e5).toDateString();S.streak=(S.lastLogin===y)?S.streak+1:1;S.lastLogin=t;S.coinsToday=0;regenQuests()}
|
| 738 |
+
}
|
| 739 |
+
function regenQuests(){S.questDate=todayStr();S.qProg={coins:0,boxes:0,houses:0};S.qClaim={};S.qNotified={}}
|
| 740 |
+
function startGame(){
|
| 741 |
+
if(gameStarted)return;gameStarted=true;
|
| 742 |
+
processLogin();
|
| 743 |
+
if(S.ftueStep===0){S.bux+=100;addCoins(50);gainXP(5);toast('π Welcome gift: +100 π Bux, +50 πͺ coins!')}
|
| 744 |
+
updateHUD();renderTutorial();
|
| 745 |
+
$('#loader').classList.add('done');setTimeout(()=>{const l=$('#loader');if(l)l.remove()},700);
|
| 746 |
+
setTimeout(()=>{if(dailyAvailable()&&!modalOpen&&gameStarted)openDaily()},1600);
|
| 747 |
+
setTimeout(()=>{const f=FRIENDS.find(x=>!x.online);if(f){f.online=true;toast('π₯ '+f.name+' is now online!');sfx.click()}},45000);
|
| 748 |
+
scheduleSocial();save();
|
| 749 |
+
}
|
| 750 |
+
$('#playBtn').onclick=()=>{audioInit();if(actx&&actx.state==='suspended')actx.resume();const nm=($('#nameInput').value||'').trim().replace(/[<>]/g,'');if(nm)S.name=nm;else if(!S.name)S.name='Explorer'+ri(100,999);$('#playBtn').disabled=true;startGame()};
|
| 751 |
+
$('#nameInput').addEventListener('keydown',e=>{if(e.key==='Enter')$('#playBtn').click()});
|
| 752 |
+
function toggleMute(){S.muted=!S.muted;updateHUD();save()}
|
| 753 |
+
|
| 754 |
+
addEventListener('resize',()=>{camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();renderer.setSize(innerWidth,innerHeight)});
|
| 755 |
+
setInterval(save,8000);
|
| 756 |
+
addEventListener('beforeunload',save);
|
| 757 |
+
document.addEventListener('visibilitychange',()=>{if(document.hidden)save()});
|
| 758 |
+
|
| 759 |
+
/* init world + entities */
|
| 760 |
+
buildWorld();
|
| 761 |
+
refreshAvatar();
|
| 762 |
+
for(let i=0;i<6;i++)spawnNPC(NPC_NAMES[i]);
|
| 763 |
+
for(let i=0;i<5;i++)spawnCoin(true);
|
| 764 |
+
for(let i=0;i<13;i++)spawnCoin(false);
|
| 765 |
+
updateHUD();
|
| 766 |
+
animate();
|
| 767 |
+
</script>
|
| 768 |
+
</body>
|
| 769 |
+
</html>
|