Nafiul Huda commited on
Update public/index.html
Browse files- public/index.html +1467 -356
public/index.html
CHANGED
|
@@ -3,425 +3,1536 @@
|
|
| 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, viewport-fit=cover">
|
| 6 |
-
<
|
|
|
|
|
|
|
|
|
|
| 7 |
<style>
|
| 8 |
-
* {
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
width: 100%;
|
| 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 |
</style>
|
| 49 |
</head>
|
| 50 |
<body>
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
<div
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
<
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
</div>
|
| 60 |
</div>
|
| 61 |
-
|
| 62 |
-
<div id="
|
| 63 |
-
<
|
| 64 |
-
<
|
| 65 |
-
<div class="cloud" style="top: 80px; left: 60%; width: 100px; height: 30px;"></div>
|
| 66 |
|
| 67 |
-
<div id="
|
| 68 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
</div>
|
| 70 |
-
|
| 71 |
-
<div id="
|
| 72 |
-
<div
|
| 73 |
-
<div id="
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
</div>
|
| 76 |
</div>
|
| 77 |
|
| 78 |
<script src="/socket.io/socket.io.js"></script>
|
| 79 |
<script>
|
| 80 |
-
//
|
| 81 |
-
const
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
| 87 |
let socket;
|
| 88 |
let myId = null;
|
| 89 |
-
let
|
| 90 |
-
let
|
| 91 |
-
let
|
| 92 |
-
let
|
| 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 |
function setupSocketEvents() {
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
platforms.push(plat);
|
| 175 |
-
renderPlatform(plat);
|
| 176 |
});
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
});
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
if(players[id]?.el) players[id].el.remove();
|
| 188 |
-
if(players[id]?.stickEl) players[id].stickEl.remove();
|
| 189 |
-
delete players[id];
|
| 190 |
-
updateLeaderboard();
|
| 191 |
});
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
const p = players[data.id];
|
| 198 |
-
if (!p) return;
|
| 199 |
-
|
| 200 |
-
if (data.type === 'grow_start') {
|
| 201 |
-
p.isGrowing = true;
|
| 202 |
-
visualizeRemoteGrowth(p);
|
| 203 |
-
} else if (data.type === 'grow_stop') {
|
| 204 |
-
p.isGrowing = false;
|
| 205 |
-
animateStickFall(p, data.height);
|
| 206 |
-
}
|
| 207 |
});
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
} else {
|
| 225 |
-
|
| 226 |
-
// Ensure X is perfectly synced for next round
|
| 227 |
-
p.x = data.x;
|
| 228 |
-
// Don't teleport visibly, just update logic var for next calculation
|
| 229 |
}
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
| 235 |
} else {
|
| 236 |
-
|
| 237 |
-
setTimeout(() => animateDeath(p, data.x), 500);
|
| 238 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
}
|
| 240 |
-
updateLeaderboard();
|
| 241 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
}
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
// 2. Network Background
|
| 259 |
-
socket.emit('start_grow');
|
| 260 |
-
};
|
| 261 |
-
|
| 262 |
-
const end = (e) => {
|
| 263 |
-
if(e.cancelable) e.preventDefault();
|
| 264 |
-
if (myState !== 'growing') return;
|
| 265 |
|
| 266 |
-
const
|
| 267 |
-
myState = 'moving'; // Lock input
|
| 268 |
-
cancelAnimationFrame(animationFrameId);
|
| 269 |
-
|
| 270 |
-
// 1. Calculate Prediction
|
| 271 |
-
const height = Math.min(duration * GROWTH_SPEED, 2000);
|
| 272 |
-
const p = players[myId];
|
| 273 |
-
p.stickHeight = height;
|
| 274 |
-
|
| 275 |
-
// 2. Visual Immediate
|
| 276 |
-
animateStickFall(p, height);
|
| 277 |
-
socket.emit('stop_grow'); // Tell server to validate
|
| 278 |
-
|
| 279 |
-
// 3. Physics Prediction
|
| 280 |
-
const currentPlat = platforms[p.currentPlatIndex];
|
| 281 |
-
const nextPlat = platforms[p.currentPlatIndex + 1];
|
| 282 |
-
const stickEnd = currentPlat.x + currentPlat.w + height;
|
| 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 |
-
d.style.left = plat.x + 'px';
|
| 318 |
-
d.style.width = plat.w + 'px';
|
| 319 |
-
d.style.height = PLATFORM_HEIGHT + 'px';
|
| 320 |
-
world.appendChild(d);
|
| 321 |
}
|
| 322 |
-
|
| 323 |
-
function
|
| 324 |
-
if (!
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
|
|
|
| 330 |
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
}
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
resetStick(p);
|
| 340 |
-
}
|
| 341 |
-
|
| 342 |
-
function resetStick(p) {
|
| 343 |
-
if(!p.stickEl) return;
|
| 344 |
-
p.stickEl.style.transition = 'none';
|
| 345 |
-
p.stickEl.style.height = '0px';
|
| 346 |
-
p.stickEl.style.transform = 'rotate(0deg)';
|
| 347 |
-
p.stickEl.style.left = (parseFloat(p.el.style.left) + PLAYER_SIZE - STICK_WIDTH/2) + 'px';
|
| 348 |
-
p.stickEl.style.bottom = PLATFORM_HEIGHT + 'px';
|
| 349 |
}
|
| 350 |
-
|
| 351 |
-
function
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
const
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
}
|
| 361 |
}
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
}
|
| 370 |
-
|
| 371 |
-
function
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
}
|
| 377 |
-
|
| 378 |
-
function
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
}
|
|
|
|
|
|
|
| 384 |
}
|
| 385 |
-
|
| 386 |
-
function
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
}
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
p.x = respawnX; // Sync logic
|
| 400 |
-
resetStick(p);
|
| 401 |
-
if (p.id === myId) updateCamera();
|
| 402 |
-
}, 1000);
|
| 403 |
}
|
| 404 |
-
|
| 405 |
-
function
|
| 406 |
-
|
| 407 |
-
|
|
|
|
| 408 |
}
|
| 409 |
|
| 410 |
-
function
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 414 |
}
|
| 415 |
-
|
| 416 |
-
function
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
}
|
| 424 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 425 |
</script>
|
| 426 |
</body>
|
| 427 |
</html>
|
|
|
|
| 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, viewport-fit=cover">
|
| 6 |
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
| 7 |
+
<meta name="mobile-web-app-capable" content="yes">
|
| 8 |
+
<meta name="theme-color" content="#1a1a2e">
|
| 9 |
+
<title>Arena.io - Battle Royale</title>
|
| 10 |
<style>
|
| 11 |
+
* {
|
| 12 |
+
margin: 0;
|
| 13 |
+
padding: 0;
|
| 14 |
+
box-sizing: border-box;
|
| 15 |
+
touch-action: none;
|
| 16 |
+
-webkit-touch-callout: none;
|
| 17 |
+
-webkit-user-select: none;
|
| 18 |
+
user-select: none;
|
| 19 |
+
}
|
| 20 |
|
| 21 |
+
html, body {
|
| 22 |
+
width: 100%;
|
| 23 |
+
height: 100%;
|
| 24 |
+
overflow: hidden;
|
| 25 |
+
background: #1a1a2e;
|
| 26 |
+
font-family: 'Segoe UI', system-ui, sans-serif;
|
| 27 |
}
|
| 28 |
|
| 29 |
+
#loginScreen {
|
| 30 |
+
position: fixed;
|
| 31 |
+
top: 0;
|
| 32 |
+
left: 0;
|
| 33 |
+
width: 100%;
|
| 34 |
+
height: 100%;
|
| 35 |
+
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
| 36 |
+
display: flex;
|
| 37 |
+
flex-direction: column;
|
| 38 |
+
align-items: center;
|
| 39 |
+
justify-content: center;
|
| 40 |
+
z-index: 1000;
|
| 41 |
+
padding: 20px;
|
| 42 |
+
}
|
| 43 |
|
| 44 |
+
.logo {
|
| 45 |
+
font-size: clamp(2rem, 10vw, 4rem);
|
| 46 |
+
font-weight: 900;
|
| 47 |
+
background: linear-gradient(45deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
|
| 48 |
+
-webkit-background-clip: text;
|
| 49 |
+
-webkit-text-fill-color: transparent;
|
| 50 |
+
background-clip: text;
|
| 51 |
+
text-shadow: 0 0 30px rgba(255, 107, 107, 0.5);
|
| 52 |
+
margin-bottom: 10px;
|
| 53 |
+
animation: glow 2s ease-in-out infinite alternate;
|
| 54 |
+
}
|
| 55 |
|
| 56 |
+
@keyframes glow {
|
| 57 |
+
from { filter: drop-shadow(0 0 10px rgba(255, 107, 107, 0.5)); }
|
| 58 |
+
to { filter: drop-shadow(0 0 20px rgba(255, 107, 107, 0.8)); }
|
| 59 |
+
}
|
| 60 |
|
| 61 |
+
.subtitle {
|
| 62 |
+
color: #888;
|
| 63 |
+
font-size: 1rem;
|
| 64 |
+
margin-bottom: 30px;
|
| 65 |
+
}
|
| 66 |
|
| 67 |
+
.login-box {
|
| 68 |
+
background: rgba(255, 255, 255, 0.05);
|
| 69 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 70 |
+
border-radius: 20px;
|
| 71 |
+
padding: 30px;
|
| 72 |
+
width: 100%;
|
| 73 |
+
max-width: 400px;
|
| 74 |
+
backdrop-filter: blur(10px);
|
| 75 |
+
}
|
| 76 |
|
| 77 |
+
.input-group {
|
| 78 |
+
margin-bottom: 20px;
|
| 79 |
+
}
|
| 80 |
|
| 81 |
+
.input-group label {
|
| 82 |
+
display: block;
|
| 83 |
+
color: #aaa;
|
| 84 |
+
font-size: 0.9rem;
|
| 85 |
+
margin-bottom: 8px;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
#usernameInput {
|
| 89 |
+
width: 100%;
|
| 90 |
+
padding: 15px 20px;
|
| 91 |
+
font-size: 1.1rem;
|
| 92 |
+
border: 2px solid rgba(255, 255, 255, 0.1);
|
| 93 |
+
border-radius: 12px;
|
| 94 |
+
background: rgba(0, 0, 0, 0.3);
|
| 95 |
+
color: #fff;
|
| 96 |
+
outline: none;
|
| 97 |
+
transition: all 0.3s;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
#usernameInput:focus {
|
| 101 |
+
border-color: #ff6b6b;
|
| 102 |
+
box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.class-selector {
|
| 106 |
+
display: grid;
|
| 107 |
+
grid-template-columns: repeat(5, 1fr);
|
| 108 |
+
gap: 10px;
|
| 109 |
+
margin-bottom: 25px;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.class-btn {
|
| 113 |
+
padding: 12px 5px;
|
| 114 |
+
border: 2px solid rgba(255, 255, 255, 0.1);
|
| 115 |
+
border-radius: 12px;
|
| 116 |
+
background: rgba(0, 0, 0, 0.3);
|
| 117 |
+
color: #fff;
|
| 118 |
+
font-size: 0.7rem;
|
| 119 |
+
cursor: pointer;
|
| 120 |
+
transition: all 0.3s;
|
| 121 |
+
text-align: center;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.class-btn.selected {
|
| 125 |
+
border-color: #ff6b6b;
|
| 126 |
+
background: rgba(255, 107, 107, 0.2);
|
| 127 |
+
transform: scale(1.05);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
.class-icon {
|
| 131 |
+
font-size: 1.5rem;
|
| 132 |
+
display: block;
|
| 133 |
+
margin-bottom: 5px;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
#playBtn {
|
| 137 |
+
width: 100%;
|
| 138 |
+
padding: 18px;
|
| 139 |
+
font-size: 1.3rem;
|
| 140 |
+
font-weight: 700;
|
| 141 |
+
border: none;
|
| 142 |
+
border-radius: 12px;
|
| 143 |
+
background: linear-gradient(135deg, #ff6b6b, #ff8e53);
|
| 144 |
+
color: #fff;
|
| 145 |
+
cursor: pointer;
|
| 146 |
+
transition: all 0.3s;
|
| 147 |
+
text-transform: uppercase;
|
| 148 |
+
letter-spacing: 2px;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
#playBtn:active {
|
| 152 |
+
transform: scale(0.98);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.online-count {
|
| 156 |
+
margin-top: 20px;
|
| 157 |
+
color: #4ade80;
|
| 158 |
+
font-size: 0.9rem;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
#gameContainer {
|
| 162 |
+
display: none;
|
| 163 |
+
width: 100%;
|
| 164 |
+
height: 100%;
|
| 165 |
+
position: relative;
|
| 166 |
+
overflow: hidden;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
#gameCanvas {
|
| 170 |
+
position: absolute;
|
| 171 |
+
top: 0;
|
| 172 |
+
left: 0;
|
| 173 |
+
width: 100%;
|
| 174 |
+
height: 100%;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.hud {
|
| 178 |
+
position: absolute;
|
| 179 |
+
pointer-events: none;
|
| 180 |
+
z-index: 100;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
#topHud {
|
| 184 |
+
top: env(safe-area-inset-top, 10px);
|
| 185 |
+
left: 10px;
|
| 186 |
+
right: 10px;
|
| 187 |
+
display: flex;
|
| 188 |
+
justify-content: space-between;
|
| 189 |
+
align-items: flex-start;
|
| 190 |
+
padding: 10px;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
.stats-panel {
|
| 194 |
+
background: rgba(0, 0, 0, 0.7);
|
| 195 |
+
border-radius: 12px;
|
| 196 |
+
padding: 10px 15px;
|
| 197 |
+
backdrop-filter: blur(5px);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
.ping-display {
|
| 201 |
+
display: flex;
|
| 202 |
+
align-items: center;
|
| 203 |
+
gap: 8px;
|
| 204 |
+
font-size: 0.9rem;
|
| 205 |
+
color: #4ade80;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
.ping-dot {
|
| 209 |
+
width: 8px;
|
| 210 |
+
height: 8px;
|
| 211 |
+
border-radius: 50%;
|
| 212 |
+
background: #4ade80;
|
| 213 |
+
animation: pulse 1s infinite;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
@keyframes pulse {
|
| 217 |
+
0%, 100% { opacity: 1; }
|
| 218 |
+
50% { opacity: 0.5; }
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.player-stats {
|
| 222 |
+
display: flex;
|
| 223 |
+
gap: 15px;
|
| 224 |
+
color: #fff;
|
| 225 |
+
font-size: 0.85rem;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
.stat {
|
| 229 |
+
display: flex;
|
| 230 |
+
flex-direction: column;
|
| 231 |
+
align-items: center;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
.stat-value {
|
| 235 |
+
font-size: 1.2rem;
|
| 236 |
+
font-weight: 700;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.stat-label {
|
| 240 |
+
font-size: 0.7rem;
|
| 241 |
+
color: #888;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
#leaderboard {
|
| 245 |
+
position: absolute;
|
| 246 |
+
top: 80px;
|
| 247 |
+
right: 10px;
|
| 248 |
+
background: rgba(0, 0, 0, 0.7);
|
| 249 |
+
border-radius: 12px;
|
| 250 |
+
padding: 10px;
|
| 251 |
+
min-width: 150px;
|
| 252 |
+
backdrop-filter: blur(5px);
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
.lb-title {
|
| 256 |
+
color: #feca57;
|
| 257 |
+
font-size: 0.8rem;
|
| 258 |
+
font-weight: 700;
|
| 259 |
+
margin-bottom: 8px;
|
| 260 |
+
text-align: center;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
.lb-entry {
|
| 264 |
+
display: flex;
|
| 265 |
+
justify-content: space-between;
|
| 266 |
+
color: #fff;
|
| 267 |
+
font-size: 0.75rem;
|
| 268 |
+
padding: 3px 0;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
.lb-entry.self {
|
| 272 |
+
color: #48dbfb;
|
| 273 |
+
font-weight: 700;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
.lb-rank {
|
| 277 |
+
color: #feca57;
|
| 278 |
+
margin-right: 5px;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
#killFeed {
|
| 282 |
+
position: absolute;
|
| 283 |
+
top: 80px;
|
| 284 |
+
left: 10px;
|
| 285 |
+
max-width: 200px;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
.kill-entry {
|
| 289 |
+
background: rgba(0, 0, 0, 0.7);
|
| 290 |
+
border-radius: 8px;
|
| 291 |
+
padding: 6px 10px;
|
| 292 |
+
margin-bottom: 5px;
|
| 293 |
+
font-size: 0.75rem;
|
| 294 |
+
color: #fff;
|
| 295 |
+
animation: fadeIn 0.3s ease;
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
@keyframes fadeIn {
|
| 299 |
+
from { opacity: 0; transform: translateX(-20px); }
|
| 300 |
+
to { opacity: 1; transform: translateX(0); }
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
.killer-name { color: #ff6b6b; }
|
| 304 |
+
.victim-name { color: #48dbfb; }
|
| 305 |
+
|
| 306 |
+
#healthBar {
|
| 307 |
+
position: absolute;
|
| 308 |
+
bottom: 180px;
|
| 309 |
+
left: 50%;
|
| 310 |
+
transform: translateX(-50%);
|
| 311 |
+
width: 200px;
|
| 312 |
+
height: 20px;
|
| 313 |
+
background: rgba(0, 0, 0, 0.7);
|
| 314 |
+
border-radius: 10px;
|
| 315 |
+
overflow: hidden;
|
| 316 |
+
border: 2px solid rgba(255, 255, 255, 0.2);
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
#healthFill {
|
| 320 |
+
height: 100%;
|
| 321 |
+
background: linear-gradient(90deg, #ff6b6b, #ff8e53);
|
| 322 |
+
transition: width 0.3s;
|
| 323 |
+
border-radius: 8px;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
#energyBar {
|
| 327 |
+
position: absolute;
|
| 328 |
+
bottom: 155px;
|
| 329 |
+
left: 50%;
|
| 330 |
+
transform: translateX(-50%);
|
| 331 |
+
width: 150px;
|
| 332 |
+
height: 12px;
|
| 333 |
+
background: rgba(0, 0, 0, 0.7);
|
| 334 |
+
border-radius: 6px;
|
| 335 |
+
overflow: hidden;
|
| 336 |
+
border: 2px solid rgba(255, 255, 255, 0.2);
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
#energyFill {
|
| 340 |
+
height: 100%;
|
| 341 |
+
background: linear-gradient(90deg, #48dbfb, #0abde3);
|
| 342 |
+
transition: width 0.3s;
|
| 343 |
+
border-radius: 4px;
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
#abilityBtn {
|
| 347 |
+
position: absolute;
|
| 348 |
+
bottom: 40px;
|
| 349 |
+
right: 30px;
|
| 350 |
+
width: 80px;
|
| 351 |
+
height: 80px;
|
| 352 |
+
border-radius: 50%;
|
| 353 |
+
background: linear-gradient(135deg, #9b59b6, #8e44ad);
|
| 354 |
+
border: 4px solid rgba(255, 255, 255, 0.3);
|
| 355 |
+
color: #fff;
|
| 356 |
+
font-size: 0.9rem;
|
| 357 |
+
font-weight: 700;
|
| 358 |
+
display: flex;
|
| 359 |
+
flex-direction: column;
|
| 360 |
+
align-items: center;
|
| 361 |
+
justify-content: center;
|
| 362 |
+
pointer-events: auto;
|
| 363 |
+
touch-action: manipulation;
|
| 364 |
+
z-index: 200;
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
#abilityBtn.cooldown {
|
| 368 |
+
opacity: 0.5;
|
| 369 |
+
background: #555;
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
.ability-icon {
|
| 373 |
+
font-size: 1.5rem;
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
#joystickContainer {
|
| 377 |
+
position: absolute;
|
| 378 |
+
bottom: 20px;
|
| 379 |
+
left: 20px;
|
| 380 |
+
width: 150px;
|
| 381 |
+
height: 150px;
|
| 382 |
+
pointer-events: auto;
|
| 383 |
+
touch-action: none;
|
| 384 |
+
z-index: 200;
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
#joystickBase {
|
| 388 |
+
position: absolute;
|
| 389 |
+
width: 150px;
|
| 390 |
+
height: 150px;
|
| 391 |
+
border-radius: 50%;
|
| 392 |
+
background: rgba(255, 255, 255, 0.1);
|
| 393 |
+
border: 3px solid rgba(255, 255, 255, 0.3);
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
#joystickKnob {
|
| 397 |
+
position: absolute;
|
| 398 |
+
width: 60px;
|
| 399 |
+
height: 60px;
|
| 400 |
+
border-radius: 50%;
|
| 401 |
+
background: radial-gradient(circle, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.6));
|
| 402 |
+
left: 50%;
|
| 403 |
+
top: 50%;
|
| 404 |
+
transform: translate(-50%, -50%);
|
| 405 |
+
box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
#minimap {
|
| 409 |
+
position: absolute;
|
| 410 |
+
bottom: 20px;
|
| 411 |
+
right: 120px;
|
| 412 |
+
width: 100px;
|
| 413 |
+
height: 100px;
|
| 414 |
+
background: rgba(0, 0, 0, 0.7);
|
| 415 |
+
border-radius: 10px;
|
| 416 |
+
border: 2px solid rgba(255, 255, 255, 0.2);
|
| 417 |
+
overflow: hidden;
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
#minimapCanvas {
|
| 421 |
+
width: 100%;
|
| 422 |
+
height: 100%;
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
#respawnOverlay {
|
| 426 |
+
display: none;
|
| 427 |
+
position: fixed;
|
| 428 |
+
top: 0;
|
| 429 |
+
left: 0;
|
| 430 |
+
width: 100%;
|
| 431 |
+
height: 100%;
|
| 432 |
+
background: rgba(0, 0, 0, 0.8);
|
| 433 |
+
z-index: 500;
|
| 434 |
+
flex-direction: column;
|
| 435 |
+
align-items: center;
|
| 436 |
+
justify-content: center;
|
| 437 |
+
color: #fff;
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
.death-text {
|
| 441 |
+
font-size: 2rem;
|
| 442 |
+
font-weight: 700;
|
| 443 |
+
color: #ff6b6b;
|
| 444 |
+
margin-bottom: 20px;
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
.respawn-timer {
|
| 448 |
+
font-size: 4rem;
|
| 449 |
+
font-weight: 900;
|
| 450 |
+
color: #feca57;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
.death-stats {
|
| 454 |
+
margin-top: 20px;
|
| 455 |
+
text-align: center;
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
#effectsDisplay {
|
| 459 |
+
position: absolute;
|
| 460 |
+
bottom: 210px;
|
| 461 |
+
left: 50%;
|
| 462 |
+
transform: translateX(-50%);
|
| 463 |
+
display: flex;
|
| 464 |
+
gap: 8px;
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
.effect-icon {
|
| 468 |
+
width: 35px;
|
| 469 |
+
height: 35px;
|
| 470 |
+
border-radius: 8px;
|
| 471 |
+
background: rgba(0, 0, 0, 0.7);
|
| 472 |
+
display: flex;
|
| 473 |
+
align-items: center;
|
| 474 |
+
justify-content: center;
|
| 475 |
+
font-size: 1.2rem;
|
| 476 |
+
border: 2px solid #feca57;
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
.streak-display {
|
| 480 |
+
position: absolute;
|
| 481 |
+
top: 50%;
|
| 482 |
+
left: 50%;
|
| 483 |
+
transform: translate(-50%, -50%);
|
| 484 |
+
font-size: 2rem;
|
| 485 |
+
font-weight: 900;
|
| 486 |
+
color: #ff6b6b;
|
| 487 |
+
text-shadow: 0 0 20px rgba(255, 107, 107, 0.8);
|
| 488 |
+
opacity: 0;
|
| 489 |
+
pointer-events: none;
|
| 490 |
+
z-index: 300;
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
.streak-display.show {
|
| 494 |
+
animation: streakPop 1.5s ease-out forwards;
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
@keyframes streakPop {
|
| 498 |
+
0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
|
| 499 |
+
20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
|
| 500 |
+
100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
.class-stats {
|
| 504 |
+
font-size: 0.6rem;
|
| 505 |
+
color: #888;
|
| 506 |
+
margin-top: 3px;
|
| 507 |
+
}
|
| 508 |
</style>
|
| 509 |
</head>
|
| 510 |
<body>
|
| 511 |
+
<div id="loginScreen">
|
| 512 |
+
<div class="logo">ARENA.IO</div>
|
| 513 |
+
<div class="subtitle">Battle Royale - Last One Standing</div>
|
| 514 |
+
|
| 515 |
+
<div class="login-box">
|
| 516 |
+
<div class="input-group">
|
| 517 |
+
<label>Enter Your Name</label>
|
| 518 |
+
<input type="text" id="usernameInput" placeholder="Your username..." maxlength="15" autocomplete="off">
|
| 519 |
+
</div>
|
| 520 |
+
|
| 521 |
+
<div class="input-group">
|
| 522 |
+
<label>Choose Your Class</label>
|
| 523 |
+
<div class="class-selector">
|
| 524 |
+
<button class="class-btn selected" data-class="WARRIOR">
|
| 525 |
+
<span class="class-icon">⚔️</span>
|
| 526 |
+
Warrior
|
| 527 |
+
<div class="class-stats">Balanced</div>
|
| 528 |
+
</button>
|
| 529 |
+
<button class="class-btn" data-class="TANK">
|
| 530 |
+
<span class="class-icon">🛡️</span>
|
| 531 |
+
Tank
|
| 532 |
+
<div class="class-stats">High HP</div>
|
| 533 |
+
</button>
|
| 534 |
+
<button class="class-btn" data-class="ASSASSIN">
|
| 535 |
+
<span class="class-icon">🗡️</span>
|
| 536 |
+
Assassin
|
| 537 |
+
<div class="class-stats">Fast</div>
|
| 538 |
+
</button>
|
| 539 |
+
<button class="class-btn" data-class="MAGE">
|
| 540 |
+
<span class="class-icon">🔮</span>
|
| 541 |
+
Mage
|
| 542 |
+
<div class="class-stats">AOE</div>
|
| 543 |
+
</button>
|
| 544 |
+
<button class="class-btn" data-class="BERSERKER">
|
| 545 |
+
<span class="class-icon">🔥</span>
|
| 546 |
+
Berserker
|
| 547 |
+
<div class="class-stats">Rage</div>
|
| 548 |
+
</button>
|
| 549 |
+
</div>
|
| 550 |
+
</div>
|
| 551 |
+
|
| 552 |
+
<button id="playBtn">⚡ ENTER ARENA ⚡</button>
|
| 553 |
+
|
| 554 |
+
<div class="online-count">
|
| 555 |
+
<span id="onlineCount">0</span> players online
|
| 556 |
+
</div>
|
| 557 |
</div>
|
| 558 |
</div>
|
| 559 |
+
|
| 560 |
+
<div id="gameContainer">
|
| 561 |
+
<canvas id="gameCanvas"></canvas>
|
| 562 |
+
<canvas id="minimapCanvas" style="display:none;"></canvas>
|
|
|
|
| 563 |
|
| 564 |
+
<div id="topHud" class="hud">
|
| 565 |
+
<div class="stats-panel">
|
| 566 |
+
<div class="ping-display">
|
| 567 |
+
<div class="ping-dot"></div>
|
| 568 |
+
<span id="pingValue">0ms</span>
|
| 569 |
+
</div>
|
| 570 |
+
</div>
|
| 571 |
+
|
| 572 |
+
<div class="stats-panel player-stats">
|
| 573 |
+
<div class="stat">
|
| 574 |
+
<div class="stat-value" id="scoreValue">0</div>
|
| 575 |
+
<div class="stat-label">SCORE</div>
|
| 576 |
+
</div>
|
| 577 |
+
<div class="stat">
|
| 578 |
+
<div class="stat-value" id="killsValue">0</div>
|
| 579 |
+
<div class="stat-label">KILLS</div>
|
| 580 |
+
</div>
|
| 581 |
+
<div class="stat">
|
| 582 |
+
<div class="stat-value" id="streakValue">0</div>
|
| 583 |
+
<div class="stat-label">STREAK</div>
|
| 584 |
+
</div>
|
| 585 |
+
</div>
|
| 586 |
</div>
|
| 587 |
+
|
| 588 |
+
<div id="leaderboard" class="hud">
|
| 589 |
+
<div class="lb-title">🏆 LEADERBOARD</div>
|
| 590 |
+
<div id="lbEntries"></div>
|
| 591 |
+
</div>
|
| 592 |
+
|
| 593 |
+
<div id="killFeed" class="hud"></div>
|
| 594 |
+
|
| 595 |
+
<div id="effectsDisplay" class="hud"></div>
|
| 596 |
+
|
| 597 |
+
<div id="healthBar" class="hud">
|
| 598 |
+
<div id="healthFill" style="width: 100%"></div>
|
| 599 |
+
</div>
|
| 600 |
+
|
| 601 |
+
<div id="energyBar" class="hud">
|
| 602 |
+
<div id="energyFill" style="width: 100%"></div>
|
| 603 |
+
</div>
|
| 604 |
+
|
| 605 |
+
<div id="minimap" class="hud">
|
| 606 |
+
<canvas id="minimapRender"></canvas>
|
| 607 |
+
</div>
|
| 608 |
+
|
| 609 |
+
<div id="joystickContainer">
|
| 610 |
+
<div id="joystickBase"></div>
|
| 611 |
+
<div id="joystickKnob"></div>
|
| 612 |
+
</div>
|
| 613 |
+
|
| 614 |
+
<button id="abilityBtn">
|
| 615 |
+
<span class="ability-icon">⚡</span>
|
| 616 |
+
<span id="abilityName">SKILL</span>
|
| 617 |
+
</button>
|
| 618 |
+
|
| 619 |
+
<div class="streak-display" id="streakPopup"></div>
|
| 620 |
+
</div>
|
| 621 |
+
|
| 622 |
+
<div id="respawnOverlay">
|
| 623 |
+
<div class="death-text">☠️ YOU DIED ☠️</div>
|
| 624 |
+
<div class="respawn-timer" id="respawnTimer">3</div>
|
| 625 |
+
<div class="death-stats">
|
| 626 |
+
<div>Killed by: <span id="killedBy">Unknown</span></div>
|
| 627 |
</div>
|
| 628 |
</div>
|
| 629 |
|
| 630 |
<script src="/socket.io/socket.io.js"></script>
|
| 631 |
<script>
|
| 632 |
+
// Game Configuration
|
| 633 |
+
const CONFIG = {
|
| 634 |
+
INTERPOLATION_DELAY: 100,
|
| 635 |
+
PREDICTION_ENABLED: true,
|
| 636 |
+
RENDER_INTERPOLATION: true,
|
| 637 |
+
INPUT_BUFFER_SIZE: 64,
|
| 638 |
+
RECONCILIATION_THRESHOLD: 50
|
| 639 |
+
};
|
| 640 |
+
|
| 641 |
+
// Game State
|
| 642 |
let socket;
|
| 643 |
let myId = null;
|
| 644 |
+
let mapSize = 3000;
|
| 645 |
+
let gameRunning = false;
|
| 646 |
+
let ping = 0;
|
| 647 |
+
let lastPingTime = 0;
|
| 648 |
+
|
| 649 |
+
// Player state for prediction
|
| 650 |
+
let localPlayer = null;
|
| 651 |
+
let serverPlayers = new Map();
|
| 652 |
+
let interpolationBuffer = new Map();
|
| 653 |
+
let inputSequence = 0;
|
| 654 |
+
let pendingInputs = [];
|
| 655 |
+
|
| 656 |
+
// Game objects from server
|
| 657 |
+
let orbs = [];
|
| 658 |
+
let powerups = [];
|
| 659 |
+
let obstacles = [];
|
| 660 |
+
let safeZone = { x: 1500, y: 1500, r: 1500 };
|
| 661 |
+
let killFeed = [];
|
| 662 |
+
let leaderboard = [];
|
| 663 |
+
|
| 664 |
+
// Input state
|
| 665 |
+
let joystickActive = false;
|
| 666 |
+
let joystickX = 0;
|
| 667 |
+
let joystickY = 0;
|
| 668 |
+
let abilityPressed = false;
|
| 669 |
+
|
| 670 |
+
// Canvas
|
| 671 |
+
let canvas, ctx;
|
| 672 |
+
let minimapCanvas, minimapCtx;
|
| 673 |
+
let camera = { x: 0, y: 0 };
|
| 674 |
+
|
| 675 |
+
// DOM Elements
|
| 676 |
+
const loginScreen = document.getElementById('loginScreen');
|
| 677 |
+
const gameContainer = document.getElementById('gameContainer');
|
| 678 |
+
const usernameInput = document.getElementById('usernameInput');
|
| 679 |
+
const playBtn = document.getElementById('playBtn');
|
| 680 |
+
const classButtons = document.querySelectorAll('.class-btn');
|
| 681 |
+
let selectedClass = 'WARRIOR';
|
| 682 |
+
|
| 683 |
+
// Initialize
|
| 684 |
+
function init() {
|
| 685 |
+
canvas = document.getElementById('gameCanvas');
|
| 686 |
+
ctx = canvas.getContext('2d');
|
| 687 |
+
|
| 688 |
+
minimapCanvas = document.getElementById('minimapRender');
|
| 689 |
+
minimapCtx = minimapCanvas.getContext('2d');
|
| 690 |
+
minimapCanvas.width = 100;
|
| 691 |
+
minimapCanvas.height = 100;
|
| 692 |
+
|
| 693 |
+
resizeCanvas();
|
| 694 |
+
window.addEventListener('resize', resizeCanvas);
|
| 695 |
+
|
| 696 |
+
setupClassSelection();
|
| 697 |
+
setupPlayButton();
|
| 698 |
+
|
| 699 |
+
// Connect to server
|
| 700 |
+
socket = io({
|
| 701 |
+
transports: ['websocket'],
|
| 702 |
+
upgrade: false,
|
| 703 |
+
reconnection: true,
|
| 704 |
+
reconnectionDelay: 1000,
|
| 705 |
+
reconnectionAttempts: 10
|
| 706 |
});
|
| 707 |
+
|
| 708 |
+
setupSocketEvents();
|
| 709 |
+
|
| 710 |
+
// Ping loop
|
| 711 |
+
setInterval(measurePing, 1000);
|
| 712 |
+
}
|
| 713 |
+
|
| 714 |
+
function resizeCanvas() {
|
| 715 |
+
canvas.width = window.innerWidth;
|
| 716 |
+
canvas.height = window.innerHeight;
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
function setupClassSelection() {
|
| 720 |
+
classButtons.forEach(btn => {
|
| 721 |
+
btn.addEventListener('click', () => {
|
| 722 |
+
classButtons.forEach(b => b.classList.remove('selected'));
|
| 723 |
+
btn.classList.add('selected');
|
| 724 |
+
selectedClass = btn.dataset.class;
|
| 725 |
+
vibrate(10);
|
| 726 |
+
});
|
| 727 |
});
|
| 728 |
+
}
|
| 729 |
+
|
| 730 |
+
function setupPlayButton() {
|
| 731 |
+
playBtn.addEventListener('click', () => {
|
| 732 |
+
const username = usernameInput.value.trim();
|
| 733 |
+
if (username.length < 1) {
|
| 734 |
+
usernameInput.style.borderColor = '#ff6b6b';
|
| 735 |
+
vibrate(50);
|
| 736 |
+
return;
|
| 737 |
+
}
|
| 738 |
|
| 739 |
+
socket.emit('join', { username, playerClass: selectedClass });
|
| 740 |
+
vibrate(20);
|
| 741 |
+
});
|
| 742 |
+
|
| 743 |
+
usernameInput.addEventListener('keypress', (e) => {
|
| 744 |
+
if (e.key === 'Enter') playBtn.click();
|
| 745 |
});
|
| 746 |
}
|
| 747 |
+
|
| 748 |
function setupSocketEvents() {
|
| 749 |
+
socket.on('connect', () => {
|
| 750 |
+
console.log('Connected to server');
|
|
|
|
|
|
|
| 751 |
});
|
| 752 |
+
|
| 753 |
+
socket.on('joined', (data) => {
|
| 754 |
+
myId = data.id;
|
| 755 |
+
mapSize = data.mapSize;
|
| 756 |
+
gameRunning = true;
|
| 757 |
+
|
| 758 |
+
loginScreen.style.display = 'none';
|
| 759 |
+
gameContainer.style.display = 'block';
|
| 760 |
+
|
| 761 |
+
setupControls();
|
| 762 |
+
requestAnimationFrame(gameLoop);
|
| 763 |
});
|
| 764 |
+
|
| 765 |
+
socket.on('gameState', (state) => {
|
| 766 |
+
processGameState(state);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 767 |
});
|
| 768 |
+
|
| 769 |
+
socket.on('pong', (startTime) => {
|
| 770 |
+
ping = Date.now() - startTime;
|
| 771 |
+
updatePingDisplay();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 772 |
});
|
| 773 |
+
|
| 774 |
+
socket.on('error', (data) => {
|
| 775 |
+
alert(data.message);
|
| 776 |
+
});
|
| 777 |
+
|
| 778 |
+
socket.on('disconnect', () => {
|
| 779 |
+
console.log('Disconnected');
|
| 780 |
+
gameRunning = false;
|
| 781 |
+
});
|
| 782 |
+
}
|
| 783 |
+
|
| 784 |
+
function measurePing() {
|
| 785 |
+
lastPingTime = Date.now();
|
| 786 |
+
socket.emit('ping', lastPingTime);
|
| 787 |
+
}
|
| 788 |
+
|
| 789 |
+
function updatePingDisplay() {
|
| 790 |
+
const pingEl = document.getElementById('pingValue');
|
| 791 |
+
const pingDot = document.querySelector('.ping-dot');
|
| 792 |
+
|
| 793 |
+
pingEl.textContent = `${ping}ms`;
|
| 794 |
+
|
| 795 |
+
if (ping < 50) {
|
| 796 |
+
pingEl.style.color = '#4ade80';
|
| 797 |
+
pingDot.style.background = '#4ade80';
|
| 798 |
+
} else if (ping < 150) {
|
| 799 |
+
pingEl.style.color = '#feca57';
|
| 800 |
+
pingDot.style.background = '#feca57';
|
| 801 |
+
} else {
|
| 802 |
+
pingEl.style.color = '#ff6b6b';
|
| 803 |
+
pingDot.style.background = '#ff6b6b';
|
| 804 |
+
}
|
| 805 |
+
}
|
| 806 |
+
|
| 807 |
+
function processGameState(state) {
|
| 808 |
+
const now = Date.now();
|
| 809 |
+
|
| 810 |
+
// Update game objects
|
| 811 |
+
orbs = state.orbs || [];
|
| 812 |
+
powerups = state.powerups || [];
|
| 813 |
+
obstacles = state.obstacles || [];
|
| 814 |
+
safeZone = state.safeZone || safeZone;
|
| 815 |
+
killFeed = state.killFeed || [];
|
| 816 |
+
leaderboard = state.leaderboard || [];
|
| 817 |
+
|
| 818 |
+
// Process players with interpolation
|
| 819 |
+
state.players.forEach(serverPlayer => {
|
| 820 |
+
if (serverPlayer.id === myId) {
|
| 821 |
+
// Handle local player with reconciliation
|
| 822 |
+
if (localPlayer) {
|
| 823 |
+
reconcilePlayer(serverPlayer);
|
| 824 |
} else {
|
| 825 |
+
localPlayer = { ...serverPlayer };
|
|
|
|
|
|
|
|
|
|
| 826 |
}
|
| 827 |
+
|
| 828 |
+
// Update UI
|
| 829 |
+
updatePlayerUI(serverPlayer);
|
| 830 |
+
|
| 831 |
+
// Check death
|
| 832 |
+
if (!serverPlayer.isAlive) {
|
| 833 |
+
showDeathScreen();
|
| 834 |
} else {
|
| 835 |
+
hideDeathScreen();
|
|
|
|
| 836 |
}
|
| 837 |
+
} else {
|
| 838 |
+
// Store for interpolation
|
| 839 |
+
if (!interpolationBuffer.has(serverPlayer.id)) {
|
| 840 |
+
interpolationBuffer.set(serverPlayer.id, []);
|
| 841 |
+
}
|
| 842 |
+
|
| 843 |
+
const buffer = interpolationBuffer.get(serverPlayer.id);
|
| 844 |
+
buffer.push({
|
| 845 |
+
timestamp: now,
|
| 846 |
+
state: serverPlayer
|
| 847 |
+
});
|
| 848 |
+
|
| 849 |
+
// Keep only recent states
|
| 850 |
+
while (buffer.length > 20) buffer.shift();
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
serverPlayers.set(serverPlayer.id, serverPlayer);
|
| 854 |
+
});
|
| 855 |
+
|
| 856 |
+
// Remove disconnected players
|
| 857 |
+
const serverIds = new Set(state.players.map(p => p.id));
|
| 858 |
+
serverPlayers.forEach((_, id) => {
|
| 859 |
+
if (!serverIds.has(id)) {
|
| 860 |
+
serverPlayers.delete(id);
|
| 861 |
+
interpolationBuffer.delete(id);
|
| 862 |
}
|
|
|
|
| 863 |
});
|
| 864 |
+
|
| 865 |
+
// Update online count
|
| 866 |
+
document.getElementById('onlineCount').textContent = state.playerCount || 0;
|
| 867 |
+
|
| 868 |
+
// Update leaderboard
|
| 869 |
+
updateLeaderboard();
|
| 870 |
+
|
| 871 |
+
// Update kill feed
|
| 872 |
+
updateKillFeed();
|
| 873 |
}
|
| 874 |
+
|
| 875 |
+
function reconcilePlayer(serverState) {
|
| 876 |
+
// Server reconciliation
|
| 877 |
+
const serverSeq = serverState.seq;
|
| 878 |
+
|
| 879 |
+
// Remove acknowledged inputs
|
| 880 |
+
pendingInputs = pendingInputs.filter(input => input.sequence > serverSeq);
|
| 881 |
+
|
| 882 |
+
// Check if prediction was too far off
|
| 883 |
+
const dx = Math.abs(localPlayer.x - serverState.x);
|
| 884 |
+
const dy = Math.abs(localPlayer.y - serverState.y);
|
| 885 |
+
|
| 886 |
+
if (dx > CONFIG.RECONCILIATION_THRESHOLD || dy > CONFIG.RECONCILIATION_THRESHOLD) {
|
| 887 |
+
// Snap to server position
|
| 888 |
+
localPlayer.x = serverState.x;
|
| 889 |
+
localPlayer.y = serverState.y;
|
| 890 |
+
} else {
|
| 891 |
+
// Smooth correction
|
| 892 |
+
localPlayer.x = localPlayer.x * 0.9 + serverState.x * 0.1;
|
| 893 |
+
localPlayer.y = localPlayer.y * 0.9 + serverState.y * 0.1;
|
| 894 |
+
}
|
| 895 |
+
|
| 896 |
+
// Update other properties
|
| 897 |
+
localPlayer.health = serverState.health;
|
| 898 |
+
localPlayer.maxHealth = serverState.maxHealth;
|
| 899 |
+
localPlayer.energy = serverState.energy;
|
| 900 |
+
localPlayer.size = serverState.size;
|
| 901 |
+
localPlayer.score = serverState.score;
|
| 902 |
+
localPlayer.kills = serverState.kills;
|
| 903 |
+
localPlayer.killStreak = serverState.killStreak;
|
| 904 |
+
localPlayer.isAlive = serverState.isAlive;
|
| 905 |
+
localPlayer.invincible = serverState.invincible;
|
| 906 |
+
localPlayer.effects = serverState.effects;
|
| 907 |
+
localPlayer.color = serverState.color;
|
| 908 |
+
localPlayer.vx = serverState.vx;
|
| 909 |
+
localPlayer.vy = serverState.vy;
|
| 910 |
+
|
| 911 |
+
// Re-apply pending inputs for prediction
|
| 912 |
+
if (CONFIG.PREDICTION_ENABLED) {
|
| 913 |
+
pendingInputs.forEach(input => {
|
| 914 |
+
applyInputToLocal(input);
|
| 915 |
+
});
|
| 916 |
+
}
|
| 917 |
+
}
|
| 918 |
+
|
| 919 |
+
function getInterpolatedPlayer(id) {
|
| 920 |
+
const buffer = interpolationBuffer.get(id);
|
| 921 |
+
if (!buffer || buffer.length < 2) {
|
| 922 |
+
return serverPlayers.get(id);
|
| 923 |
+
}
|
| 924 |
+
|
| 925 |
+
const renderTime = Date.now() - CONFIG.INTERPOLATION_DELAY;
|
| 926 |
+
|
| 927 |
+
// Find two states to interpolate between
|
| 928 |
+
let before = null;
|
| 929 |
+
let after = null;
|
| 930 |
+
|
| 931 |
+
for (let i = 0; i < buffer.length - 1; i++) {
|
| 932 |
+
if (buffer[i].timestamp <= renderTime && buffer[i + 1].timestamp >= renderTime) {
|
| 933 |
+
before = buffer[i];
|
| 934 |
+
after = buffer[i + 1];
|
| 935 |
+
break;
|
| 936 |
+
}
|
| 937 |
+
}
|
| 938 |
+
|
| 939 |
+
if (!before || !after) {
|
| 940 |
+
return buffer[buffer.length - 1].state;
|
| 941 |
+
}
|
| 942 |
+
|
| 943 |
+
// Interpolate
|
| 944 |
+
const total = after.timestamp - before.timestamp;
|
| 945 |
+
const progress = (renderTime - before.timestamp) / total;
|
| 946 |
+
const t = Math.max(0, Math.min(1, progress));
|
| 947 |
+
|
| 948 |
+
return {
|
| 949 |
+
...after.state,
|
| 950 |
+
x: before.state.x + (after.state.x - before.state.x) * t,
|
| 951 |
+
y: before.state.y + (after.state.y - before.state.y) * t,
|
| 952 |
+
angle: lerpAngle(before.state.angle, after.state.angle, t)
|
| 953 |
+
};
|
| 954 |
+
}
|
| 955 |
+
|
| 956 |
+
function lerpAngle(a, b, t) {
|
| 957 |
+
const diff = b - a;
|
| 958 |
+
const adjusted = ((diff + Math.PI) % (Math.PI * 2)) - Math.PI;
|
| 959 |
+
return a + adjusted * t;
|
| 960 |
+
}
|
| 961 |
+
|
| 962 |
+
function updatePlayerUI(player) {
|
| 963 |
+
document.getElementById('scoreValue').textContent = player.score;
|
| 964 |
+
document.getElementById('killsValue').textContent = player.kills;
|
| 965 |
+
document.getElementById('streakValue').textContent = player.killStreak;
|
| 966 |
+
|
| 967 |
+
const healthPercent = (player.health / player.maxHealth) * 100;
|
| 968 |
+
document.getElementById('healthFill').style.width = `${healthPercent}%`;
|
| 969 |
+
|
| 970 |
+
const energyPercent = (player.energy / 100) * 100;
|
| 971 |
+
document.getElementById('energyFill').style.width = `${energyPercent}%`;
|
| 972 |
+
|
| 973 |
+
// Update effects display
|
| 974 |
+
const effectsEl = document.getElementById('effectsDisplay');
|
| 975 |
+
const effectIcons = {
|
| 976 |
+
'speed': '⚡',
|
| 977 |
+
'damage': '💥',
|
| 978 |
+
'shield': '🛡️',
|
| 979 |
+
'magnet': '🧲',
|
| 980 |
+
'ghost': '👻',
|
| 981 |
+
'rapid': '🔥',
|
| 982 |
+
'rage': '😤'
|
| 983 |
+
};
|
| 984 |
+
|
| 985 |
+
effectsEl.innerHTML = player.effects.map(e =>
|
| 986 |
+
`<div class="effect-icon">${effectIcons[e] || '✨'}</div>`
|
| 987 |
+
).join('');
|
| 988 |
+
}
|
| 989 |
+
|
| 990 |
+
function updateLeaderboard() {
|
| 991 |
+
const lbEntries = document.getElementById('lbEntries');
|
| 992 |
+
lbEntries.innerHTML = leaderboard.map(entry => {
|
| 993 |
+
const isSelf = localPlayer && entry.username === localPlayer.username;
|
| 994 |
+
return `
|
| 995 |
+
<div class="lb-entry ${isSelf ? 'self' : ''}">
|
| 996 |
+
<span><span class="lb-rank">#${entry.rank}</span>${entry.username}</span>
|
| 997 |
+
<span>${entry.score}</span>
|
| 998 |
+
</div>
|
| 999 |
+
`;
|
| 1000 |
+
}).join('');
|
| 1001 |
+
}
|
| 1002 |
+
|
| 1003 |
+
function updateKillFeed() {
|
| 1004 |
+
const feedEl = document.getElementById('killFeed');
|
| 1005 |
+
feedEl.innerHTML = killFeed.slice(0, 5).map(kill => `
|
| 1006 |
+
<div class="kill-entry">
|
| 1007 |
+
<span class="killer-name">${kill.killer}</span>
|
| 1008 |
+
☠️
|
| 1009 |
+
<span class="victim-name">${kill.victim}</span>
|
| 1010 |
+
</div>
|
| 1011 |
+
`).join('');
|
| 1012 |
+
}
|
| 1013 |
+
|
| 1014 |
+
function showDeathScreen() {
|
| 1015 |
+
document.getElementById('respawnOverlay').style.display = 'flex';
|
| 1016 |
+
}
|
| 1017 |
+
|
| 1018 |
+
function hideDeathScreen() {
|
| 1019 |
+
document.getElementById('respawnOverlay').style.display = 'none';
|
| 1020 |
+
}
|
| 1021 |
+
|
| 1022 |
+
function showKillStreak(streak) {
|
| 1023 |
+
if (streak < 2) return;
|
| 1024 |
+
|
| 1025 |
+
const popup = document.getElementById('streakPopup');
|
| 1026 |
+
const messages = {
|
| 1027 |
+
2: '🔥 DOUBLE KILL!',
|
| 1028 |
+
3: '💥 TRIPLE KILL!',
|
| 1029 |
+
4: '⚡ QUADRA KILL!',
|
| 1030 |
+
5: '🌟 PENTA KILL!',
|
| 1031 |
+
6: '👑 LEGENDARY!',
|
| 1032 |
+
7: '💀 UNSTOPPABLE!',
|
| 1033 |
+
8: '🔱 GODLIKE!',
|
| 1034 |
+
9: '☄️ BEYOND GODLIKE!',
|
| 1035 |
+
10: '🌌 DIVINE!'
|
| 1036 |
+
};
|
| 1037 |
+
|
| 1038 |
+
popup.textContent = messages[Math.min(streak, 10)] || `🔥 ${streak} KILL STREAK!`;
|
| 1039 |
+
popup.classList.remove('show');
|
| 1040 |
+
void popup.offsetWidth; // Trigger reflow
|
| 1041 |
+
popup.classList.add('show');
|
| 1042 |
|
| 1043 |
+
vibrate([50, 30, 50]);
|
| 1044 |
+
}
|
| 1045 |
+
|
| 1046 |
+
// Controls
|
| 1047 |
+
function setupControls() {
|
| 1048 |
+
const joystickContainer = document.getElementById('joystickContainer');
|
| 1049 |
+
const joystickKnob = document.getElementById('joystickKnob');
|
| 1050 |
+
const joystickBase = document.getElementById('joystickBase');
|
| 1051 |
+
const abilityBtn = document.getElementById('abilityBtn');
|
| 1052 |
+
|
| 1053 |
+
const baseRadius = 75;
|
| 1054 |
+
const knobRadius = 30;
|
| 1055 |
+
const maxDistance = baseRadius - knobRadius;
|
| 1056 |
+
|
| 1057 |
+
let touchId = null;
|
| 1058 |
+
|
| 1059 |
+
function handleJoystickStart(e) {
|
| 1060 |
+
e.preventDefault();
|
| 1061 |
+
const touch = e.changedTouches[0];
|
| 1062 |
+
touchId = touch.identifier;
|
| 1063 |
+
joystickActive = true;
|
| 1064 |
+
updateJoystick(touch);
|
| 1065 |
+
}
|
| 1066 |
+
|
| 1067 |
+
function handleJoystickMove(e) {
|
| 1068 |
+
e.preventDefault();
|
| 1069 |
+
if (!joystickActive) return;
|
| 1070 |
|
| 1071 |
+
for (let touch of e.changedTouches) {
|
| 1072 |
+
if (touch.identifier === touchId) {
|
| 1073 |
+
updateJoystick(touch);
|
| 1074 |
+
break;
|
| 1075 |
+
}
|
| 1076 |
+
}
|
| 1077 |
+
}
|
| 1078 |
+
|
| 1079 |
+
function handleJoystickEnd(e) {
|
| 1080 |
+
e.preventDefault();
|
| 1081 |
+
for (let touch of e.changedTouches) {
|
| 1082 |
+
if (touch.identifier === touchId) {
|
| 1083 |
+
joystickActive = false;
|
| 1084 |
+
touchId = null;
|
| 1085 |
+
joystickX = 0;
|
| 1086 |
+
joystickY = 0;
|
| 1087 |
+
joystickKnob.style.left = '50%';
|
| 1088 |
+
joystickKnob.style.top = '50%';
|
| 1089 |
+
joystickKnob.style.transform = 'translate(-50%, -50%)';
|
| 1090 |
+
break;
|
| 1091 |
+
}
|
| 1092 |
+
}
|
| 1093 |
+
}
|
| 1094 |
+
|
| 1095 |
+
function updateJoystick(touch) {
|
| 1096 |
+
const rect = joystickBase.getBoundingClientRect();
|
| 1097 |
+
const centerX = rect.left + rect.width / 2;
|
| 1098 |
+
const centerY = rect.top + rect.height / 2;
|
| 1099 |
|
| 1100 |
+
let dx = touch.clientX - centerX;
|
| 1101 |
+
let dy = touch.clientY - centerY;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1102 |
|
| 1103 |
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1104 |
|
| 1105 |
+
if (distance > maxDistance) {
|
| 1106 |
+
dx = (dx / distance) * maxDistance;
|
| 1107 |
+
dy = (dy / distance) * maxDistance;
|
| 1108 |
+
}
|
| 1109 |
+
|
| 1110 |
+
joystickX = dx / maxDistance;
|
| 1111 |
+
joystickY = dy / maxDistance;
|
| 1112 |
+
|
| 1113 |
+
joystickKnob.style.left = `calc(50% + ${dx}px)`;
|
| 1114 |
+
joystickKnob.style.top = `calc(50% + ${dy}px)`;
|
| 1115 |
+
}
|
| 1116 |
+
|
| 1117 |
+
joystickContainer.addEventListener('touchstart', handleJoystickStart, { passive: false });
|
| 1118 |
+
joystickContainer.addEventListener('touchmove', handleJoystickMove, { passive: false });
|
| 1119 |
+
joystickContainer.addEventListener('touchend', handleJoystickEnd, { passive: false });
|
| 1120 |
+
joystickContainer.addEventListener('touchcancel', handleJoystickEnd, { passive: false });
|
| 1121 |
+
|
| 1122 |
+
// Ability button
|
| 1123 |
+
abilityBtn.addEventListener('touchstart', (e) => {
|
| 1124 |
+
e.preventDefault();
|
| 1125 |
+
abilityPressed = true;
|
| 1126 |
+
vibrate(20);
|
| 1127 |
+
}, { passive: false });
|
| 1128 |
+
|
| 1129 |
+
abilityBtn.addEventListener('touchend', (e) => {
|
| 1130 |
+
e.preventDefault();
|
| 1131 |
+
abilityPressed = false;
|
| 1132 |
+
}, { passive: false });
|
| 1133 |
+
|
| 1134 |
+
// Prevent default touch behavior on game area
|
| 1135 |
+
gameContainer.addEventListener('touchstart', (e) => {
|
| 1136 |
+
if (e.target === canvas) {
|
| 1137 |
+
e.preventDefault();
|
| 1138 |
+
}
|
| 1139 |
+
}, { passive: false });
|
| 1140 |
}
|
| 1141 |
+
|
| 1142 |
+
function vibrate(pattern) {
|
| 1143 |
+
if (navigator.vibrate) {
|
| 1144 |
+
navigator.vibrate(pattern);
|
| 1145 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1146 |
}
|
| 1147 |
+
|
| 1148 |
+
function applyInputToLocal(input) {
|
| 1149 |
+
if (!localPlayer || !localPlayer.isAlive) return;
|
| 1150 |
+
|
| 1151 |
+
const speed = 8 * (localPlayer.speed || 1);
|
| 1152 |
+
|
| 1153 |
+
if (Math.abs(input.joystickX) > 0.1 || Math.abs(input.joystickY) > 0.1) {
|
| 1154 |
+
const mag = Math.sqrt(input.joystickX ** 2 + input.joystickY ** 2);
|
| 1155 |
+
const normalized = mag > 0 ? { x: input.joystickX / mag, y: input.joystickY / mag } : { x: 0, y: 0 };
|
| 1156 |
|
| 1157 |
+
localPlayer.x += normalized.x * speed * Math.min(1, mag);
|
| 1158 |
+
localPlayer.y += normalized.y * speed * Math.min(1, mag);
|
| 1159 |
+
localPlayer.angle = Math.atan2(input.joystickY, input.joystickX);
|
| 1160 |
}
|
| 1161 |
+
|
| 1162 |
+
// Boundary check
|
| 1163 |
+
localPlayer.x = Math.max(localPlayer.size || 30, Math.min(mapSize - (localPlayer.size || 30), localPlayer.x));
|
| 1164 |
+
localPlayer.y = Math.max(localPlayer.size || 30, Math.min(mapSize - (localPlayer.size || 30), localPlayer.y));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1165 |
}
|
| 1166 |
+
|
| 1167 |
+
function sendInput() {
|
| 1168 |
+
if (!gameRunning || !localPlayer) return;
|
| 1169 |
+
|
| 1170 |
+
const input = {
|
| 1171 |
+
joystickX,
|
| 1172 |
+
joystickY,
|
| 1173 |
+
useAbility: abilityPressed,
|
| 1174 |
+
sequence: ++inputSequence,
|
| 1175 |
+
timestamp: Date.now()
|
| 1176 |
+
};
|
| 1177 |
+
|
| 1178 |
+
// Store for reconciliation
|
| 1179 |
+
if (CONFIG.PREDICTION_ENABLED) {
|
| 1180 |
+
pendingInputs.push(input);
|
| 1181 |
+
if (pendingInputs.length > CONFIG.INPUT_BUFFER_SIZE) {
|
| 1182 |
+
pendingInputs.shift();
|
| 1183 |
+
}
|
| 1184 |
+
|
| 1185 |
+
// Apply locally for prediction
|
| 1186 |
+
applyInputToLocal(input);
|
| 1187 |
+
}
|
| 1188 |
+
|
| 1189 |
+
socket.emit('input', input);
|
| 1190 |
+
|
| 1191 |
+
// Reset ability press
|
| 1192 |
+
if (abilityPressed) {
|
| 1193 |
+
abilityPressed = false;
|
| 1194 |
}
|
| 1195 |
}
|
| 1196 |
+
|
| 1197 |
+
// Rendering
|
| 1198 |
+
function gameLoop() {
|
| 1199 |
+
if (!gameRunning) {
|
| 1200 |
+
requestAnimationFrame(gameLoop);
|
| 1201 |
+
return;
|
| 1202 |
+
}
|
| 1203 |
+
|
| 1204 |
+
sendInput();
|
| 1205 |
+
update();
|
| 1206 |
+
render();
|
| 1207 |
+
renderMinimap();
|
| 1208 |
+
|
| 1209 |
+
requestAnimationFrame(gameLoop);
|
| 1210 |
}
|
| 1211 |
+
|
| 1212 |
+
function update() {
|
| 1213 |
+
if (!localPlayer) return;
|
| 1214 |
+
|
| 1215 |
+
// Update camera to follow local player
|
| 1216 |
+
const targetX = localPlayer.x - canvas.width / 2;
|
| 1217 |
+
const targetY = localPlayer.y - canvas.height / 2;
|
| 1218 |
+
|
| 1219 |
+
camera.x += (targetX - camera.x) * 0.1;
|
| 1220 |
+
camera.y += (targetY - camera.y) * 0.1;
|
| 1221 |
+
|
| 1222 |
+
// Clamp camera
|
| 1223 |
+
camera.x = Math.max(0, Math.min(mapSize - canvas.width, camera.x));
|
| 1224 |
+
camera.y = Math.max(0, Math.min(mapSize - canvas.height, camera.y));
|
| 1225 |
}
|
| 1226 |
+
|
| 1227 |
+
function render() {
|
| 1228 |
+
ctx.fillStyle = '#1a1a2e';
|
| 1229 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 1230 |
+
|
| 1231 |
+
ctx.save();
|
| 1232 |
+
ctx.translate(-camera.x, -camera.y);
|
| 1233 |
+
|
| 1234 |
+
// Draw grid
|
| 1235 |
+
drawGrid();
|
| 1236 |
+
|
| 1237 |
+
// Draw danger zone
|
| 1238 |
+
drawDangerZone();
|
| 1239 |
+
|
| 1240 |
+
// Draw safe zone
|
| 1241 |
+
drawSafeZone();
|
| 1242 |
+
|
| 1243 |
+
// Draw obstacles
|
| 1244 |
+
obstacles.forEach(obs => {
|
| 1245 |
+
const screenX = obs.x - camera.x;
|
| 1246 |
+
const screenY = obs.y - camera.y;
|
| 1247 |
+
|
| 1248 |
+
if (screenX > -obs.radius && screenX < canvas.width + obs.radius &&
|
| 1249 |
+
screenY > -obs.radius && screenY < canvas.height + obs.radius) {
|
| 1250 |
+
ctx.beginPath();
|
| 1251 |
+
ctx.arc(obs.x, obs.y, obs.radius, 0, Math.PI * 2);
|
| 1252 |
+
ctx.fillStyle = obs.type === 'bounce' ? '#ff9f43' : '#636e72';
|
| 1253 |
+
ctx.fill();
|
| 1254 |
+
ctx.strokeStyle = 'rgba(255,255,255,0.3)';
|
| 1255 |
+
ctx.lineWidth = 2;
|
| 1256 |
+
ctx.stroke();
|
| 1257 |
+
}
|
| 1258 |
+
});
|
| 1259 |
+
|
| 1260 |
+
// Draw orbs
|
| 1261 |
+
orbs.forEach(orb => {
|
| 1262 |
+
const screenX = orb.x - camera.x;
|
| 1263 |
+
const screenY = orb.y - camera.y;
|
| 1264 |
+
|
| 1265 |
+
if (screenX > -20 && screenX < canvas.width + 20 &&
|
| 1266 |
+
screenY > -20 && screenY < canvas.height + 20) {
|
| 1267 |
+
const radius = 5 + orb.v * 3;
|
| 1268 |
+
const colors = ['#feca57', '#ff6b6b', '#48dbfb'];
|
| 1269 |
+
|
| 1270 |
+
ctx.beginPath();
|
| 1271 |
+
ctx.arc(orb.x, orb.y, radius, 0, Math.PI * 2);
|
| 1272 |
+
ctx.fillStyle = colors[orb.v - 1] || colors[0];
|
| 1273 |
+
ctx.fill();
|
| 1274 |
+
|
| 1275 |
+
// Glow
|
| 1276 |
+
ctx.shadowColor = colors[orb.v - 1] || colors[0];
|
| 1277 |
+
ctx.shadowBlur = 10;
|
| 1278 |
+
ctx.fill();
|
| 1279 |
+
ctx.shadowBlur = 0;
|
| 1280 |
+
}
|
| 1281 |
+
});
|
| 1282 |
+
|
| 1283 |
+
// Draw powerups
|
| 1284 |
+
powerups.forEach(pow => {
|
| 1285 |
+
const screenX = pow.x - camera.x;
|
| 1286 |
+
const screenY = pow.y - camera.y;
|
| 1287 |
+
|
| 1288 |
+
if (screenX > -30 && screenX < canvas.width + 30 &&
|
| 1289 |
+
screenY > -30 && screenY < canvas.height + 30) {
|
| 1290 |
+
const icons = {
|
| 1291 |
+
'speed': '⚡',
|
| 1292 |
+
'damage': '💥',
|
| 1293 |
+
'health': '❤️',
|
| 1294 |
+
'shield': '🛡️',
|
| 1295 |
+
'size': '📈',
|
| 1296 |
+
'magnet': '🧲',
|
| 1297 |
+
'ghost': '👻',
|
| 1298 |
+
'rapid': '🔥'
|
| 1299 |
+
};
|
| 1300 |
+
|
| 1301 |
+
ctx.beginPath();
|
| 1302 |
+
ctx.arc(pow.x, pow.y, 20, 0, Math.PI * 2);
|
| 1303 |
+
ctx.fillStyle = 'rgba(255, 255, 255, 0.2)';
|
| 1304 |
+
ctx.fill();
|
| 1305 |
+
ctx.strokeStyle = '#feca57';
|
| 1306 |
+
ctx.lineWidth = 3;
|
| 1307 |
+
ctx.stroke();
|
| 1308 |
+
|
| 1309 |
+
ctx.font = '20px Arial';
|
| 1310 |
+
ctx.textAlign = 'center';
|
| 1311 |
+
ctx.textBaseline = 'middle';
|
| 1312 |
+
ctx.fillText(icons[pow.t] || '✨', pow.x, pow.y);
|
| 1313 |
+
}
|
| 1314 |
+
});
|
| 1315 |
+
|
| 1316 |
+
// Draw other players
|
| 1317 |
+
serverPlayers.forEach((player, id) => {
|
| 1318 |
+
if (id === myId) return;
|
| 1319 |
+
|
| 1320 |
+
const interpolated = CONFIG.RENDER_INTERPOLATION ?
|
| 1321 |
+
getInterpolatedPlayer(id) : player;
|
| 1322 |
+
|
| 1323 |
+
if (interpolated) {
|
| 1324 |
+
drawPlayer(interpolated, false);
|
| 1325 |
+
}
|
| 1326 |
+
});
|
| 1327 |
+
|
| 1328 |
+
// Draw local player
|
| 1329 |
+
if (localPlayer && localPlayer.isAlive) {
|
| 1330 |
+
drawPlayer(localPlayer, true);
|
| 1331 |
}
|
| 1332 |
+
|
| 1333 |
+
ctx.restore();
|
| 1334 |
}
|
| 1335 |
+
|
| 1336 |
+
function drawGrid() {
|
| 1337 |
+
const gridSize = 100;
|
| 1338 |
+
const startX = Math.floor(camera.x / gridSize) * gridSize;
|
| 1339 |
+
const startY = Math.floor(camera.y / gridSize) * gridSize;
|
| 1340 |
+
|
| 1341 |
+
ctx.strokeStyle = 'rgba(255, 255, 255, 0.05)';
|
| 1342 |
+
ctx.lineWidth = 1;
|
| 1343 |
+
|
| 1344 |
+
for (let x = startX; x < camera.x + canvas.width + gridSize; x += gridSize) {
|
| 1345 |
+
ctx.beginPath();
|
| 1346 |
+
ctx.moveTo(x, camera.y);
|
| 1347 |
+
ctx.lineTo(x, camera.y + canvas.height);
|
| 1348 |
+
ctx.stroke();
|
| 1349 |
+
}
|
| 1350 |
+
|
| 1351 |
+
for (let y = startY; y < camera.y + canvas.height + gridSize; y += gridSize) {
|
| 1352 |
+
ctx.beginPath();
|
| 1353 |
+
ctx.moveTo(camera.x, y);
|
| 1354 |
+
ctx.lineTo(camera.x + canvas.width, y);
|
| 1355 |
+
ctx.stroke();
|
| 1356 |
}
|
| 1357 |
+
|
| 1358 |
+
// Map border
|
| 1359 |
+
ctx.strokeStyle = '#ff6b6b';
|
| 1360 |
+
ctx.lineWidth = 5;
|
| 1361 |
+
ctx.strokeRect(0, 0, mapSize, mapSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1362 |
}
|
| 1363 |
+
|
| 1364 |
+
function drawDangerZone() {
|
| 1365 |
+
// Draw everything outside safe zone as danger
|
| 1366 |
+
ctx.fillStyle = 'rgba(255, 0, 0, 0.1)';
|
| 1367 |
+
ctx.fillRect(0, 0, mapSize, mapSize);
|
| 1368 |
}
|
| 1369 |
|
| 1370 |
+
function drawSafeZone() {
|
| 1371 |
+
// Clear safe zone area
|
| 1372 |
+
ctx.save();
|
| 1373 |
+
ctx.beginPath();
|
| 1374 |
+
ctx.arc(safeZone.x, safeZone.y, safeZone.r, 0, Math.PI * 2);
|
| 1375 |
+
ctx.clip();
|
| 1376 |
+
ctx.clearRect(safeZone.x - safeZone.r, safeZone.y - safeZone.r,
|
| 1377 |
+
safeZone.r * 2, safeZone.r * 2);
|
| 1378 |
+
ctx.fillStyle = '#1a1a2e';
|
| 1379 |
+
ctx.fillRect(safeZone.x - safeZone.r, safeZone.y - safeZone.r,
|
| 1380 |
+
safeZone.r * 2, safeZone.r * 2);
|
| 1381 |
+
ctx.restore();
|
| 1382 |
+
|
| 1383 |
+
// Draw safe zone border
|
| 1384 |
+
ctx.beginPath();
|
| 1385 |
+
ctx.arc(safeZone.x, safeZone.y, safeZone.r, 0, Math.PI * 2);
|
| 1386 |
+
ctx.strokeStyle = '#4ade80';
|
| 1387 |
+
ctx.lineWidth = 4;
|
| 1388 |
+
ctx.setLineDash([20, 10]);
|
| 1389 |
+
ctx.stroke();
|
| 1390 |
+
ctx.setLineDash([]);
|
| 1391 |
}
|
| 1392 |
+
|
| 1393 |
+
function drawPlayer(player, isLocal) {
|
| 1394 |
+
if (!player.isAlive) return;
|
| 1395 |
+
|
| 1396 |
+
const x = player.x;
|
| 1397 |
+
const y = player.y;
|
| 1398 |
+
const size = player.size || 30;
|
| 1399 |
+
|
| 1400 |
+
// Invincibility effect
|
| 1401 |
+
if (player.invincible) {
|
| 1402 |
+
ctx.beginPath();
|
| 1403 |
+
ctx.arc(x, y, size + 10, 0, Math.PI * 2);
|
| 1404 |
+
ctx.strokeStyle = 'rgba(72, 219, 251, 0.5)';
|
| 1405 |
+
ctx.lineWidth = 3;
|
| 1406 |
+
ctx.stroke();
|
| 1407 |
+
}
|
| 1408 |
+
|
| 1409 |
+
// Effects ring
|
| 1410 |
+
if (player.effects && player.effects.length > 0) {
|
| 1411 |
+
ctx.beginPath();
|
| 1412 |
+
ctx.arc(x, y, size + 5, 0, Math.PI * 2);
|
| 1413 |
+
ctx.strokeStyle = '#feca57';
|
| 1414 |
+
ctx.lineWidth = 2;
|
| 1415 |
+
ctx.stroke();
|
| 1416 |
+
}
|
| 1417 |
+
|
| 1418 |
+
// Player body
|
| 1419 |
+
ctx.beginPath();
|
| 1420 |
+
ctx.arc(x, y, size, 0, Math.PI * 2);
|
| 1421 |
+
|
| 1422 |
+
const gradient = ctx.createRadialGradient(x, y, 0, x, y, size);
|
| 1423 |
+
gradient.addColorStop(0, player.color || '#4CAF50');
|
| 1424 |
+
gradient.addColorStop(1, shadeColor(player.color || '#4CAF50', -30));
|
| 1425 |
+
ctx.fillStyle = gradient;
|
| 1426 |
+
ctx.fill();
|
| 1427 |
+
|
| 1428 |
+
ctx.strokeStyle = isLocal ? '#fff' : 'rgba(255,255,255,0.5)';
|
| 1429 |
+
ctx.lineWidth = isLocal ? 4 : 2;
|
| 1430 |
+
ctx.stroke();
|
| 1431 |
+
|
| 1432 |
+
// Direction indicator
|
| 1433 |
+
const dirX = x + Math.cos(player.angle || 0) * (size + 10);
|
| 1434 |
+
const dirY = y + Math.sin(player.angle || 0) * (size + 10);
|
| 1435 |
+
|
| 1436 |
+
ctx.beginPath();
|
| 1437 |
+
ctx.arc(dirX, dirY, 8, 0, Math.PI * 2);
|
| 1438 |
+
ctx.fillStyle = '#fff';
|
| 1439 |
+
ctx.fill();
|
| 1440 |
+
|
| 1441 |
+
// Health bar
|
| 1442 |
+
const healthWidth = size * 2;
|
| 1443 |
+
const healthHeight = 6;
|
| 1444 |
+
const healthX = x - healthWidth / 2;
|
| 1445 |
+
const healthY = y - size - 15;
|
| 1446 |
+
|
| 1447 |
+
ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
|
| 1448 |
+
ctx.fillRect(healthX, healthY, healthWidth, healthHeight);
|
| 1449 |
+
|
| 1450 |
+
const healthPercent = player.health / player.maxHealth;
|
| 1451 |
+
ctx.fillStyle = healthPercent > 0.5 ? '#4ade80' :
|
| 1452 |
+
healthPercent > 0.25 ? '#feca57' : '#ff6b6b';
|
| 1453 |
+
ctx.fillRect(healthX, healthY, healthWidth * healthPercent, healthHeight);
|
| 1454 |
+
|
| 1455 |
+
// Username
|
| 1456 |
+
ctx.font = 'bold 14px Arial';
|
| 1457 |
+
ctx.textAlign = 'center';
|
| 1458 |
+
ctx.textBaseline = 'bottom';
|
| 1459 |
+
ctx.fillStyle = '#fff';
|
| 1460 |
+
ctx.strokeStyle = '#000';
|
| 1461 |
+
ctx.lineWidth = 3;
|
| 1462 |
+
ctx.strokeText(player.username || 'Player', x, y - size - 20);
|
| 1463 |
+
ctx.fillText(player.username || 'Player', x, y - size - 20);
|
| 1464 |
+
|
| 1465 |
+
// Kill streak badge
|
| 1466 |
+
if (player.killStreak >= 3) {
|
| 1467 |
+
ctx.font = 'bold 12px Arial';
|
| 1468 |
+
ctx.fillStyle = '#ff6b6b';
|
| 1469 |
+
ctx.fillText(`🔥${player.killStreak}`, x, y - size - 35);
|
| 1470 |
+
}
|
| 1471 |
}
|
| 1472 |
+
|
| 1473 |
+
function shadeColor(color, percent) {
|
| 1474 |
+
const num = parseInt(color.replace('#', ''), 16);
|
| 1475 |
+
const amt = Math.round(2.55 * percent);
|
| 1476 |
+
const R = (num >> 16) + amt;
|
| 1477 |
+
const G = (num >> 8 & 0x00FF) + amt;
|
| 1478 |
+
const B = (num & 0x0000FF) + amt;
|
| 1479 |
+
return '#' + (0x1000000 +
|
| 1480 |
+
(R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 +
|
| 1481 |
+
(G < 255 ? G < 1 ? 0 : G : 255) * 0x100 +
|
| 1482 |
+
(B < 255 ? B < 1 ? 0 : B : 255))
|
| 1483 |
+
.toString(16).slice(1);
|
| 1484 |
+
}
|
| 1485 |
+
|
| 1486 |
+
function renderMinimap() {
|
| 1487 |
+
const mmCanvas = document.getElementById('minimapRender');
|
| 1488 |
+
const mmCtx = mmCanvas.getContext('2d');
|
| 1489 |
+
mmCanvas.width = 100;
|
| 1490 |
+
mmCanvas.height = 100;
|
| 1491 |
+
|
| 1492 |
+
// Background
|
| 1493 |
+
mmCtx.fillStyle = 'rgba(0, 0, 0, 0.8)';
|
| 1494 |
+
mmCtx.fillRect(0, 0, 100, 100);
|
| 1495 |
+
|
| 1496 |
+
const scale = 100 / mapSize;
|
| 1497 |
+
|
| 1498 |
+
// Safe zone
|
| 1499 |
+
mmCtx.beginPath();
|
| 1500 |
+
mmCtx.arc(safeZone.x * scale, safeZone.y * scale, safeZone.r * scale, 0, Math.PI * 2);
|
| 1501 |
+
mmCtx.strokeStyle = '#4ade80';
|
| 1502 |
+
mmCtx.lineWidth = 1;
|
| 1503 |
+
mmCtx.stroke();
|
| 1504 |
+
|
| 1505 |
+
// Other players
|
| 1506 |
+
serverPlayers.forEach((player, id) => {
|
| 1507 |
+
if (id === myId) return;
|
| 1508 |
+
if (!player.isAlive) return;
|
| 1509 |
+
|
| 1510 |
+
mmCtx.beginPath();
|
| 1511 |
+
mmCtx.arc(player.x * scale, player.y * scale, 2, 0, Math.PI * 2);
|
| 1512 |
+
mmCtx.fillStyle = '#ff6b6b';
|
| 1513 |
+
mmCtx.fill();
|
| 1514 |
+
});
|
| 1515 |
+
|
| 1516 |
+
// Local player
|
| 1517 |
+
if (localPlayer && localPlayer.isAlive) {
|
| 1518 |
+
mmCtx.beginPath();
|
| 1519 |
+
mmCtx.arc(localPlayer.x * scale, localPlayer.y * scale, 3, 0, Math.PI * 2);
|
| 1520 |
+
mmCtx.fillStyle = '#48dbfb';
|
| 1521 |
+
mmCtx.fill();
|
| 1522 |
+
}
|
| 1523 |
+
|
| 1524 |
+
// Camera view
|
| 1525 |
+
mmCtx.strokeStyle = 'rgba(255, 255, 255, 0.3)';
|
| 1526 |
+
mmCtx.strokeRect(
|
| 1527 |
+
camera.x * scale,
|
| 1528 |
+
camera.y * scale,
|
| 1529 |
+
canvas.width * scale,
|
| 1530 |
+
canvas.height * scale
|
| 1531 |
+
);
|
| 1532 |
+
}
|
| 1533 |
+
|
| 1534 |
+
// Start game
|
| 1535 |
+
init();
|
| 1536 |
</script>
|
| 1537 |
</body>
|
| 1538 |
</html>
|