Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- index.html +619 -768
index.html
CHANGED
|
@@ -2,909 +2,760 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0
|
| 6 |
-
<title>
|
| 7 |
-
<!-- Importing a nice font for that modern UI look -->
|
| 8 |
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;500;800&display=swap" rel="stylesheet">
|
| 9 |
-
<!-- Importing FontAwesome for Icons -->
|
| 10 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 11 |
-
|
| 12 |
<style>
|
| 13 |
:root {
|
| 14 |
-
--
|
| 15 |
-
--
|
| 16 |
-
--
|
| 17 |
-
--
|
| 18 |
-
--
|
| 19 |
-
--
|
| 20 |
-
--
|
| 21 |
-
--font-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
* {
|
| 25 |
box-sizing: border-box;
|
| 26 |
margin: 0;
|
| 27 |
padding: 0;
|
| 28 |
-
-webkit-tap-highlight-color: transparent;
|
| 29 |
}
|
| 30 |
|
| 31 |
body {
|
| 32 |
-
|
| 33 |
-
background-
|
| 34 |
-
|
| 35 |
-
radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%),
|
| 36 |
-
radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
|
| 37 |
-
font-family: var(--font-main);
|
| 38 |
-
color: var(--text-primary);
|
| 39 |
-
overflow: hidden;
|
| 40 |
-
height: 100vh;
|
| 41 |
-
width: 100vw;
|
| 42 |
display: flex;
|
| 43 |
flex-direction: column;
|
|
|
|
|
|
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
-
/*
|
| 47 |
header {
|
| 48 |
-
position: absolute;
|
| 49 |
-
top: 0;
|
| 50 |
-
left: 0;
|
| 51 |
-
width: 100%;
|
| 52 |
-
padding: 1rem 1.5rem;
|
| 53 |
display: flex;
|
| 54 |
justify-content: space-between;
|
| 55 |
align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
z-index: 100;
|
| 57 |
-
background: rgba(15, 23, 42, 0.4);
|
| 58 |
-
backdrop-filter: blur(20px);
|
| 59 |
-
-webkit-backdrop-filter: blur(20px);
|
| 60 |
-
border-bottom: 1px solid var(--ios-glass-border);
|
| 61 |
}
|
| 62 |
|
| 63 |
-
.
|
|
|
|
| 64 |
font-weight: 800;
|
| 65 |
-
|
| 66 |
-
letter-spacing: -0.5px;
|
| 67 |
-
background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
|
| 68 |
-webkit-background-clip: text;
|
| 69 |
-webkit-text-fill-color: transparent;
|
| 70 |
-
|
|
|
|
| 71 |
}
|
| 72 |
|
| 73 |
.anycoder-link {
|
| 74 |
-
font-size: 0.
|
| 75 |
-
|
| 76 |
text-decoration: none;
|
| 77 |
-
|
| 78 |
-
padding:
|
| 79 |
-
background: var(--ios-glass);
|
| 80 |
border-radius: 20px;
|
| 81 |
-
border: 1px solid var(--ios-glass-border);
|
| 82 |
transition: all 0.3s ease;
|
| 83 |
}
|
| 84 |
|
| 85 |
.anycoder-link:hover {
|
| 86 |
-
background:
|
| 87 |
-
color: #
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
}
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
position: relative;
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
width: 100%;
|
| 96 |
height: 100%;
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
}
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
}
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
width: 100%;
|
| 108 |
height: 100%;
|
|
|
|
|
|
|
| 109 |
}
|
| 110 |
|
| 111 |
-
/*
|
| 112 |
-
.
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
transform: translateX(-50%);
|
| 117 |
display: flex;
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
|
|
|
| 121 |
}
|
| 122 |
|
| 123 |
-
.
|
| 124 |
-
background: var(--ios-glass);
|
| 125 |
-
backdrop-filter: blur(16px);
|
| 126 |
-
-webkit-backdrop-filter: blur(16px);
|
| 127 |
-
border: 1px solid var(--ios-glass-border);
|
| 128 |
-
padding: 0.8rem 1.5rem;
|
| 129 |
-
border-radius: 24px;
|
| 130 |
display: flex;
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
|
| 136 |
}
|
| 137 |
|
| 138 |
-
.
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
}
|
| 141 |
|
| 142 |
-
.
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
font-variant-numeric: tabular-nums;
|
| 146 |
}
|
| 147 |
|
| 148 |
-
.
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
opacity: 0.7;
|
| 153 |
}
|
| 154 |
|
| 155 |
-
.
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
cursor: pointer;
|
| 164 |
display: flex;
|
| 165 |
align-items: center;
|
| 166 |
justify-content: center;
|
| 167 |
-
transition: all 0.2s
|
| 168 |
-
|
| 169 |
}
|
| 170 |
|
| 171 |
-
.
|
| 172 |
-
background: rgba(255,
|
| 173 |
-
transform: scale(1.
|
| 174 |
}
|
| 175 |
|
| 176 |
-
.
|
| 177 |
-
|
|
|
|
| 178 |
}
|
| 179 |
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
top: 50%;
|
| 184 |
-
left: 50%;
|
| 185 |
-
transform: translate(-50%, -50%) scale(0.9);
|
| 186 |
-
background: rgba(15, 23, 42, 0.85);
|
| 187 |
-
backdrop-filter: blur(30px);
|
| 188 |
-
-webkit-backdrop-filter: blur(30px);
|
| 189 |
-
border: 1px solid var(--ios-glass-border);
|
| 190 |
-
padding: 2rem 3rem;
|
| 191 |
-
border-radius: 32px;
|
| 192 |
-
text-align: center;
|
| 193 |
-
opacity: 0;
|
| 194 |
-
pointer-events: none;
|
| 195 |
-
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
| 196 |
-
z-index: 200;
|
| 197 |
-
box-shadow: 0 20px 50px rgba(0,0,0,0.5);
|
| 198 |
-
max-width: 90%;
|
| 199 |
}
|
| 200 |
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
|
|
|
| 205 |
}
|
| 206 |
|
| 207 |
-
|
| 208 |
-
font-size:
|
| 209 |
-
|
| 210 |
-
margin-bottom: 0.5rem;
|
| 211 |
-
background: linear-gradient(to right, #fff, #a5b4fc);
|
| 212 |
-
-webkit-background-clip: text;
|
| 213 |
-
-webkit-text-fill-color: transparent;
|
| 214 |
}
|
| 215 |
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
color:
|
| 219 |
-
margin-bottom: 2rem;
|
| 220 |
}
|
| 221 |
|
| 222 |
-
|
| 223 |
-
|
|
|
|
| 224 |
border: none;
|
| 225 |
-
|
| 226 |
-
border-radius: 50px;
|
| 227 |
-
color: white;
|
| 228 |
-
font-weight: 600;
|
| 229 |
-
font-size: 1rem;
|
| 230 |
cursor: pointer;
|
| 231 |
-
box-shadow: 0 4px 15px rgba(255, 46, 99, 0.4);
|
| 232 |
-
transition: all 0.2s ease;
|
| 233 |
}
|
| 234 |
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
/* --- Tutorial Hint --- */
|
| 241 |
-
.tutorial-hint {
|
| 242 |
-
position: absolute;
|
| 243 |
-
top: 50%;
|
| 244 |
-
left: 20%;
|
| 245 |
-
transform: translateY(-50%);
|
| 246 |
-
color: rgba(255,255,255,0.5);
|
| 247 |
-
font-size: 0.9rem;
|
| 248 |
-
pointer-events: none;
|
| 249 |
-
animation: pulse 2s infinite;
|
| 250 |
text-align: center;
|
| 251 |
-
|
|
|
|
| 252 |
}
|
| 253 |
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
50% { opacity: 0.8; }
|
| 257 |
-
100% { opacity: 0.3; }
|
| 258 |
}
|
| 259 |
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
.tutorial-hint {
|
| 263 |
-
top: 40%;
|
| 264 |
-
left: 50%;
|
| 265 |
-
transform: translate(-50%, -50%);
|
| 266 |
-
width: 100%;
|
| 267 |
-
}
|
| 268 |
-
.brand { font-size: 1rem; }
|
| 269 |
-
.hud-panel { padding: 0.6rem 1rem; }
|
| 270 |
}
|
| 271 |
-
</style>
|
| 272 |
-
</head>
|
| 273 |
-
<body>
|
| 274 |
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
</div>
|
| 287 |
-
</div>
|
| 288 |
-
|
| 289 |
-
<div class="ui-layer">
|
| 290 |
-
<div class="hud-panel">
|
| 291 |
-
<div>
|
| 292 |
-
<div class="stat-value" id="score">0</div>
|
| 293 |
-
<div class="stat-label">Score</div>
|
| 294 |
-
</div>
|
| 295 |
-
</div>
|
| 296 |
-
<button class="btn-icon" id="resetBtn" title="Reset Level">
|
| 297 |
-
<i class="fas fa-redo-alt"></i>
|
| 298 |
-
</button>
|
| 299 |
-
</div>
|
| 300 |
-
|
| 301 |
-
<!-- Win/Loss Modal -->
|
| 302 |
-
<div class="message-overlay" id="modal">
|
| 303 |
-
<div class="message-title" id="modalTitle">Level Complete!</div>
|
| 304 |
-
<div class="message-subtitle" id="modalSubtitle">All targets eliminated.</div>
|
| 305 |
-
<button class="btn-primary" id="modalBtn">Next Level</button>
|
| 306 |
-
</div>
|
| 307 |
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
// --- Configuration ---
|
| 315 |
-
const CONFIG = {
|
| 316 |
-
gravity: 0.5,
|
| 317 |
-
friction: 0.99,
|
| 318 |
-
groundFriction: 0.8,
|
| 319 |
-
elasticity: 0.6,
|
| 320 |
-
slingshotPower: 0.18,
|
| 321 |
-
maxStretch: 150,
|
| 322 |
-
colors: {
|
| 323 |
-
bird: '#ff2e63',
|
| 324 |
-
birdGlow: 'rgba(255, 46, 99, 0.6)',
|
| 325 |
-
pig: '#08d9d6',
|
| 326 |
-
pigGlow: 'rgba(8, 217, 214, 0.6)',
|
| 327 |
-
blockWood: '#eaeaea',
|
| 328 |
-
blockGlass: 'rgba(200, 230, 255, 0.4)',
|
| 329 |
-
slingshot: 'rgba(255, 255, 255, 0.5)'
|
| 330 |
-
}
|
| 331 |
-
};
|
| 332 |
|
| 333 |
-
/
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
|
|
|
| 345 |
}
|
| 346 |
|
| 347 |
-
|
|
|
|
|
|
|
|
|
|
| 348 |
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
// Apply Gravity
|
| 364 |
-
this.vel.y += CONFIG.gravity;
|
| 365 |
-
|
| 366 |
-
// Apply Friction
|
| 367 |
-
this.vel = this.vel.mult(CONFIG.friction);
|
| 368 |
-
|
| 369 |
-
// Update Position
|
| 370 |
-
this.pos = this.pos.add(this.vel);
|
| 371 |
-
}
|
| 372 |
-
|
| 373 |
-
draw(ctx) {
|
| 374 |
-
// Base draw method
|
| 375 |
-
}
|
| 376 |
}
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
constructor(x, y) {
|
| 380 |
-
super(x, y, 20);
|
| 381 |
-
this.trail = [];
|
| 382 |
-
this.isDragging = false;
|
| 383 |
-
}
|
| 384 |
-
|
| 385 |
-
launch(velocity) {
|
| 386 |
-
this.vel = velocity;
|
| 387 |
-
this.isDragging = false;
|
| 388 |
-
// Add launch sound effect logic here if audio allowed
|
| 389 |
-
}
|
| 390 |
-
|
| 391 |
-
update() {
|
| 392 |
-
super.update();
|
| 393 |
-
// Trail logic
|
| 394 |
-
if (this.vel.mag() > 1) {
|
| 395 |
-
this.trail.push({x: this.pos.x, y: this.pos.y, alpha: 1.0});
|
| 396 |
-
}
|
| 397 |
-
// Fade trail
|
| 398 |
-
for (let i = this.trail.length - 1; i >= 0; i--) {
|
| 399 |
-
this.trail[i].alpha -= 0.05;
|
| 400 |
-
if (this.trail[i].alpha <= 0) this.trail.splice(i, 1);
|
| 401 |
-
}
|
| 402 |
-
}
|
| 403 |
-
|
| 404 |
-
draw(ctx) {
|
| 405 |
-
// Draw Trail
|
| 406 |
-
ctx.save();
|
| 407 |
-
for (let t of this.trail) {
|
| 408 |
-
ctx.beginPath();
|
| 409 |
-
ctx.arc(t.x, t.y, this.radius * 0.6, 0, Math.PI * 2);
|
| 410 |
-
ctx.fillStyle = `rgba(255, 46, 99, ${t.alpha * 0.3})`;
|
| 411 |
-
ctx.fill();
|
| 412 |
-
}
|
| 413 |
-
ctx.restore();
|
| 414 |
-
|
| 415 |
-
// Draw Bird (Glowing Orb)
|
| 416 |
-
ctx.save();
|
| 417 |
-
ctx.translate(this.pos.x, this.pos.y);
|
| 418 |
-
|
| 419 |
-
// Glow
|
| 420 |
-
const gradient = ctx.createRadialGradient(0, 0, this.radius * 0.2, 0, 0, this.radius * 2);
|
| 421 |
-
gradient.addColorStop(0, '#fff');
|
| 422 |
-
gradient.addColorStop(0.3, CONFIG.colors.bird);
|
| 423 |
-
gradient.addColorStop(1, 'rgba(255, 46, 99, 0)');
|
| 424 |
-
|
| 425 |
-
ctx.fillStyle = gradient;
|
| 426 |
-
ctx.beginPath();
|
| 427 |
-
ctx.arc(0, 0, this.radius * 2, 0, Math.PI * 2);
|
| 428 |
-
ctx.fill();
|
| 429 |
-
|
| 430 |
-
// Core
|
| 431 |
-
ctx.fillStyle = '#fff';
|
| 432 |
-
ctx.beginPath();
|
| 433 |
-
ctx.arc(0, 0, this.radius * 0.8, 0, Math.PI * 2);
|
| 434 |
-
ctx.fill();
|
| 435 |
-
|
| 436 |
-
ctx.restore();
|
| 437 |
-
}
|
| 438 |
}
|
| 439 |
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
}
|
| 445 |
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
gradient.addColorStop(0, '#a5f3fc');
|
| 454 |
-
gradient.addColorStop(0.4, CONFIG.colors.pig);
|
| 455 |
-
gradient.addColorStop(1, 'rgba(8, 217, 214, 0)');
|
| 456 |
-
|
| 457 |
-
ctx.fillStyle = gradient;
|
| 458 |
-
ctx.beginPath();
|
| 459 |
-
ctx.arc(0, 0, this.radius * 2, 0, Math.PI * 2);
|
| 460 |
-
ctx.fill();
|
| 461 |
-
|
| 462 |
-
// Core
|
| 463 |
-
ctx.fillStyle = '#fff';
|
| 464 |
-
ctx.beginPath();
|
| 465 |
-
ctx.arc(0, 0, this.radius * 0.7, 0, Math.PI * 2);
|
| 466 |
-
ctx.fill();
|
| 467 |
-
|
| 468 |
-
// Face (Simple Sci-Fi Eyes)
|
| 469 |
-
ctx.fillStyle = '#0f172a';
|
| 470 |
-
ctx.beginPath();
|
| 471 |
-
ctx.arc(-5, -2, 3, 0, Math.PI*2);
|
| 472 |
-
ctx.arc(5, -2, 3, 0, Math.PI*2);
|
| 473 |
-
ctx.fill();
|
| 474 |
-
|
| 475 |
-
ctx.restore();
|
| 476 |
-
}
|
| 477 |
}
|
| 478 |
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
this.w = w;
|
| 483 |
-
this.h = h;
|
| 484 |
-
this.type = type;
|
| 485 |
-
this.hp = type === 'glass' ? 1 : 3;
|
| 486 |
-
this.isStatic = true; // Blocks are static until hit hard
|
| 487 |
-
this.mass = (w * h) / 1000;
|
| 488 |
-
}
|
| 489 |
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
// Modern Glass/Neon Block Style
|
| 496 |
-
ctx.fillStyle = this.type === 'glass' ? CONFIG.colors.blockGlass : CONFIG.colors.blockWood;
|
| 497 |
-
ctx.strokeStyle = 'rgba(255,255,255,0.3)';
|
| 498 |
-
ctx.lineWidth = 2;
|
| 499 |
-
|
| 500 |
-
// Rounded Rectangle
|
| 501 |
-
const r = 4;
|
| 502 |
-
ctx.beginPath();
|
| 503 |
-
ctx.roundRect(-this.w/2, -this.h/2, this.w, this.h, r);
|
| 504 |
-
ctx.fill();
|
| 505 |
-
ctx.stroke();
|
| 506 |
-
|
| 507 |
-
// Inner detail
|
| 508 |
-
ctx.fillStyle = 'rgba(255,255,255,0.1)';
|
| 509 |
-
ctx.beginPath();
|
| 510 |
-
ctx.roundRect(-this.w/2 + 2, -this.h/2 + 2, this.w - 4, this.h/2 - 2, r);
|
| 511 |
-
ctx.fill();
|
| 512 |
-
|
| 513 |
-
ctx.restore();
|
| 514 |
-
}
|
| 515 |
-
}
|
| 516 |
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 527 |
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 543 |
|
| 544 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 545 |
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
this.bird = null;
|
| 556 |
-
this.slingshotPos = new Vector(0, 0);
|
| 557 |
-
|
| 558 |
-
this.score = 0;
|
| 559 |
-
this.state = 'WAITING'; // WAITING, DRAGGING, FLYING, ENDED
|
| 560 |
-
this.mousePos = new Vector(0, 0);
|
| 561 |
-
|
| 562 |
-
this.resize();
|
| 563 |
-
window.addEventListener('resize', () => this.resize());
|
| 564 |
-
|
| 565 |
-
this.initInput();
|
| 566 |
-
this.reset();
|
| 567 |
-
this.loop();
|
| 568 |
-
}
|
| 569 |
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 578 |
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
};
|
| 586 |
|
| 587 |
-
|
| 588 |
-
if (this.state !== 'WAITING') return;
|
| 589 |
-
const pos = getPos(e);
|
| 590 |
-
if (pos.dist(this.bird.pos) < this.bird.radius * 3) {
|
| 591 |
-
this.state = 'DRAGGING';
|
| 592 |
-
this.mousePos = pos;
|
| 593 |
-
document.getElementById('tutorial').style.opacity = '0';
|
| 594 |
-
}
|
| 595 |
-
};
|
| 596 |
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 602 |
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
this.bird.pos = this.slingshotPos;
|
| 617 |
-
}
|
| 618 |
-
}
|
| 619 |
-
};
|
| 620 |
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 624 |
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 628 |
}
|
|
|
|
| 629 |
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
this.updateScoreUI();
|
| 633 |
-
this.entities = [];
|
| 634 |
-
this.particles = [];
|
| 635 |
-
this.state = 'WAITING';
|
| 636 |
-
document.getElementById('modal').classList.remove('active');
|
| 637 |
-
document.getElementById('tutorial').style.opacity = '1';
|
| 638 |
-
|
| 639 |
-
// Setup Slingshot Position (Responsive)
|
| 640 |
-
this.slingshotPos = new Vector(this.width * 0.15, this.height * 0.7);
|
| 641 |
-
|
| 642 |
-
// Create Bird
|
| 643 |
-
this.bird = new Bird(this.slingshotPos.x, this.slingshotPos.y);
|
| 644 |
-
this.entities.push(this.bird);
|
| 645 |
-
|
| 646 |
-
// Create Level (Pyramid structure)
|
| 647 |
-
const startX = this.width * 0.7;
|
| 648 |
-
const groundY = this.height * 0.8;
|
| 649 |
-
const blockSize = 40;
|
| 650 |
-
|
| 651 |
-
// Base
|
| 652 |
-
this.entities.push(new Block(startX, groundY - blockSize/2, blockSize, blockSize, 'glass'));
|
| 653 |
-
this.entities.push(new Block(startX + blockSize, groundY - blockSize/2, blockSize, blockSize, 'glass'));
|
| 654 |
-
this.entities.push(new Block(startX - blockSize, groundY - blockSize/2, blockSize, blockSize, 'glass'));
|
| 655 |
-
|
| 656 |
-
// Mid
|
| 657 |
-
this.entities.push(new Block(startX, groundY - blockSize - blockSize/2, blockSize * 3, blockSize/2, 'wood'));
|
| 658 |
-
|
| 659 |
-
// Top Pig
|
| 660 |
-
this.entities.push(new Pig(startX, groundY - blockSize - blockSize - 20));
|
| 661 |
-
|
| 662 |
-
// Right Tower
|
| 663 |
-
this.entities.push(new Block(startX + 150, groundY - blockSize*2, blockSize/2, blockSize*4, 'glass'));
|
| 664 |
-
this.entities.push(new Block(startX + 150, groundY - blockSize*2 - 20, blockSize*2, blockSize/2, 'wood'));
|
| 665 |
-
this.entities.push(new Pig(startX + 150, groundY - blockSize*2 - 40));
|
| 666 |
-
|
| 667 |
-
// Left Tower
|
| 668 |
-
this.entities.push(new Block(startX - 150, groundY - blockSize*2, blockSize/2, blockSize*4, 'glass'));
|
| 669 |
-
this.entities.push(new Pig(startX - 150, groundY - 30));
|
| 670 |
-
}
|
| 671 |
|
| 672 |
-
|
| 673 |
-
|
|
|
|
|
|
|
|
|
|
| 674 |
}
|
| 675 |
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
|
|
|
| 680 |
}
|
|
|
|
| 681 |
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
// Stop if too slow
|
| 694 |
-
if (Math.abs(e.vel.y) < 1 && Math.abs(e.vel.x) < 0.5) {
|
| 695 |
-
e.vel.x = 0;
|
| 696 |
-
e.vel.y = 0;
|
| 697 |
-
}
|
| 698 |
-
}
|
| 699 |
-
} else if (e instanceof Block) {
|
| 700 |
-
// Simple ground for blocks
|
| 701 |
-
if (e.pos.y + e.h/2 > groundY && !e.isStatic) {
|
| 702 |
-
e.pos.y = groundY - e.h/2;
|
| 703 |
-
e.vel.y = 0;
|
| 704 |
-
e.vel.x = 0;
|
| 705 |
-
e.isStatic = true; // Rest on ground
|
| 706 |
-
}
|
| 707 |
-
}
|
| 708 |
-
});
|
| 709 |
-
|
| 710 |
-
// 2. Bird vs Blocks/Pigs
|
| 711 |
-
if (this.state === 'FLYING') {
|
| 712 |
-
this.entities.forEach(target => {
|
| 713 |
-
if (target === this.bird || !target.active) return;
|
| 714 |
-
|
| 715 |
-
// Circle vs Circle (Bird vs Pig)
|
| 716 |
-
if (target instanceof Pig) {
|
| 717 |
-
const dist = this.bird.pos.dist(target.pos);
|
| 718 |
-
if (dist < this.bird.radius + target.radius) {
|
| 719 |
-
target.active = false;
|
| 720 |
-
this.score += 500;
|
| 721 |
-
this.updateScoreUI();
|
| 722 |
-
this.createExplosion(target.pos.x, target.pos.y, CONFIG.colors.pig, 15);
|
| 723 |
-
// Bounce bird slightly
|
| 724 |
-
this.bird.vel = this.bird.vel.mult(0.5);
|
| 725 |
-
}
|
| 726 |
-
}
|
| 727 |
-
// Circle vs AABB (Bird vs Block) - Simplified
|
| 728 |
-
else if (target instanceof Block) {
|
| 729 |
-
// Find closest point on rectangle to circle center
|
| 730 |
-
let testX = this.bird.pos.x;
|
| 731 |
-
let testY = this.bird.pos.y;
|
| 732 |
-
|
| 733 |
-
if (this.bird.pos.x < target.pos.x - target.w/2) testX = target.pos.x - target.w/2;
|
| 734 |
-
else if (this.bird.pos.x > target.pos.x + target.w/2) testX = target.pos.x + target.w/2;
|
| 735 |
-
|
| 736 |
-
if (this.bird.pos.y < target.pos.y - target.h/2) testY = target.pos.y - target.h/2;
|
| 737 |
-
else if (this.bird.pos.y > target.pos.y + target.h/2) testY = target.pos.y + target.h/2;
|
| 738 |
-
|
| 739 |
-
const distX = this.bird.pos.x - testX;
|
| 740 |
-
const distY = this.bird.pos.y - testY;
|
| 741 |
-
const distance = Math.sqrt((distX*distX) + (distY*distY));
|
| 742 |
-
|
| 743 |
-
if (distance <= this.bird.radius) {
|
| 744 |
-
// Collision detected
|
| 745 |
-
const impactForce = this.bird.vel.mag();
|
| 746 |
-
if (impactForce > 2) {
|
| 747 |
-
target.hp--;
|
| 748 |
-
this.createExplosion(testX, testY, '#fff', 3);
|
| 749 |
-
if (target.hp <= 0) {
|
| 750 |
-
target.active = false;
|
| 751 |
-
this.score += 100;
|
| 752 |
-
this.updateScoreUI();
|
| 753 |
-
} else {
|
| 754 |
-
// Wake up block (physics)
|
| 755 |
-
target.isStatic = false;
|
| 756 |
-
target.vel = this.bird.vel.mult(0.4);
|
| 757 |
-
}
|
| 758 |
-
}
|
| 759 |
-
// Reflect bird (very approximate)
|
| 760 |
-
this.bird.vel.x *= -0.5;
|
| 761 |
-
this.bird.vel.y *= -0.5;
|
| 762 |
-
}
|
| 763 |
-
}
|
| 764 |
-
});
|
| 765 |
-
}
|
| 766 |
-
}
|
| 767 |
|
| 768 |
-
|
| 769 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 770 |
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
|
| 781 |
-
|
| 782 |
-
|
| 783 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 784 |
}
|
| 785 |
-
|
|
|
|
|
|
|
|
|
|
| 786 |
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
|
|
|
|
|
|
|
|
|
| 793 |
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
-
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
|
| 806 |
-
|
| 807 |
-
this.ctx.lineTo(this.width, groundY);
|
| 808 |
-
this.ctx.strokeStyle = 'rgba(255,255,255,0.3)';
|
| 809 |
-
this.ctx.lineWidth = 2;
|
| 810 |
-
this.ctx.stroke();
|
| 811 |
-
}
|
| 812 |
|
| 813 |
-
|
| 814 |
-
|
| 815 |
-
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
|
| 819 |
-
|
| 820 |
-
|
| 821 |
-
|
| 822 |
-
|
| 823 |
-
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
| 829 |
-
|
| 830 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 831 |
}
|
|
|
|
| 832 |
|
| 833 |
-
|
| 834 |
-
|
| 835 |
-
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
if (this.state === 'DRAGGING') {
|
| 839 |
-
// Constrain bird to radius
|
| 840 |
-
const pullVector = this.mousePos.sub(this.slingshotPos);
|
| 841 |
-
const dist = pullVector.mag();
|
| 842 |
-
if (dist > CONFIG.maxStretch) {
|
| 843 |
-
const clamped = pullVector.normalize().mult(CONFIG.maxStretch);
|
| 844 |
-
this.bird.pos = this.slingshotPos.add(clamped);
|
| 845 |
-
} else {
|
| 846 |
-
this.bird.pos = this.mousePos;
|
| 847 |
-
}
|
| 848 |
-
}
|
| 849 |
-
|
| 850 |
-
this.entities.forEach(e => e.update());
|
| 851 |
-
this.checkCollisions();
|
| 852 |
-
this.checkWinCondition();
|
| 853 |
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 859 |
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 863 |
|
| 864 |
-
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
this.ctx.beginPath();
|
| 873 |
-
this.ctx.strokeStyle = 'rgba(255, 255, 255, 0.2)';
|
| 874 |
-
this.ctx.lineWidth = 2;
|
| 875 |
-
this.ctx.setLineDash([5, 5]);
|
| 876 |
-
|
| 877 |
-
let simPos = this.bird.pos;
|
| 878 |
-
let pullVector = this.slingshotPos.sub(this.bird.pos);
|
| 879 |
-
let simVel = pullVector.normalize().mult(Math.min(pullVector.mag(), CONFIG.maxStretch) * CONFIG.slingshotPower);
|
| 880 |
-
|
| 881 |
-
this.ctx.moveTo(simPos.x, simPos.y);
|
| 882 |
-
for(let i=0; i<15; i++) {
|
| 883 |
-
simVel.y += CONFIG.gravity;
|
| 884 |
-
simPos = simPos.add(simVel);
|
| 885 |
-
this.ctx.lineTo(simPos.x, simPos.y);
|
| 886 |
-
}
|
| 887 |
-
this.ctx.stroke();
|
| 888 |
-
this.ctx.setLineDash([]);
|
| 889 |
-
}
|
| 890 |
|
| 891 |
-
|
| 892 |
-
|
|
|
|
|
|
|
|
|
|
| 893 |
}
|
| 894 |
|
| 895 |
// --- Init ---
|
| 896 |
-
|
| 897 |
-
|
| 898 |
-
|
| 899 |
-
// UI Listeners
|
| 900 |
-
document.getElementById('resetBtn').addEventListener('click', () => {
|
| 901 |
-
game.reset();
|
| 902 |
-
});
|
| 903 |
-
|
| 904 |
-
document.getElementById('modalBtn').addEventListener('click', () => {
|
| 905 |
-
game.reset();
|
| 906 |
-
});
|
| 907 |
-
};
|
| 908 |
|
| 909 |
</script>
|
| 910 |
</body>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Sprunki OC Creator - Phase 9</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
<style>
|
| 8 |
:root {
|
| 9 |
+
--bg-color: #121212;
|
| 10 |
+
--panel-bg: #1e1e1e;
|
| 11 |
+
--text-color: #ffffff;
|
| 12 |
+
--accent-primary: #00ffcc; /* Cyan/Teal */
|
| 13 |
+
--accent-secondary: #ff00ff; /* Magenta */
|
| 14 |
+
--accent-horror: #ff3333; /* Red for Phase 9 */
|
| 15 |
+
--border-radius: 12px;
|
| 16 |
+
--font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 17 |
+
--transition-speed: 0.3s;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
/* Phase 9 Horror Theme Variables */
|
| 21 |
+
[data-theme="horror"] {
|
| 22 |
+
--bg-color: #050000;
|
| 23 |
+
--panel-bg: #1a0505;
|
| 24 |
+
--accent-primary: #55ff00;
|
| 25 |
+
--accent-secondary: #ff0000;
|
| 26 |
+
--text-color: #e0e0e0;
|
| 27 |
}
|
| 28 |
|
| 29 |
* {
|
| 30 |
box-sizing: border-box;
|
| 31 |
margin: 0;
|
| 32 |
padding: 0;
|
|
|
|
| 33 |
}
|
| 34 |
|
| 35 |
body {
|
| 36 |
+
font-family: var(--font-family);
|
| 37 |
+
background-color: var(--bg-color);
|
| 38 |
+
color: var(--text-color);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
display: flex;
|
| 40 |
flex-direction: column;
|
| 41 |
+
min-height: 100vh;
|
| 42 |
+
overflow-x: hidden;
|
| 43 |
+
transition: background-color var(--transition-speed);
|
| 44 |
}
|
| 45 |
|
| 46 |
+
/* Header */
|
| 47 |
header {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
display: flex;
|
| 49 |
justify-content: space-between;
|
| 50 |
align-items: center;
|
| 51 |
+
padding: 1rem 2rem;
|
| 52 |
+
background: rgba(30, 30, 30, 0.8);
|
| 53 |
+
backdrop-filter: blur(10px);
|
| 54 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
| 55 |
+
position: sticky;
|
| 56 |
+
top: 0;
|
| 57 |
z-index: 100;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
}
|
| 59 |
|
| 60 |
+
.logo {
|
| 61 |
+
font-size: 1.5rem;
|
| 62 |
font-weight: 800;
|
| 63 |
+
background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
|
|
|
|
|
|
|
| 64 |
-webkit-background-clip: text;
|
| 65 |
-webkit-text-fill-color: transparent;
|
| 66 |
+
letter-spacing: 1px;
|
| 67 |
+
text-transform: uppercase;
|
| 68 |
}
|
| 69 |
|
| 70 |
.anycoder-link {
|
| 71 |
+
font-size: 0.9rem;
|
| 72 |
+
color: var(--text-color);
|
| 73 |
text-decoration: none;
|
| 74 |
+
border: 1px solid var(--accent-primary);
|
| 75 |
+
padding: 0.4rem 0.8rem;
|
|
|
|
| 76 |
border-radius: 20px;
|
|
|
|
| 77 |
transition: all 0.3s ease;
|
| 78 |
}
|
| 79 |
|
| 80 |
.anycoder-link:hover {
|
| 81 |
+
background: var(--accent-primary);
|
| 82 |
+
color: #000;
|
| 83 |
+
box-shadow: 0 0 15px var(--accent-primary);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/* Main Layout */
|
| 87 |
+
main {
|
| 88 |
+
flex: 1;
|
| 89 |
+
display: grid;
|
| 90 |
+
grid-template-columns: 1fr 350px;
|
| 91 |
+
gap: 2rem;
|
| 92 |
+
padding: 2rem;
|
| 93 |
+
max-width: 1600px;
|
| 94 |
+
margin: 0 auto;
|
| 95 |
+
width: 100%;
|
| 96 |
}
|
| 97 |
|
| 98 |
+
@media (max-width: 900px) {
|
| 99 |
+
main {
|
| 100 |
+
grid-template-columns: 1fr;
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
/* Preview Section */
|
| 105 |
+
.preview-section {
|
| 106 |
+
background: var(--panel-bg);
|
| 107 |
+
border-radius: var(--border-radius);
|
| 108 |
+
display: flex;
|
| 109 |
+
flex-direction: column;
|
| 110 |
+
align-items: center;
|
| 111 |
+
justify-content: center;
|
| 112 |
position: relative;
|
| 113 |
+
overflow: hidden;
|
| 114 |
+
border: 1px solid rgba(255, 255, 255, 0.05);
|
| 115 |
+
min-height: 500px;
|
| 116 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
.stage-bg {
|
| 120 |
+
position: absolute;
|
| 121 |
+
top: 0;
|
| 122 |
+
left: 0;
|
| 123 |
width: 100%;
|
| 124 |
height: 100%;
|
| 125 |
+
opacity: 0.1;
|
| 126 |
+
background-image: radial-gradient(circle at center, var(--accent-primary) 0%, transparent 70%);
|
| 127 |
+
animation: pulseBg 4s infinite alternate;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
@keyframes pulseBg {
|
| 131 |
+
0% { transform: scale(1); opacity: 0.1; }
|
| 132 |
+
100% { transform: scale(1.2); opacity: 0.2; }
|
| 133 |
}
|
| 134 |
|
| 135 |
+
/* Character Container */
|
| 136 |
+
.character-wrapper {
|
| 137 |
+
position: relative;
|
| 138 |
+
width: 300px;
|
| 139 |
+
height: 450px;
|
| 140 |
+
display: flex;
|
| 141 |
+
justify-content: center;
|
| 142 |
+
align-items: flex-end;
|
| 143 |
+
z-index: 10;
|
| 144 |
+
/* Default Idle Animation */
|
| 145 |
+
animation: bounce 2s infinite ease-in-out;
|
| 146 |
}
|
| 147 |
|
| 148 |
+
@keyframes bounce {
|
| 149 |
+
0%, 100% { transform: translateY(0); }
|
| 150 |
+
50% { transform: translateY(-10px); }
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/* SVG Styles */
|
| 154 |
+
#character-svg {
|
| 155 |
width: 100%;
|
| 156 |
height: 100%;
|
| 157 |
+
filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
|
| 158 |
+
overflow: visible;
|
| 159 |
}
|
| 160 |
|
| 161 |
+
/* Controls Section */
|
| 162 |
+
.controls-section {
|
| 163 |
+
background: var(--panel-bg);
|
| 164 |
+
border-radius: var(--border-radius);
|
| 165 |
+
padding: 1.5rem;
|
|
|
|
| 166 |
display: flex;
|
| 167 |
+
flex-direction: column;
|
| 168 |
+
gap: 1.5rem;
|
| 169 |
+
border: 1px solid rgba(255, 255, 255, 0.05);
|
| 170 |
+
height: fit-content;
|
| 171 |
}
|
| 172 |
|
| 173 |
+
.tabs {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
display: flex;
|
| 175 |
+
gap: 0.5rem;
|
| 176 |
+
overflow-x: auto;
|
| 177 |
+
padding-bottom: 0.5rem;
|
| 178 |
+
border-bottom: 1px solid rgba(255,255,255,0.1);
|
|
|
|
| 179 |
}
|
| 180 |
|
| 181 |
+
.tab-btn {
|
| 182 |
+
background: transparent;
|
| 183 |
+
border: none;
|
| 184 |
+
color: #888;
|
| 185 |
+
padding: 0.5rem 1rem;
|
| 186 |
+
cursor: pointer;
|
| 187 |
+
font-weight: 600;
|
| 188 |
+
white-space: nowrap;
|
| 189 |
+
transition: color 0.3s;
|
| 190 |
}
|
| 191 |
|
| 192 |
+
.tab-btn.active {
|
| 193 |
+
color: var(--accent-primary);
|
| 194 |
+
border-bottom: 2px solid var(--accent-primary);
|
|
|
|
| 195 |
}
|
| 196 |
|
| 197 |
+
.control-panel {
|
| 198 |
+
display: none;
|
| 199 |
+
flex-direction: column;
|
| 200 |
+
gap: 1rem;
|
|
|
|
| 201 |
}
|
| 202 |
|
| 203 |
+
.control-panel.active {
|
| 204 |
+
display: flex;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
.options-grid {
|
| 208 |
+
display: grid;
|
| 209 |
+
grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
|
| 210 |
+
gap: 10px;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
.option-item {
|
| 214 |
+
aspect-ratio: 1;
|
| 215 |
+
background: rgba(255,255,255,0.05);
|
| 216 |
+
border: 2px solid transparent;
|
| 217 |
+
border-radius: 8px;
|
| 218 |
cursor: pointer;
|
| 219 |
display: flex;
|
| 220 |
align-items: center;
|
| 221 |
justify-content: center;
|
| 222 |
+
transition: all 0.2s;
|
| 223 |
+
overflow: hidden;
|
| 224 |
}
|
| 225 |
|
| 226 |
+
.option-item:hover {
|
| 227 |
+
background: rgba(255,255,255,0.1);
|
| 228 |
+
transform: scale(1.05);
|
| 229 |
}
|
| 230 |
|
| 231 |
+
.option-item.selected {
|
| 232 |
+
border-color: var(--accent-primary);
|
| 233 |
+
box-shadow: 0 0 10px var(--accent-primary);
|
| 234 |
}
|
| 235 |
|
| 236 |
+
.option-item svg {
|
| 237 |
+
width: 80%;
|
| 238 |
+
height: 80%;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
}
|
| 240 |
|
| 241 |
+
/* Sliders and Inputs */
|
| 242 |
+
.input-group {
|
| 243 |
+
display: flex;
|
| 244 |
+
flex-direction: column;
|
| 245 |
+
gap: 0.5rem;
|
| 246 |
}
|
| 247 |
|
| 248 |
+
label {
|
| 249 |
+
font-size: 0.9rem;
|
| 250 |
+
color: #aaa;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
}
|
| 252 |
|
| 253 |
+
input[type="range"] {
|
| 254 |
+
width: 100%;
|
| 255 |
+
accent-color: var(--accent-primary);
|
|
|
|
| 256 |
}
|
| 257 |
|
| 258 |
+
input[type="color"] {
|
| 259 |
+
width: 100%;
|
| 260 |
+
height: 40px;
|
| 261 |
border: none;
|
| 262 |
+
background: transparent;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
cursor: pointer;
|
|
|
|
|
|
|
| 264 |
}
|
| 265 |
|
| 266 |
+
/* Upload Area */
|
| 267 |
+
.upload-area {
|
| 268 |
+
border: 2px dashed #444;
|
| 269 |
+
border-radius: var(--border-radius);
|
| 270 |
+
padding: 2rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
text-align: center;
|
| 272 |
+
cursor: pointer;
|
| 273 |
+
transition: border-color 0.3s;
|
| 274 |
}
|
| 275 |
|
| 276 |
+
.upload-area:hover {
|
| 277 |
+
border-color: var(--accent-secondary);
|
|
|
|
|
|
|
| 278 |
}
|
| 279 |
|
| 280 |
+
.upload-area input {
|
| 281 |
+
display: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
}
|
|
|
|
|
|
|
|
|
|
| 283 |
|
| 284 |
+
.btn {
|
| 285 |
+
background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
|
| 286 |
+
border: none;
|
| 287 |
+
padding: 0.8rem 1.5rem;
|
| 288 |
+
border-radius: 30px;
|
| 289 |
+
color: #fff;
|
| 290 |
+
font-weight: bold;
|
| 291 |
+
cursor: pointer;
|
| 292 |
+
text-transform: uppercase;
|
| 293 |
+
letter-spacing: 1px;
|
| 294 |
+
transition: transform 0.2s, opacity 0.2s;
|
| 295 |
+
width: 100%;
|
| 296 |
+
margin-top: 1rem;
|
| 297 |
+
}
|
| 298 |
|
| 299 |
+
.btn:hover {
|
| 300 |
+
opacity: 0.9;
|
| 301 |
+
transform: translateY(-2px);
|
| 302 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
|
| 304 |
+
.btn-secondary {
|
| 305 |
+
background: transparent;
|
| 306 |
+
border: 1px solid var(--accent-primary);
|
| 307 |
+
color: var(--accent-primary);
|
| 308 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
|
| 310 |
+
/* Phase 9 Toggle */
|
| 311 |
+
.theme-toggle {
|
| 312 |
+
position: absolute;
|
| 313 |
+
top: 1rem;
|
| 314 |
+
right: 1rem;
|
| 315 |
+
background: rgba(0,0,0,0.5);
|
| 316 |
+
border: 1px solid #444;
|
| 317 |
+
color: #fff;
|
| 318 |
+
padding: 0.5rem 1rem;
|
| 319 |
+
border-radius: 20px;
|
| 320 |
+
cursor: pointer;
|
| 321 |
+
font-size: 0.8rem;
|
| 322 |
+
z-index: 20;
|
| 323 |
}
|
| 324 |
|
| 325 |
+
[data-theme="horror"] .theme-toggle {
|
| 326 |
+
border-color: var(--accent-horror);
|
| 327 |
+
color: var(--accent-horror);
|
| 328 |
+
}
|
| 329 |
|
| 330 |
+
/* Notification */
|
| 331 |
+
.notification {
|
| 332 |
+
position: fixed;
|
| 333 |
+
bottom: 20px;
|
| 334 |
+
left: 50%;
|
| 335 |
+
transform: translateX(-50%);
|
| 336 |
+
background: var(--panel-bg);
|
| 337 |
+
border: 1px solid var(--accent-primary);
|
| 338 |
+
padding: 10px 20px;
|
| 339 |
+
border-radius: 30px;
|
| 340 |
+
opacity: 0;
|
| 341 |
+
transition: opacity 0.3s;
|
| 342 |
+
pointer-events: none;
|
| 343 |
+
z-index: 200;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
}
|
| 345 |
+
.notification.show {
|
| 346 |
+
opacity: 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
}
|
| 348 |
|
| 349 |
+
/* Animations for Phase 9 */
|
| 350 |
+
[data-theme="horror"] .character-wrapper {
|
| 351 |
+
animation: glitchShake 0.5s infinite linear;
|
| 352 |
+
}
|
|
|
|
| 353 |
|
| 354 |
+
@keyframes glitchShake {
|
| 355 |
+
0% { transform: translate(0); }
|
| 356 |
+
20% { transform: translate(-2px, 2px); }
|
| 357 |
+
40% { transform: translate(-2px, -2px); }
|
| 358 |
+
60% { transform: translate(2px, 2px); }
|
| 359 |
+
80% { transform: translate(2px, -2px); }
|
| 360 |
+
100% { transform: translate(0); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
}
|
| 362 |
|
| 363 |
+
</style>
|
| 364 |
+
</head>
|
| 365 |
+
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
|
| 367 |
+
<header>
|
| 368 |
+
<div class="logo">Sprunki OC <span style="font-size:0.8em; opacity:0.7;">PHASE 9</span></div>
|
| 369 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">Built with anycoder</a>
|
| 370 |
+
</header>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
|
| 372 |
+
<main>
|
| 373 |
+
<!-- Preview Area -->
|
| 374 |
+
<section class="preview-section" id="previewContainer">
|
| 375 |
+
<div class="stage-bg"></div>
|
| 376 |
+
|
| 377 |
+
<button class="theme-toggle" id="themeToggle">👻 Toggle Phase 9 Mode</button>
|
| 378 |
+
|
| 379 |
+
<div class="character-wrapper" id="characterWrapper">
|
| 380 |
+
<!-- SVG Character will be rendered here -->
|
| 381 |
+
<svg id="character-svg" viewBox="0 0 200 300" xmlns="http://www.w3.org/2000/svg">
|
| 382 |
+
<defs>
|
| 383 |
+
<filter id="glow" x="-20%" y="-20%" width="140%" height="140%">
|
| 384 |
+
<feGaussianBlur stdDeviation="3" result="blur" />
|
| 385 |
+
<feComposite in="SourceGraphic" in2="blur" operator="over" />
|
| 386 |
+
</filter>
|
| 387 |
+
</defs>
|
| 388 |
+
<!-- Layers -->
|
| 389 |
+
<g id="layer-body"></g>
|
| 390 |
+
<g id="layer-face"></g>
|
| 391 |
+
<g id="layer-mouth"></g>
|
| 392 |
+
<g id="layer-accessory"></g>
|
| 393 |
+
<g id="layer-overlay"></g> <!-- For uploads -->
|
| 394 |
+
</svg>
|
| 395 |
+
</div>
|
| 396 |
+
</section>
|
| 397 |
+
|
| 398 |
+
<!-- Controls Area -->
|
| 399 |
+
<section class="controls-section">
|
| 400 |
+
<div class="tabs">
|
| 401 |
+
<button class="tab-btn active" onclick="switchTab('body')">Body</button>
|
| 402 |
+
<button class="tab-btn" onclick="switchTab('face')">Face</button>
|
| 403 |
+
<button class="tab-btn" onclick="switchTab('mouth')">Mouth</button>
|
| 404 |
+
<button class="tab-btn" onclick="switchTab('acc')">Accessory</button>
|
| 405 |
+
<button class="tab-btn" onclick="switchTab('upload')">Upload</button>
|
| 406 |
+
</div>
|
| 407 |
|
| 408 |
+
<!-- Body Controls -->
|
| 409 |
+
<div id="panel-body" class="control-panel active">
|
| 410 |
+
<div class="input-group">
|
| 411 |
+
<label>Base Color</label>
|
| 412 |
+
<input type="color" id="bodyColor" value="#00ffcc">
|
| 413 |
+
</div>
|
| 414 |
+
<div class="input-group">
|
| 415 |
+
<label>Shape</label>
|
| 416 |
+
<div class="options-grid" id="bodyShapes">
|
| 417 |
+
<!-- JS generated -->
|
| 418 |
+
</div>
|
| 419 |
+
</div>
|
| 420 |
+
</div>
|
| 421 |
|
| 422 |
+
<!-- Face Controls -->
|
| 423 |
+
<div id="panel-face" class="control-panel">
|
| 424 |
+
<div class="input-group">
|
| 425 |
+
<label>Eye Style</label>
|
| 426 |
+
<div class="options-grid" id="eyeStyles">
|
| 427 |
+
<!-- JS generated -->
|
| 428 |
+
</div>
|
| 429 |
+
</div>
|
| 430 |
+
<div class="input-group">
|
| 431 |
+
<label>Eye Color</label>
|
| 432 |
+
<input type="color" id="eyeColor" value="#ffffff">
|
| 433 |
+
</div>
|
| 434 |
+
</div>
|
| 435 |
|
| 436 |
+
<!-- Mouth Controls -->
|
| 437 |
+
<div id="panel-mouth" class="control-panel">
|
| 438 |
+
<div class="input-group">
|
| 439 |
+
<label>Expression</label>
|
| 440 |
+
<div class="options-grid" id="mouthStyles">
|
| 441 |
+
<!-- JS generated -->
|
| 442 |
+
</div>
|
| 443 |
+
</div>
|
| 444 |
+
</div>
|
| 445 |
|
| 446 |
+
<!-- Accessory Controls -->
|
| 447 |
+
<div id="panel-acc" class="control-panel">
|
| 448 |
+
<div class="input-group">
|
| 449 |
+
<label>Hat / Gear</label>
|
| 450 |
+
<div class="options-grid" id="accStyles">
|
| 451 |
+
<!-- JS generated -->
|
| 452 |
+
</div>
|
| 453 |
+
</div>
|
| 454 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 455 |
|
| 456 |
+
<!-- Upload Controls -->
|
| 457 |
+
<div id="panel-upload" class="control-panel">
|
| 458 |
+
<div class="upload-area" onclick="document.getElementById('fileInput').click()">
|
| 459 |
+
<p>Click to upload PNG/JPG</p>
|
| 460 |
+
<span style="font-size:0.8em; color:#666;">(Applies as Overlay Texture)</span>
|
| 461 |
+
<input type="file" id="fileInput" accept="image/*">
|
| 462 |
+
</div>
|
| 463 |
+
<div class="input-group" style="margin-top:1rem;">
|
| 464 |
+
<label>Overlay Scale</label>
|
| 465 |
+
<input type="range" id="overlayScale" min="0.1" max="2" step="0.1" value="1">
|
| 466 |
+
</div>
|
| 467 |
+
<div class="input-group">
|
| 468 |
+
<label>Overlay Opacity</label>
|
| 469 |
+
<input type="range" id="overlayOpacity" min="0" max="1" step="0.1" value="1">
|
| 470 |
+
</div>
|
| 471 |
+
<button class="btn btn-secondary" onclick="clearOverlay()">Remove Overlay</button>
|
| 472 |
+
</div>
|
| 473 |
|
| 474 |
+
<div style="margin-top:auto; border-top: 1px solid rgba(255,255,255,0.1); padding-top:1rem;">
|
| 475 |
+
<button class="btn" onclick="randomize()">🎲 Randomize OC</button>
|
| 476 |
+
<button class="btn" style="background: #333; margin-top: 0.5rem;" onclick="downloadCharacter()">📸 Download PNG</button>
|
| 477 |
+
</div>
|
| 478 |
+
</section>
|
| 479 |
+
</main>
|
|
|
|
| 480 |
|
| 481 |
+
<div class="notification" id="notification">Image Saved!</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
|
| 483 |
+
<script>
|
| 484 |
+
// --- Data Assets (SVG Paths) ---
|
| 485 |
+
const assets = {
|
| 486 |
+
bodies: [
|
| 487 |
+
{ id: 'b1', path: 'M 60 250 C 60 150 140 150 140 250 L 140 300 L 60 300 Z' }, // Tall Rect
|
| 488 |
+
{ id: 'b2', path: 'M 50 260 C 50 130 150 130 150 260 L 150 300 L 50 300 Z' }, // Wide Rect
|
| 489 |
+
{ id: 'b3', path: 'M 70 250 C 70 160 130 160 130 250 C 130 280 150 300 100 300 C 50 300 70 280 70 250 Z' }, // Blob
|
| 490 |
+
{ id: 'b4', path: 'M 100 150 L 140 300 L 60 300 Z' } // Triangle
|
| 491 |
+
],
|
| 492 |
+
eyes: [
|
| 493 |
+
{ id: 'e1', type: 'circle', cx: 75, cy: 180, r: 15, cx2: 125, cy2: 180, r2: 15 },
|
| 494 |
+
{ id: 'e2', type: 'rect', x: 65, y: 170, w: 20, h: 20, x2: 115, y2: 170, w2: 20, h2: 20 },
|
| 495 |
+
{ id: 'e3', type: 'spiral', d: 'M75 180 m-10 0 a10 10 0 1 0 20 0 a10 10 0 1 0 -20 0 M125 180 m-10 0 a10 10 0 1 0 20 0 a10 10 0 1 0 -20 0' },
|
| 496 |
+
{ id: 'e4', type: 'x', d: 'M65 170 L85 190 M85 170 L65 190 M115 170 L135 190 M135 170 L115 190' },
|
| 497 |
+
{ id: 'e5', type: 'line', d: 'M65 180 L85 180 M115 180 L135 180' }
|
| 498 |
+
],
|
| 499 |
+
mouths: [
|
| 500 |
+
{ id: 'm1', path: 'M 80 220 Q 100 240 120 220' }, // Smile
|
| 501 |
+
{ id: 'm2', path: 'M 80 230 Q 100 210 120 230' }, // Frown
|
| 502 |
+
{ id: 'm3', path: 'M 90 220 L 110 220 L 100 240 Z' }, // Teeth
|
| 503 |
+
{ id: 'm4', path: 'M 85 220 L 115 220' }, // Flat
|
| 504 |
+
{ id: 'm5', path: 'M 85 220 Q 100 220 115 220 Q 100 250 85 220' } // Open
|
| 505 |
+
],
|
| 506 |
+
accessories: [
|
| 507 |
+
{ id: 'a0', path: '' }, // None
|
| 508 |
+
{ id: 'a1', path: 'M 60 160 L 140 160 L 140 130 Q 100 100 60 130 Z', fill: '#333' }, // Cap
|
| 509 |
+
{ id: 'a2', path: 'M 60 150 L 60 120 L 140 120 L 140 150 M 50 150 L 60 120 L 60 150', fill: '#555' }, // Headphones
|
| 510 |
+
{ id: 'a3', path: 'M 80 140 L 80 110 L 90 110 L 90 140 M 110 140 L 110 110 L 120 110 L 120 140', stroke: '#fff', strokeWidth: 3 }, // Antenna
|
| 511 |
+
{ id: 'a4', path: 'M 50 140 L 150 140 L 130 80 L 70 80 Z', fill: 'rgba(255,0,0,0.5)' } // Visor
|
| 512 |
+
]
|
| 513 |
+
};
|
| 514 |
|
| 515 |
+
// --- State Management ---
|
| 516 |
+
const state = {
|
| 517 |
+
bodyColor: '#00ffcc',
|
| 518 |
+
bodyShape: assets.bodies[0],
|
| 519 |
+
eyeStyle: assets.eyes[0],
|
| 520 |
+
eyeColor: '#ffffff',
|
| 521 |
+
mouthStyle: assets.mouths[0],
|
| 522 |
+
accessory: assets.accessories[0],
|
| 523 |
+
overlayImage: null,
|
| 524 |
+
overlayScale: 1,
|
| 525 |
+
overlayOpacity: 1,
|
| 526 |
+
isHorror: false
|
| 527 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
| 528 |
|
| 529 |
+
// --- DOM Elements ---
|
| 530 |
+
const els = {
|
| 531 |
+
svg: document.getElementById('character-svg'),
|
| 532 |
+
layerBody: document.getElementById('layer-body'),
|
| 533 |
+
layerFace: document.getElementById('layer-face'),
|
| 534 |
+
layerMouth: document.getElementById('layer-mouth'),
|
| 535 |
+
layerAcc: document.getElementById('layer-accessory'),
|
| 536 |
+
layerOverlay: document.getElementById('layer-overlay'),
|
| 537 |
+
bodyColor: document.getElementById('bodyColor'),
|
| 538 |
+
eyeColor: document.getElementById('eyeColor'),
|
| 539 |
+
overlayScale: document.getElementById('overlayScale'),
|
| 540 |
+
overlayOpacity: document.getElementById('overlayOpacity'),
|
| 541 |
+
fileInput: document.getElementById('fileInput'),
|
| 542 |
+
themeToggle: document.getElementById('themeToggle')
|
| 543 |
+
};
|
| 544 |
|
| 545 |
+
// --- Rendering Logic ---
|
| 546 |
+
function render() {
|
| 547 |
+
// Render Body
|
| 548 |
+
els.layerBody.innerHTML = `<path d="${state.bodyShape.path}" fill="${state.bodyColor}" stroke="${state.isHorror ? '#ff0000' : '#000'}" stroke-width="2" />`;
|
| 549 |
+
|
| 550 |
+
// Render Eyes
|
| 551 |
+
let eyeContent = '';
|
| 552 |
+
const s = state.eyeStyle;
|
| 553 |
+
const color = state.eyeColor;
|
| 554 |
+
|
| 555 |
+
if (s.type === 'circle') {
|
| 556 |
+
eyeContent = `<circle cx="${s.cx}" cy="${s.cy}" r="${s.r}" fill="${color}" />
|
| 557 |
+
<circle cx="${s.cx2}" cy="${s.cy2}" r="${s.r2}" fill="${color}" />
|
| 558 |
+
<circle cx="${s.cx}" cy="${s.cy}" r="${s.r/2}" fill="#000" />
|
| 559 |
+
<circle cx="${s.cx2}" cy="${s.cy2}" r="${s.r2/2}" fill="#000" />`;
|
| 560 |
+
} else if (s.type === 'rect') {
|
| 561 |
+
eyeContent = `<rect x="${s.x}" y="${s.y}" width="${s.w}" height="${s.h}" fill="${color}" />
|
| 562 |
+
<rect x="${s.x2}" y="${s.y2}" width="${s.w2}" height="${s.h2}" fill="${color}" />`;
|
| 563 |
+
} else if (s.type === 'x') {
|
| 564 |
+
eyeContent = `<path d="${s.d}" stroke="${color}" stroke-width="4" stroke-linecap="round" />`;
|
| 565 |
+
} else if (s.type === 'line') {
|
| 566 |
+
eyeContent = `<path d="${s.d}" stroke="${color}" stroke-width="4" stroke-linecap="round" />`;
|
| 567 |
+
} else {
|
| 568 |
+
eyeContent = `<path d="${s.d}" fill="${color}" />`;
|
| 569 |
}
|
| 570 |
+
els.layerFace.innerHTML = eyeContent;
|
| 571 |
|
| 572 |
+
// Render Mouth
|
| 573 |
+
els.layerMouth.innerHTML = `<path d="${state.mouthStyle.path}" fill="none" stroke="${color}" stroke-width="3" stroke-linecap="round" />`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 574 |
|
| 575 |
+
// Render Accessory
|
| 576 |
+
if (state.accessory.id !== 'a0') {
|
| 577 |
+
els.layerAcc.innerHTML = `<path d="${state.accessory.path}" fill="${state.accessory.fill || 'none'}" stroke="${state.accessory.stroke || 'none'}" stroke-width="${state.accessory.strokeWidth || 0}" />`;
|
| 578 |
+
} else {
|
| 579 |
+
els.layerAcc.innerHTML = '';
|
| 580 |
}
|
| 581 |
|
| 582 |
+
// Render Overlay
|
| 583 |
+
if (state.overlayImage) {
|
| 584 |
+
els.layerOverlay.innerHTML = `<image href="${state.overlayImage}" x="50" y="50" width="100" height="100" transform="translate(-50, -50) scale(${state.overlayScale}) translate(100, 100)" opacity="${state.overlayOpacity}" />`;
|
| 585 |
+
} else {
|
| 586 |
+
els.layerOverlay.innerHTML = '';
|
| 587 |
}
|
| 588 |
+
}
|
| 589 |
|
| 590 |
+
// --- UI Builders ---
|
| 591 |
+
function buildOptions() {
|
| 592 |
+
// Bodies
|
| 593 |
+
const bContainer = document.getElementById('bodyShapes');
|
| 594 |
+
assets.bodies.forEach((b, i) => {
|
| 595 |
+
const div = document.createElement('div');
|
| 596 |
+
div.className = `option-item ${state.bodyShape.id === b.id ? 'selected' : ''}`;
|
| 597 |
+
div.innerHTML = `<svg viewBox="0 0 200 300"><path d="${b.path}" fill="#888" /></svg>`;
|
| 598 |
+
div.onclick = () => { state.bodyShape = b; updateUI(); };
|
| 599 |
+
bContainer.appendChild(div);
|
| 600 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 601 |
|
| 602 |
+
// Eyes
|
| 603 |
+
const eContainer = document.getElementById('eyeStyles');
|
| 604 |
+
assets.eyes.forEach((e, i) => {
|
| 605 |
+
const div = document.createElement('div');
|
| 606 |
+
div.className = `option-item ${state.eyeStyle.id === e.id ? 'selected' : ''}`;
|
| 607 |
+
// simplified preview for eyes
|
| 608 |
+
let preview = '';
|
| 609 |
+
if(e.type === 'circle') preview = `<circle cx="30" cy="30" r="10" fill="#fff"/> <circle cx="70" cy="30" r="10" fill="#fff"/>`;
|
| 610 |
+
else if(e.type === 'x') preview = `<path d="M20 20 L40 40 M40 20 L20 20 M60 20 L80 40 M80 20 L60 20" stroke="#fff"/>`;
|
| 611 |
+
else preview = `<rect x="20" y="20" width="20" height="20" fill="#fff"/> <rect x="60" y="20" width="20" height="20" fill="#fff"/>`;
|
| 612 |
|
| 613 |
+
div.innerHTML = `<svg viewBox="0 0 100 100">${preview}</svg>`;
|
| 614 |
+
div.onclick = () => { state.eyeStyle = e; updateUI(); };
|
| 615 |
+
eContainer.appendChild(div);
|
| 616 |
+
});
|
| 617 |
+
|
| 618 |
+
// Mouths
|
| 619 |
+
const mContainer = document.getElementById('mouthStyles');
|
| 620 |
+
assets.mouths.forEach((m, i) => {
|
| 621 |
+
const div = document.createElement('div');
|
| 622 |
+
div.className = `option-item ${state.mouthStyle.id === m.id ? 'selected' : ''}`;
|
| 623 |
+
div.innerHTML = `<svg viewBox="0 0 100 100"><path d="${m.path}" stroke="#fff" fill="none" transform="scale(0.5) translate(50,50)"/></svg>`;
|
| 624 |
+
div.onclick = () => { state.mouthStyle = m; updateUI(); };
|
| 625 |
+
mContainer.appendChild(div);
|
| 626 |
+
});
|
| 627 |
+
|
| 628 |
+
// Accessories
|
| 629 |
+
const aContainer = document.getElementById('accStyles');
|
| 630 |
+
assets.accessories.forEach((a, i) => {
|
| 631 |
+
const div = document.createElement('div');
|
| 632 |
+
div.className = `option-item ${state.accessory.id === a.id ? 'selected' : ''}`;
|
| 633 |
+
if (a.id === 'a0') {
|
| 634 |
+
div.innerHTML = `<span style="color:#fff; font-size:0.8rem">None</span>`;
|
| 635 |
+
} else {
|
| 636 |
+
div.innerHTML = `<svg viewBox="0 0 200 300"><path d="${a.path}" fill="${a.fill||'#fff'}" stroke="${a.stroke||'none'}" /></svg>`;
|
| 637 |
}
|
| 638 |
+
div.onclick = () => { state.accessory = a; updateUI(); };
|
| 639 |
+
aContainer.appendChild(div);
|
| 640 |
+
});
|
| 641 |
+
}
|
| 642 |
|
| 643 |
+
function updateUI() {
|
| 644 |
+
// Re-render options to show selection state
|
| 645 |
+
document.getElementById('bodyShapes').innerHTML = '';
|
| 646 |
+
document.getElementById('eyeStyles').innerHTML = '';
|
| 647 |
+
document.getElementById('mouthStyles').innerHTML = '';
|
| 648 |
+
document.getElementById('accStyles').innerHTML = '';
|
| 649 |
+
buildOptions();
|
| 650 |
+
render();
|
| 651 |
+
}
|
| 652 |
|
| 653 |
+
// --- Event Listeners ---
|
| 654 |
+
|
| 655 |
+
// Tab Switching
|
| 656 |
+
window.switchTab = (tabName) => {
|
| 657 |
+
document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
|
| 658 |
+
document.querySelectorAll('.control-panel').forEach(p => p.classList.remove('active'));
|
| 659 |
+
|
| 660 |
+
// Find button by text or index (simple approach)
|
| 661 |
+
const index = ['body','face','mouth','acc','upload'].indexOf(tabName);
|
| 662 |
+
document.querySelectorAll('.tab-btn')[index].classList.add('active');
|
| 663 |
+
|
| 664 |
+
document.getElementById(`panel-${tabName}`).classList.add('active');
|
| 665 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 666 |
|
| 667 |
+
// Color Inputs
|
| 668 |
+
els.bodyColor.addEventListener('input', (e) => { state.bodyColor = e.target.value; render(); });
|
| 669 |
+
els.eyeColor.addEventListener('input', (e) => { state.eyeColor = e.target.value; render(); });
|
| 670 |
+
|
| 671 |
+
// Overlay Sliders
|
| 672 |
+
els.overlayScale.addEventListener('input', (e) => { state.overlayScale = e.target.value; render(); });
|
| 673 |
+
els.overlayOpacity.addEventListener('input', (e) => { state.overlayOpacity = e.target.value; render(); });
|
| 674 |
+
|
| 675 |
+
// Theme Toggle
|
| 676 |
+
els.themeToggle.addEventListener('click', () => {
|
| 677 |
+
state.isHorror = !state.isHorror;
|
| 678 |
+
document.body.setAttribute('data-theme', state.isHorror ? 'horror' : 'normal');
|
| 679 |
+
els.themeToggle.innerText = state.isHorror ? '👻 Phase 9 Active' : '👻 Toggle Phase 9 Mode';
|
| 680 |
+
render(); // Re-render to apply stroke changes
|
| 681 |
+
});
|
| 682 |
+
|
| 683 |
+
// File Upload
|
| 684 |
+
els.fileInput.addEventListener('change', (e) => {
|
| 685 |
+
const file = e.target.files[0];
|
| 686 |
+
if (file) {
|
| 687 |
+
const reader = new FileReader();
|
| 688 |
+
reader.onload = (event) => {
|
| 689 |
+
state.overlayImage = event.target.result;
|
| 690 |
+
render();
|
| 691 |
+
showNotification('Image Uploaded!');
|
| 692 |
+
};
|
| 693 |
+
reader.readAsDataURL(file);
|
| 694 |
}
|
| 695 |
+
});
|
| 696 |
|
| 697 |
+
window.clearOverlay = () => {
|
| 698 |
+
state.overlayImage = null;
|
| 699 |
+
els.fileInput.value = '';
|
| 700 |
+
render();
|
| 701 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 702 |
|
| 703 |
+
window.randomize = () => {
|
| 704 |
+
state.bodyColor = '#' + Math.floor(Math.random()*16777215).toString(16);
|
| 705 |
+
state.bodyShape = assets.bodies[Math.floor(Math.random() * assets.bodies.length)];
|
| 706 |
+
state.eyeStyle = assets.eyes[Math.floor(Math.random() * assets.eyes.length)];
|
| 707 |
+
state.mouthStyle = assets.mouths[Math.floor(Math.random() * assets.mouths.length)];
|
| 708 |
+
state.accessory = assets.accessories[Math.floor(Math.random() * assets.accessories.length)];
|
| 709 |
+
|
| 710 |
+
// Sync inputs
|
| 711 |
+
els.bodyColor.value = state.bodyColor;
|
| 712 |
+
|
| 713 |
+
updateUI();
|
| 714 |
+
showNotification('Randomized!');
|
| 715 |
+
};
|
| 716 |
|
| 717 |
+
// Download Functionality
|
| 718 |
+
window.downloadCharacter = () => {
|
| 719 |
+
const svgData = new XMLSerializer().serializeToString(els.svg);
|
| 720 |
+
const canvas = document.createElement("canvas");
|
| 721 |
+
const ctx = canvas.getContext("2d");
|
| 722 |
+
const img = new Image();
|
| 723 |
+
|
| 724 |
+
// Set canvas size
|
| 725 |
+
canvas.width = 600;
|
| 726 |
+
canvas.height = 900;
|
| 727 |
+
|
| 728 |
+
// Background fill
|
| 729 |
+
ctx.fillStyle = state.isHorror ? "#1a0505" : "#1e1e1e";
|
| 730 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 731 |
+
|
| 732 |
+
const svgBlob = new Blob([svgData], {type: "image/svg+xml;charset=utf-8"});
|
| 733 |
+
const url = URL.createObjectURL(svgBlob);
|
| 734 |
+
|
| 735 |
+
img.onload = function() {
|
| 736 |
+
// Draw centered
|
| 737 |
+
ctx.drawImage(img, 150, 225, 300, 450);
|
| 738 |
+
URL.revokeObjectURL(url);
|
| 739 |
|
| 740 |
+
const link = document.createElement('a');
|
| 741 |
+
link.download = `sprunki-oc-${Date.now()}.png`;
|
| 742 |
+
link.href = canvas.toDataURL("image/png");
|
| 743 |
+
link.click();
|
| 744 |
+
showNotification('Character Saved!');
|
| 745 |
+
};
|
| 746 |
+
img.src = url;
|
| 747 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 748 |
|
| 749 |
+
function showNotification(msg) {
|
| 750 |
+
const notif = document.getElementById('notification');
|
| 751 |
+
notif.innerText = msg;
|
| 752 |
+
notif.classList.add('show');
|
| 753 |
+
setTimeout(() => notif.classList.remove('show'), 2000);
|
| 754 |
}
|
| 755 |
|
| 756 |
// --- Init ---
|
| 757 |
+
buildOptions();
|
| 758 |
+
render();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 759 |
|
| 760 |
</script>
|
| 761 |
</body>
|