<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Kirby 3D Dream Adventure - Super Mechagodzilla & Island Checkpoint Edition</title>
<!-- Three.js CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<style>
* {
box-sizing: border-box;
user-select: none;
-webkit-user-select: none;
margin: 0;
padding: 0;
}
body, html {
width: 100%;
height: 100%;
overflow: hidden;
background: #0f172a;
font-family: 'Inter', 'Hiragino Maru Gothic ProN', 'Meiryo', sans-serif;
}
#canvas-container {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
#hud {
position: absolute;
top: 12px;
left: 12px;
right: 12px;
display: flex;
justify-content: space-between;
align-items: flex-start;
pointer-events: none;
z-index: 20;
flex-wrap: wrap;
gap: 8px;
}
.hud-card {
background: rgba(255, 255, 255, 0.94);
backdrop-filter: blur(10px);
border: 3px solid #ff7fa4;
border-radius: 20px;
padding: 8px 14px;
box-shadow: 0 8px 22px rgba(255, 105, 180, 0.35);
display: flex;
align-items: center;
gap: 10px;
font-weight: bold;
color: #d12e66;
}
.hp-container {
display: flex;
flex-direction: column;
gap: 3px;
}
.hp-bar-bg {
width: 110px;
height: 14px;
background: #ffe3eb;
border-radius: 10px;
overflow: hidden;
border: 2px solid #ff7fa4;
}
.hp-bar-fill {
width: 100%;
height: 100%;
background: linear-gradient(90deg, #ff4071, #ff9f43);
border-radius: 8px;
transition: width 0.2s ease;
}
.badge-icon {
font-size: 22px;
}
.score-val {
font-size: 18px;
color: #d12e66;
min-width: 45px;
}
.island-tracker {
display: flex;
flex-direction: column;
gap: 2px;
font-size: 11px;
color: #475569;
}
.island-val {
font-size: 15px;
font-weight: 900;
color: #0284c7;
}
.island-val.ready {
color: #16a34a;
animation: pulseText 1s infinite alternate;
}
@keyframes pulseText {
0% { transform: scale(1); }
100% { transform: scale(1.08); }
}
.ability-box {
display: flex;
align-items: center;
gap: 8px;
background: #fff0f5;
padding: 4px 10px;
border-radius: 14px;
border: 2px solid #ff85a2;
}
.ability-icon {
font-size: 20px;
}
.ability-name {
font-size: 13px;
color: #b3164a;
font-weight: 900;
}
.btn-drop-ability {
pointer-events: auto;
background: #ff5c8a;
color: #fff;
border: none;
padding: 3px 8px;
border-radius: 10px;
font-size: 11px;
cursor: pointer;
transition: 0.1s;
}
.btn-drop-ability:hover {
background: #d82b5c;
}
.stage-badge {
background: #ff5c8a;
color: #fff;
padding: 4px 10px;
border-radius: 12px;
font-size: 12px;
font-weight: bold;
display: inline-block;
}
.diff-tag {
background: #ef4444;
color: #fff;
padding: 2px 7px;
border-radius: 8px;
font-size: 10px;
font-weight: 900;
margin-left: 4px;
}
.btn-stage-select {
pointer-events: auto;
background: linear-gradient(135deg, #ffd166, #f78c6c);
border: 2px solid #fff;
color: #7a2700;
font-weight: 800;
font-size: 11px;
padding: 5px 12px;
border-radius: 20px;
cursor: pointer;
box-shadow: 0 4px 10px rgba(247, 140, 108, 0.35);
transition: transform 0.15s ease;
}
.btn-stage-select:hover {
transform: scale(1.05);
}
#boss-hud {
position: absolute;
bottom: 22px;
left: 50%;
transform: translateX(-50%);
width: min(90%, 460px);
background: rgba(15, 23, 42, 0.92);
border: 3px solid #ef4444;
box-shadow: 0 8px 30px rgba(239, 68, 68, 0.45);
border-radius: 20px;
padding: 10px 18px;
z-index: 25;
display: none;
flex-direction: column;
gap: 6px;
pointer-events: none;
}
.boss-header {
display: flex;
justify-content: space-between;
align-items: center;
color: #f87171;
font-weight: 900;
font-size: 13px;
letter-spacing: 1px;
}
.boss-hp-bg {
width: 100%;
height: 16px;
background: #334155;
border-radius: 10px;
overflow: hidden;
border: 2px solid #f87171;
}
.boss-hp-fill {
width: 100%;
height: 100%;
background: linear-gradient(90deg, #dc2626, #f59e0b);
border-radius: 8px;
transition: width 0.15s ease;
}
#cinematic-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 150;
display: none;
flex-direction: column;
justify-content: space-between;
overflow: hidden;
}
#cinematic-overlay.active {
display: flex;
}
.letterbox-bar {
width: 100%;
height: 14%;
background: #000;
position: relative;
z-index: 10;
}
.scanlines {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 255, 234, 0.08) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
background-size: 100% 4px, 6px 100%;
pointer-events: none;
z-index: 2;
}
.cinematic-hud {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
width: 90%;
z-index: 5;
}
.warning-tag {
font-size: 14px;
letter-spacing: 4px;
color: #38bdf8;
text-shadow: 0 0 12px #0284c7;
font-weight: 900;
margin-bottom: 8px;
animation: blinkAlert 0.25s infinite alternate;
}
@keyframes blinkAlert {
0% { opacity: 0.3; }
100% { opacity: 1; }
}
.super-title {
font-size: 32px;
font-weight: 900;
background: linear-gradient(135deg, #ffffff, #93c5fd, #38bdf8, #f59e0b);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 0 0 35px rgba(56, 189, 248, 0.85);
letter-spacing: 4px;
transform: scale(0.7);
opacity: 0;
transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.super-title.broly-theme {
background: linear-gradient(135deg, #ffffff, #86efac, #22c55e, #15803d);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 0 0 40px rgba(34, 197, 94, 0.95);
}
.super-title.magolor-theme {
background: linear-gradient(135deg, #ffffff, #f0abfc, #a855f7, #fbbf24);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 0 0 45px rgba(168, 85, 247, 0.95);
}
.super-title.tyranno-theme {
background: linear-gradient(135deg, #ffffff, #fca5a5, #ef4444, #b91c1c, #d97706);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 0 0 45px rgba(239, 68, 68, 0.95);
}
.super-title.show {
transform: scale(1.05);
opacity: 1;
}
.system-specs {
color: #94a3b8;
font-size: 12px;
letter-spacing: 2px;
font-family: monospace;
margin-top: 10px;
}
#mission-toast {
position: absolute;
top: 86px;
left: 50%;
transform: translateX(-50%);
background: rgba(15, 23, 42, 0.9);
border: 2px solid #38bdf8;
color: #f0f9ff;
padding: 7px 18px;
border-radius: 30px;
font-size: 13px;
font-weight: bold;
z-index: 30;
pointer-events: none;
opacity: 0;
transition: opacity 0.3s ease, transform 0.3s ease;
box-shadow: 0 6px 20px rgba(0,0,0,0.4);
white-space: nowrap;
}
#mission-toast.show {
opacity: 1;
transform: translateX(-50%) translateY(4px);
}
#message-banner {
position: absolute;
top: 45%;
left: 50%;
transform: translate(-50%, -50%) scale(0.9);
background: rgba(255, 255, 255, 0.98);
border: 4px solid #ff5c8a;
box-shadow: 0 16px 40px rgba(255, 64, 129, 0.45);
border-radius: 28px;
padding: 26px 40px;
text-align: center;
color: #d12e66;
z-index: 60;
display: none;
opacity: 0;
transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
pointer-events: auto;
}
#message-banner.show {
display: block;
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
#message-banner h2 {
font-size: 26px;
margin-bottom: 8px;
}
#message-banner p {
font-size: 15px;
color: #555;
margin-bottom: 20px;
}
.banner-buttons {
display: flex;
gap: 12px;
justify-content: center;
flex-wrap: wrap;
}
.btn-restart, .btn-next {
font-size: 15px;
font-weight: bold;
padding: 10px 24px;
border: none;
border-radius: 50px;
cursor: pointer;
transition: transform 0.15s ease;
color: white;
}
.btn-restart {
background: linear-gradient(135deg, #ff6b8b, #ff4071);
box-shadow: 0 6px 16px rgba(255, 64, 113, 0.4);
}
.btn-next {
background: linear-gradient(135deg, #48c74c, #10ac84);
box-shadow: 0 6px 16px rgba(16, 172, 132, 0.4);
}
#stage-modal {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(15, 23, 42, 0.7);
backdrop-filter: blur(8px);
z-index: 100;
display: none;
align-items: center;
justify-content: center;
padding: 16px;
}
#stage-modal.open {
display: flex;
}
.modal-content {
background: #ffffff;
border: 4px solid #ff7fa4;
border-radius: 28px;
padding: 24px;
max-width: 700px;
width: 100%;
max-height: 85vh;
overflow-y: auto;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
text-align: center;
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.modal-title {
color: #d12e66;
font-size: 20px;
font-weight: 900;
}
.btn-close-modal {
background: #f1f2f6;
border: none;
width: 36px;
height: 36px;
border-radius: 50%;
font-size: 18px;
font-weight: bold;
color: #666;
cursor: pointer;
}
.stage-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
gap: 10px;
margin-bottom: 16px;
}
.stage-tile {
background: #fff5f8;
border: 2px solid #ff9ebb;
border-radius: 14px;
padding: 10px 6px;
cursor: pointer;
transition: all 0.15s ease;
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
}
.stage-tile:hover {
transform: translateY(-3px);
border-color: #ff4071;
background: #ffe3eb;
}
.stage-tile.active {
background: #ff5c8a;
border-color: #d12e66;
color: #fff;
}
.stage-num {
font-size: 13px;
font-weight: 900;
}
.stage-world-tag {
font-size: 10px;
opacity: 0.85;
}
#guide {
position: absolute;
bottom: 16px;
left: 50%;
transform: translateX(-50%);
background: rgba(15, 23, 42, 0.85);
backdrop-filter: blur(8px);
border: 2px solid #ff7fa4;
color: #fff;
padding: 8px 18px;
border-radius: 30px;
font-size: 12px;
pointer-events: none;
display: flex;
align-items: center;
gap: 12px;
z-index: 10;
white-space: nowrap;
box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.chasm-alert {
background: linear-gradient(135deg, #ef4444, #dc2626);
color: #fff;
padding: 2px 8px;
border-radius: 8px;
font-weight: 900;
font-size: 11px;
display: inline-flex;
align-items: center;
gap: 4px;
}
.key-tag {
background: #fff;
color: #ff4071;
padding: 1px 6px;
border-radius: 6px;
font-weight: 800;
font-size: 11px;
margin-right: 3px;
}
#mobile-controls {
display: none;
position: absolute;
bottom: 16px;
left: 0;
right: 0;
width: 100%;
height: 160px;
pointer-events: none;
z-index: 25;
}
@media (max-width: 900px), (pointer: coarse) {
#mobile-controls {
display: block;
}
#guide {
display: none;
}
}
.touch-btn {
position: absolute;
width: 66px;
height: 66px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.92);
border: 3px solid #ff6b8b;
box-shadow: 0 6px 14px rgba(255, 80, 120, 0.35);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
pointer-events: auto;
color: #d12e66;
font-weight: bold;
font-size: 11px;
touch-action: manipulation;
}
.touch-btn:active {
transform: scale(0.92);
background: #ffecf2;
}
#btn-jump { bottom: 16px; right: 18px; }
#btn-action { bottom: 92px; right: 28px; }
#btn-ability-atk { bottom: 32px; right: 94px; background: #fff2cc; border-color: #f59e0b; color: #b45309; }
#btn-teleport { bottom: 96px; right: 98px; display: none; background: #dbeafe; border-color: #3b82f6; color: #1d4ed8; }
#dpad-zone {
position: absolute;
bottom: 16px;
left: 16px;
width: 124px;
height: 124px;
background: rgba(255, 255, 255, 0.55);
border-radius: 50%;
border: 2px dashed rgba(255, 105, 180, 0.5);
pointer-events: auto;
}
#dpad-knob {
position: absolute;
top: 37px;
left: 37px;
width: 50px;
height: 50px;
background: #ff5c8a;
border-radius: 50%;
box-shadow: 0 4px 10px rgba(255, 92, 138, 0.5);
pointer-events: none;
}
</style>
</head>
<body>
<div id="canvas-container"></div>
<div id="hud">
<div class="hud-card">
<span class="badge-icon">🍅</span>
<div class="hp-container">
<div style="font-size: 10px; font-weight: 800;">KIRBY LIFE</div>
<div class="hp-bar-bg">
<div id="hp-bar" class="hp-bar-fill"></div>
</div>
</div>
<div class="ability-box">
<span id="ability-icon" class="ability-icon">✨</span>
<span id="ability-name" class="ability-name">ノーマル</span>
<button id="btn-drop-ability" class="btn-drop-ability" style="display:none;" title="能力をすてる">すてる</button>
</div>
</div>
<div class="hud-card" style="gap: 8px;">
<div style="display: flex; flex-direction: column; gap: 3px; align-items: flex-start;">
<div style="display:flex; align-items:center;">
<div id="stage-title-text" class="stage-badge">STAGE 1: 試練の突風草原</div>
<span id="stage-diff-tag" class="diff-tag">HARD</span>
</div>
<button id="btn-open-stages" class="btn-stage-select">ステージ選択 (全20)</button>
</div>
</div>
<!-- Island Checkpoint Progression Card -->
<div class="hud-card">
<span class="badge-icon">🏝️</span>
<div class="island-tracker">
<div>全島着陸 踏破状況</div>
<div id="island-count-text" class="island-val">1 / 8 島</div>
</div>
</div>
<div class="hud-card">
<span class="badge-icon">⭐</span>
<span id="score-text" class="score-val">0</span>
</div>
</div>
<!-- Mission notification banner -->
<div id="mission-toast">🚩 島をチェックしました!</div>
<!-- Boss HP HUD -->
<div id="boss-hud">
<div class="boss-header">
<span id="boss-name-label">👑 巨獣大王 ギガ・ハンマー</span>
<span id="boss-hp-pct">100%</span>
</div>
<div class="boss-hp-bg">
<div id="boss-hp-fill" class="boss-hp-fill"></div>
</div>
</div>
<!-- Super Copy Ability Cinematic Cutscene Overlay -->
<div id="cinematic-overlay">
<div class="letterbox-bar"></div>
<div class="scanlines"></div>
<div class="cinematic-hud">
<div id="cine-warning" class="warning-tag">⚠ SUPER COPY ABILITY DETECTED ⚠</div>
<div id="cine-title" class="super-title">⚡ SUPER MECHAGODZILLA ⚡</div>
<div id="cine-specs" class="system-specs">SYSTEM: NT-1 GARUDA MERGE // ALL WEAPONS ONLINE</div>
</div>
<div class="letterbox-bar"></div>
</div>
<div id="guide">
<span class="chasm-alert">🏝️ 全ての島に着陸&ボス撃破でゴール出現!</span>
<span><span class="key-tag">SPACE / JUMP</span>連打で浮遊</span>
<span><span class="key-tag">WASD</span>移動</span>
<span><span class="key-tag">Z / J</span>すいこみ</span>
<span><span class="key-tag">X / K</span>技攻撃</span>
</div>
<div id="mobile-controls">
<div id="dpad-zone"><div id="dpad-knob"></div></div>
<div id="btn-jump" class="touch-btn"><span>JUMP</span><span>浮遊/上昇</span></div>
<div id="btn-action" class="touch-btn"><span id="m-action-top">すいこみ</span><span id="m-action-sub">はきだし</span></div>
<div id="btn-ability-atk" class="touch-btn" style="display:none;"><span>技攻撃</span><span>ATTACK</span></div>
<div id="btn-teleport" class="touch-btn"><span>瞬間移動</span><span>WARP</span></div>
</div>
<div id="message-banner">
<h2 id="banner-title">ステージクリア!⭐</h2>
<p id="banner-desc">全島を踏破し、大ボスを撃破してゴールしました!</p>
<div class="banner-buttons">
<button class="btn-restart" id="btn-reset">もういちど</button>
<button class="btn-next" id="btn-next-stage">次のステージへ ➔</button>
</div>
</div>
<!-- Stage Select Modal -->
<div id="stage-modal">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">🌟 ステージをえらぶ (1〜20 難関モード)</h3>
<button class="btn-close-modal" id="btn-close-modal">✕</button>
</div>
<div id="stage-grid" class="stage-grid"></div>
</div>
</div>
<script>
const SoundController = {
ctx: null,
init() {
if (!this.ctx) {
const AudioCtx = window.AudioContext || window.webkitAudioContext;
if (AudioCtx) this.ctx = new AudioCtx();
}
if (this.ctx && this.ctx.state === 'suspended') {
this.ctx.resume();
}
},
playTone(freq, type, duration, startVol = 0.25, endVol = 0.0) {
this.init();
if (!this.ctx) return;
try {
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = type;
osc.frequency.setValueAtTime(freq, this.ctx.currentTime);
gain.gain.setValueAtTime(startVol, this.ctx.currentTime);
gain.gain.exponentialRampToValueAtTime(Math.max(endVol, 0.0001), this.ctx.currentTime + duration);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start();
osc.stop(this.ctx.currentTime + duration);
} catch (e) {}
},
checkpointChime() {
this.init();
if (!this.ctx) return;
const notes = [587, 880, 1174, 1479];
notes.forEach((f, idx) => {
setTimeout(() => this.playTone(f, 'sine', 0.25, 0.2, 0.001), idx * 60);
});
},
allIslandsUnlocked() {
this.init();
if (!this.ctx) return;
const notes = [523, 659, 783, 1046, 1318, 1567, 2093];
notes.forEach((f, idx) => {
setTimeout(() => this.playTone(f, 'triangle', 0.35, 0.3, 0.001), idx * 75);
});
},
bossRoar() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(90, now);
osc.frequency.exponentialRampToValueAtTime(260, now + 0.2);
osc.frequency.exponentialRampToValueAtTime(55, now + 0.6);
gain.gain.setValueAtTime(0.45, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.65);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.65);
},
bossSlam() {
this.init();
this.playTone(60, 'square', 0.45, 0.5, 0.01);
},
mechTransform() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
[180, 240, 360, 520].forEach((f, i) => {
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'square';
osc.frequency.setValueAtTime(f, now + i * 0.12);
osc.frequency.linearRampToValueAtTime(f * 1.5, now + i * 0.12 + 0.1);
gain.gain.setValueAtTime(0.3, now + i * 0.12);
gain.gain.exponentialRampToValueAtTime(0.01, now + i * 0.12 + 0.15);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now + i * 0.12);
osc.stop(now + i * 0.12 + 0.15);
});
},
megaBusterBeam() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(900, now);
osc.frequency.exponentialRampToValueAtTime(120, now + 0.7);
gain.gain.setValueAtTime(0.45, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.75);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.75);
},
plasmaGrenade() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
[300, 600, 900, 1200].forEach((freq, idx) => {
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(freq, now + idx * 0.05);
osc.frequency.exponentialRampToValueAtTime(80, now + idx * 0.05 + 0.35);
gain.gain.setValueAtTime(0.35, now + idx * 0.05);
gain.gain.exponentialRampToValueAtTime(0.01, now + idx * 0.05 + 0.4);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now + idx * 0.05);
osc.stop(now + idx * 0.05 + 0.4);
});
},
superFanfare() {
this.init();
if (!this.ctx) return;
const notes = [440, 554, 659, 880, 1108, 1318, 1760];
notes.forEach((f, idx) => {
setTimeout(() => this.playTone(f, 'sawtooth', 0.28, 0.35, 0.01), idx * 70);
});
},
brolyRoar() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(80, now);
osc.frequency.exponentialRampToValueAtTime(580, now + 0.35);
osc.frequency.exponentialRampToValueAtTime(65, now + 0.9);
gain.gain.setValueAtTime(0.48, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.95);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.95);
},
giganticMeteorCharge() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'triangle';
osc.frequency.setValueAtTime(140, now);
osc.frequency.exponentialRampToValueAtTime(980, now + 0.5);
gain.gain.setValueAtTime(0.35, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.55);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.55);
},
kiExplosion() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'square';
osc.frequency.setValueAtTime(180, now);
osc.frequency.exponentialRampToValueAtTime(30, now + 0.6);
gain.gain.setValueAtTime(0.5, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.65);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.65);
},
magolorMagicChime() {
this.init();
if (!this.ctx) return;
const notes = [587, 740, 880, 1174, 1480, 1760];
notes.forEach((f, idx) => {
setTimeout(() => this.playTone(f, 'sine', 0.35, 0.28, 0.001), idx * 65);
});
},
dimensionalRift() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(950, now);
osc.frequency.exponentialRampToValueAtTime(70, now + 0.55);
gain.gain.setValueAtTime(0.4, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.6);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.6);
},
magolorLaser() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
[1100, 1400, 1700].forEach((f, idx) => {
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'triangle';
osc.frequency.setValueAtTime(f, now + idx * 0.04);
osc.frequency.exponentialRampToValueAtTime(220, now + idx * 0.04 + 0.28);
gain.gain.setValueAtTime(0.25, now + idx * 0.04);
gain.gain.exponentialRampToValueAtTime(0.001, now + idx * 0.04 + 0.3);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now + idx * 0.04);
osc.stop(now + idx * 0.04 + 0.3);
});
},
tyrannoRoar() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(65, now);
osc.frequency.exponentialRampToValueAtTime(460, now + 0.3);
osc.frequency.exponentialRampToValueAtTime(45, now + 0.95);
gain.gain.setValueAtTime(0.52, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 1.0);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 1.0);
},
tyrannoStomp() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'square';
osc.frequency.setValueAtTime(140, now);
osc.frequency.exponentialRampToValueAtTime(30, now + 0.45);
gain.gain.setValueAtTime(0.55, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.5);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.5);
},
tyrannoBite() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
[180, 90].forEach((f, i) => {
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(f, now + i * 0.05);
gain.gain.setValueAtTime(0.4, now + i * 0.05);
gain.gain.exponentialRampToValueAtTime(0.01, now + i * 0.05 + 0.22);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now + i * 0.05);
osc.stop(now + i * 0.05 + 0.22);
});
},
spikeHit() { this.init(); this.playTone(85, 'sawtooth', 0.28, 0.45, 0.01); },
turretFire() { this.init(); this.playTone(320, 'square', 0.1, 0.2, 0.01); },
jetEngine() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(120, now);
osc.frequency.exponentialRampToValueAtTime(540, now + 0.18);
gain.gain.setValueAtTime(0.28, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.25);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.25);
},
missileLaunch() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
[780, 520, 260].forEach((f, i) => {
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'triangle';
osc.frequency.setValueAtTime(f, now + i * 0.04);
osc.frequency.linearRampToValueAtTime(180, now + 0.25);
gain.gain.setValueAtTime(0.25, now + i * 0.04);
gain.gain.exponentialRampToValueAtTime(0.001, now + 0.3);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now + i * 0.04);
osc.stop(now + 0.3);
});
},
jump() { this.init(); this.playTone(420, 'sine', 0.15, 0.2, 0.01); },
hover() { this.init(); this.playTone(720, 'triangle', 0.1, 0.15, 0.01); },
helicopterRotor() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'square';
osc.frequency.setValueAtTime(55, now);
osc.frequency.exponentialRampToValueAtTime(80, now + 0.06);
gain.gain.setValueAtTime(0.22, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.09);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.09);
},
gatlingFire() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
[420, 280].forEach((f, i) => {
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(f, now + i * 0.02);
gain.gain.setValueAtTime(0.2, now + i * 0.02);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.07);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now + i * 0.02);
osc.stop(now + 0.07);
});
},
inhale() { this.init(); this.playTone(160, 'sawtooth', 0.06, 0.04, 0.01); },
swallow() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
[440, 554, 659, 880].forEach((f, i) => {
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sine';
osc.frequency.setValueAtTime(f, now + i * 0.05);
gain.gain.setValueAtTime(0.22, now + i * 0.05);
gain.gain.exponentialRampToValueAtTime(0.001, now + i * 0.05 + 0.2);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now + i * 0.05);
osc.stop(now + i * 0.05 + 0.2);
});
},
copyFanfare() {
this.init();
if (!this.ctx) return;
const notes = [523, 659, 783, 1046, 1318];
notes.forEach((f, idx) => {
setTimeout(() => this.playTone(f, 'triangle', 0.22, 0.28, 0.01), idx * 80);
});
},
swordSlash() { this.init(); this.playTone(520, 'triangle', 0.12, 0.3, 0.01); },
fireBreath() { this.init(); this.playTone(220, 'sawtooth', 0.15, 0.25, 0.01); },
cutterThrow() { this.init(); this.playTone(850, 'sine', 0.14, 0.25, 0.01); },
pteraRoar() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(680, now);
osc.frequency.exponentialRampToValueAtTime(1450, now + 0.12);
osc.frequency.exponentialRampToValueAtTime(420, now + 0.35);
gain.gain.setValueAtTime(0.3, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.4);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.4);
},
pteraFlap() { this.init(); this.playTone(180, 'sine', 0.12, 0.25, 0.01); },
tornadoGust() {
this.init();
this.playTone(400, 'triangle', 0.3, 0.25, 0.01);
},
diveImpact() { this.init(); this.playTone(90, 'square', 0.25, 0.4, 0.01); },
mosasaurRoar() {
this.init();
if (!this.ctx) return;
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(110, now);
osc.frequency.exponentialRampToValueAtTime(320, now + 0.15);
gain.gain.setValueAtTime(0.35, now);
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.48);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.48);
},
waterSurge() { this.init(); this.playTone(360, 'sine', 0.25, 0.25, 0.01); },
chompBite() { this.init(); this.playTone(160, 'square', 0.12, 0.45, 0.01); },
superSaiyanRoar() { this.init(); this.playTone(320, 'sawtooth', 0.4, 0.35, 0.01); },
kamehameha() { this.init(); this.playTone(440, 'sawtooth', 0.5, 0.3, 0.01); },
instantTransmission() { this.init(); this.playTone(1800, 'sine', 0.1, 0.35, 0.01); },
spit() { this.init(); this.playTone(600, 'sine', 0.15, 0.25, 0.01); },
starCollect() { this.init(); this.playTone(1174, 'sine', 0.18, 0.25, 0.01); },
hit() { this.init(); this.playTone(110, 'square', 0.2, 0.35, 0.01); },
win() {
this.init();
const fanfares = [523, 659, 783, 1046, 1318];
fanfares.forEach((f, i) => {
setTimeout(() => this.playTone(f, 'triangle', 0.3, 0.25, 0.01), i * 110);
});
}
};
let scene, camera, renderer;
let dirLight, ambientLight, lightTarget;
const container = document.getElementById('canvas-container');
function initScene() {
scene = new THREE.Scene();
scene.background = new THREE.Color(0x38bdf8);
camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1500);
camera.position.set(0, 7.5, 13.5);
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false, powerPreference: 'high-performance' });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setClearColor(0x38bdf8, 1.0);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
container.innerHTML = '';
container.appendChild(renderer.domElement);
ambientLight = new THREE.AmbientLight(0xffffff, 0.95);
scene.add(ambientLight);
lightTarget = new THREE.Object3D();
scene.add(lightTarget);
dirLight = new THREE.DirectionalLight(0xffffff, 1.1);
dirLight.position.set(20, 45, 25);
dirLight.target = lightTarget;
dirLight.castShadow = true;
dirLight.shadow.mapSize.width = 1024;
dirLight.shadow.mapSize.height = 1024;
dirLight.shadow.camera.near = 5;
dirLight.shadow.camera.far = 200;
dirLight.shadow.camera.left = -50;
dirLight.shadow.camera.right = 50;
dirLight.shadow.camera.top = 50;
dirLight.shadow.camera.bottom = -50;
scene.add(dirLight);
}
let kirby;
let kirbyBodyMesh, leftArm, rightArm, leftFoot, rightFoot, mouthMesh;
let swordGroup, fireHatGroup, cutterHatGroup, dbGokuGroup, kiAuraParticles;
let pteranodonGroup, pteraLeftWing, pteraRightWing;
let fighterJetGroup, jetAfterburners = [];
let helicopterGroup, heliMainRotor, heliTailRotor, heliGatlingLeft, heliGatlingRight;
let mosasaurusGroup, mosaFlipperLeft, mosaFlipperRight, mosaTail;
let superMechagodzillaGroup, mechaGarudaBackpack, mechaPlasmaCannons = [], mechaSpines = [], mechaThrusters = [];
let brolyGroup, brolyAuraParticles, brolyTorcMesh;
let magolorGroup, magolorHands = [], magolorAuraParticles, magolorCrownMesh;
let tyrannoGroup, tyrannoUpperJaw, tyrannoLowerJaw, tyrannoTail, tyrannoEmberParticles;
let isCinematicPlaying = false;
let cinematicTime = 0;
let cinematicTargetPos = new THREE.Vector3();
let activeCinematicAbility = 'mechagodzilla';
function createKirbyModel() {
const group = new THREE.Group();
const bodyGeo = new THREE.SphereGeometry(1.0, 32, 32);
const bodyMat = new THREE.MeshToonMaterial({ color: 0xff7aa8, shininess: 25 });
kirbyBodyMesh = new THREE.Mesh(bodyGeo, bodyMat);
kirbyBodyMesh.castShadow = true;
kirbyBodyMesh.receiveShadow = true;
group.add(kirbyBodyMesh);
// Eyes
const eyeGeo = new THREE.CylinderGeometry(0.12, 0.12, 0.03, 16);
eyeGeo.rotateX(Math.PI / 2);
eyeGeo.scale(0.75, 1.8, 1.0);
const eyeMat = new THREE.MeshBasicMaterial({ color: 0x0f1c3f });
const pupilGeo = new THREE.CylinderGeometry(0.065, 0.065, 0.04, 16);
pupilGeo.rotateX(Math.PI / 2);
pupilGeo.scale(0.75, 1.4, 1.0);
const pupilMat = new THREE.MeshBasicMaterial({ color: 0x1d63d8 });
const highlightGeo = new THREE.SphereGeometry(0.045, 12, 12);
const highlightMat = new THREE.MeshBasicMaterial({ color: 0xffffff });
function createSingleEye(xPos) {
const eyeGroup = new THREE.Group();
const base = new THREE.Mesh(eyeGeo, eyeMat);
const pupil = new THREE.Mesh(pupilGeo, pupilMat);
pupil.position.set(0, -0.04, 0.01);
const shine = new THREE.Mesh(highlightGeo, highlightMat);
shine.position.set(0.02, 0.07, 0.02);
eyeGroup.add(base, pupil, shine);
eyeGroup.position.set(xPos, 0.22, 0.94);
eyeGroup.rotation.y = xPos * 0.15;
return eyeGroup;
}
group.add(createSingleEye(-0.24), createSingleEye(0.24));
// Cheeks & Mouth
const cheekGeo = new THREE.SphereGeometry(0.15, 16, 16);
cheekGeo.scale(1.4, 0.6, 0.3);
const cheekMat = new THREE.MeshBasicMaterial({ color: 0xff3b75 });
const cheekL = new THREE.Mesh(cheekGeo, cheekMat);
cheekL.position.set(-0.48, -0.05, 0.86);
const cheekR = cheekL.clone();
cheekR.position.x = 0.48;
group.add(cheekL, cheekR);
const mouthGeo = new THREE.SphereGeometry(0.15, 16, 16);
const mouthMat = new THREE.MeshBasicMaterial({ color: 0x8b0028 });
mouthMesh = new THREE.Mesh(mouthGeo, mouthMat);
mouthMesh.scale.set(0.9, 0.5, 0.3);
mouthMesh.position.set(0, -0.15, 0.96);
group.add(mouthMesh);
// Arms & Feet
const armGeo = new THREE.SphereGeometry(0.38, 16, 16);
armGeo.scale(1.4, 0.9, 0.9);
leftArm = new THREE.Mesh(armGeo, bodyMat);
leftArm.position.set(-0.95, 0.1, 0);
leftArm.rotation.z = 0.4;
rightArm = leftArm.clone();
rightArm.position.x = 0.95;
rightArm.rotation.z = -0.4;
group.add(leftArm, rightArm);
const footGeo = new THREE.SphereGeometry(0.48, 16, 16);
footGeo.scale(1.0, 0.6, 1.5);
const footMat = new THREE.MeshToonMaterial({ color: 0xd90429 });
leftFoot = new THREE.Mesh(footGeo, footMat);
leftFoot.position.set(-0.48, -0.75, 0.15);
leftFoot.castShadow = true;
rightFoot = leftFoot.clone();
rightFoot.position.x = 0.48;
group.add(leftFoot, rightFoot);
// Sword Ability
swordGroup = new THREE.Group();
const swordHat = new THREE.Mesh(new THREE.ConeGeometry(0.65, 1.5, 16), new THREE.MeshToonMaterial({ color: 0x22c55e }));
swordHat.position.set(0, 1.25, -0.3);
swordHat.rotation.x = -0.55;
const rim = new THREE.Mesh(new THREE.TorusGeometry(0.68, 0.12, 8, 24), new THREE.MeshToonMaterial({ color: 0xfacc15 }));
rim.position.set(0, 0.85, 0.05);
rim.rotation.x = Math.PI / 3;
const blade = new THREE.Mesh(new THREE.BoxGeometry(0.12, 1.4, 0.28), new THREE.MeshToonMaterial({ color: 0xe2e8f0, metalness: 0.8 }));
blade.position.set(1.15, 0.4, 0.35);
blade.rotation.z = -0.3;
swordGroup.add(swordHat, rim, blade);
swordGroup.visible = false;
group.add(swordGroup);
// Fire Ability
fireHatGroup = new THREE.Group();
const fireCrown = new THREE.Mesh(new THREE.ConeGeometry(0.7, 1.3, 8), new THREE.MeshToonMaterial({ color: 0xef4444, emissive: 0xff3300, emissiveIntensity: 0.5 }));
fireCrown.position.set(0, 1.35, 0);
const fireDeco = new THREE.Mesh(new THREE.TorusGeometry(0.72, 0.1, 8, 16), new THREE.MeshBasicMaterial({ color: 0xffd000 }));
fireDeco.position.set(0, 0.85, 0);
fireDeco.rotation.x = Math.PI / 2;
fireHatGroup.add(fireCrown, fireDeco);
fireHatGroup.visible = false;
group.add(fireHatGroup);
// Cutter Ability
cutterHatGroup = new THREE.Group();
const cutterHat = new THREE.Mesh(new THREE.SphereGeometry(0.72, 16, 16), new THREE.MeshToonMaterial({ color: 0xfacc15 }));
cutterHat.position.set(0, 0.85, 0);
cutterHat.scale.set(1.05, 0.8, 1.05);
const cutterBlade = new THREE.Mesh(new THREE.BoxGeometry(0.1, 1.2, 0.5), new THREE.MeshToonMaterial({ color: 0xffffff }));
cutterBlade.position.set(0, 1.45, 0);
cutterBlade.rotation.x = -0.4;
cutterHatGroup.add(cutterHat, cutterBlade);
cutterHatGroup.visible = false;
group.add(cutterHatGroup);
// Helicopter
helicopterGroup = new THREE.Group();
const heliHelmetMat = new THREE.MeshToonMaterial({ color: 0x2d4a22, shininess: 30 });
const heliVisorMat = new THREE.MeshToonMaterial({ color: 0xf59e0b, transparent: true, opacity: 0.85 });
const heliHelmet = new THREE.Mesh(new THREE.SphereGeometry(0.74, 16, 16), heliHelmetMat);
heliHelmet.position.set(0, 0.85, 0);
heliHelmet.scale.set(1.05, 0.85, 1.15);
const heliVisor = new THREE.Mesh(new THREE.BoxGeometry(0.72, 0.24, 0.28), heliVisorMat);
heliVisor.position.set(0, 0.86, 0.68);
helicopterGroup.add(heliHelmet, heliVisor);
const mast = new THREE.Mesh(new THREE.CylinderGeometry(0.08, 0.08, 0.5, 8), new THREE.MeshToonMaterial({ color: 0x1f2937 }));
mast.position.set(0, 1.5, 0);
helicopterGroup.add(mast);
heliMainRotor = new THREE.Group();
heliMainRotor.position.set(0, 1.75, 0);
const rotorBladeGeo = new THREE.BoxGeometry(3.2, 0.04, 0.22);
const rotorBladeMat = new THREE.MeshToonMaterial({ color: 0x111827 });
const blade1 = new THREE.Mesh(rotorBladeGeo, rotorBladeMat);
const blade2 = new THREE.Mesh(rotorBladeGeo, rotorBladeMat);
blade2.rotation.y = Math.PI / 2;
heliMainRotor.add(blade1, blade2);
helicopterGroup.add(heliMainRotor);
const boomGeo = new THREE.CylinderGeometry(0.09, 0.14, 1.5, 8);
boomGeo.rotateX(Math.PI / 2);
const tailBoom = new THREE.Mesh(boomGeo, heliHelmetMat);
tailBoom.position.set(0, 0.65, -1.35);
helicopterGroup.add(tailBoom);
heliTailRotor = new THREE.Group();
heliTailRotor.position.set(0.09, 1.1, -2.05);
const tBlade = new THREE.Mesh(new THREE.BoxGeometry(0.03, 0.8, 0.1), rotorBladeMat);
heliTailRotor.add(tBlade);
helicopterGroup.add(heliTailRotor);
heliGatlingLeft = new THREE.Group();
heliGatlingLeft.position.set(-0.95, 0.05, 0.3);
const podL = new THREE.Mesh(new THREE.CylinderGeometry(0.18, 0.18, 0.75, 8), new THREE.MeshToonMaterial({ color: 0x374151 }));
podL.rotation.x = Math.PI / 2;
const barrelL = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.05, 0.5, 6), rotorBladeMat);
barrelL.rotation.x = Math.PI / 2;
barrelL.position.z = 0.5;
heliGatlingLeft.add(podL, barrelL);
heliGatlingRight = heliGatlingLeft.clone();
heliGatlingRight.position.x = 0.95;
helicopterGroup.add(heliGatlingLeft, heliGatlingRight);
helicopterGroup.visible = false;
group.add(helicopterGroup);
// Pteranodon
pteranodonGroup = new THREE.Group();
const crestHead = new THREE.Mesh(new THREE.ConeGeometry(0.38, 1.6, 12), new THREE.MeshToonMaterial({ color: 0xe63946 }));
crestHead.position.set(0, 1.15, -0.65);
crestHead.rotation.x = -1.1;
const beak = new THREE.Mesh(new THREE.ConeGeometry(0.26, 0.85, 8), new THREE.MeshToonMaterial({ color: 0xfca311 }));
beak.position.set(0, 0.35, 1.15);
beak.rotation.x = 1.35;
pteranodonGroup.add(crestHead, beak);
const wingShape = new THREE.Shape();
wingShape.moveTo(0, 0);
wingShape.lineTo(1.8, 0.8);
wingShape.lineTo(2.2, 0.2);
wingShape.lineTo(1.5, -0.6);
wingShape.lineTo(0.5, -0.3);
wingShape.closePath();
const wingGeo = new THREE.ShapeGeometry(wingShape);
const wingMat = new THREE.MeshToonMaterial({ color: 0xef233c, side: THREE.DoubleSide });
pteraLeftWing = new THREE.Mesh(wingGeo, wingMat);
pteraLeftWing.position.set(-0.7, 0.3, -0.35);
pteraLeftWing.rotation.y = Math.PI - 0.2;
pteraRightWing = new THREE.Mesh(wingGeo, wingMat);
pteraRightWing.position.set(0.7, 0.3, -0.35);
pteraRightWing.rotation.y = 0.2;
pteranodonGroup.add(pteraLeftWing, pteraRightWing);
pteranodonGroup.visible = false;
group.add(pteranodonGroup);
// Goku Super Saiyan
dbGokuGroup = new THREE.Group();
const ssjHairMat = new THREE.MeshToonMaterial({ color: 0xffea00, emissive: 0xffb703, emissiveIntensity: 0.55 });
const hairSpikes = [
{ x: 0, y: 1.55, z: -0.1, rx: -0.25, rz: 0, sx: 0.45, sy: 1.4, sz: 0.45 },
{ x: -0.42, y: 1.4, z: 0.05, rx: -0.1, rz: 0.45, sx: 0.4, sy: 1.25, sz: 0.4 },
{ x: 0.42, y: 1.4, z: 0.05, rx: -0.1, rz: -0.45, sx: 0.4, sy: 1.25, sz: 0.4 },
{ x: -0.7, y: 1.05, z: 0.1, rx: 0.1, rz: 0.85, sx: 0.35, sy: 1.1, sz: 0.35 },
{ x: 0.7, y: 1.05, z: 0.1, rx: 0.1, rz: -0.85, sx: 0.35, sy: 1.1, sz: 0.35 }
];
hairSpikes.forEach(s => {
const spike = new THREE.Mesh(new THREE.ConeGeometry(s.sx, s.sy, 7), ssjHairMat);
spike.position.set(s.x, s.y, s.z);
spike.rotation.x = s.rx;
spike.rotation.z = s.rz;
dbGokuGroup.add(spike);
});
dbGokuGroup.visible = false;
group.add(dbGokuGroup);
// Fighter Jet
fighterJetGroup = new THREE.Group();
const jetHelmet = new THREE.Mesh(new THREE.SphereGeometry(0.72, 16, 16), new THREE.MeshToonMaterial({ color: 0x374151 }));
jetHelmet.position.set(0, 0.85, 0);
jetHelmet.scale.set(1.1, 0.9, 1.25);
const visor = new THREE.Mesh(new THREE.BoxGeometry(0.8, 0.28, 0.4), new THREE.MeshToonMaterial({ color: 0x38bdf8, transparent: true, opacity: 0.9 }));
visor.position.set(0, 0.82, 0.72);
fighterJetGroup.add(jetHelmet, visor);
const deltaWingShape = new THREE.Shape();
deltaWingShape.moveTo(0, 0);
deltaWingShape.lineTo(1.6, -0.9);
deltaWingShape.lineTo(1.5, -1.3);
deltaWingShape.lineTo(0, -0.6);
deltaWingShape.closePath();
const jetWingGeo = new THREE.ExtrudeGeometry(deltaWingShape, { depth: 0.08, bevelEnabled: false });
const jetWingMat = new THREE.MeshToonMaterial({ color: 0x4b5563 });
const leftJetWing = new THREE.Mesh(jetWingGeo, jetWingMat);
leftJetWing.position.set(-0.7, 0.1, 0.2);
leftJetWing.rotation.x = Math.PI / 2;
leftJetWing.rotation.y = Math.PI;
const rightJetWing = new THREE.Mesh(jetWingGeo, jetWingMat);
rightJetWing.position.set(0.7, 0.1, 0.2);
rightJetWing.rotation.x = Math.PI / 2;
fighterJetGroup.add(leftJetWing, rightJetWing);
jetAfterburners = [];
[-0.32, 0.32].forEach(xOffset => {
const flame = new THREE.Mesh(new THREE.ConeGeometry(0.16, 0.7, 8), new THREE.MeshBasicMaterial({ color: 0x00d2ff, transparent: true, opacity: 0.9 }));
flame.rotation.x = -Math.PI / 2;
flame.position.set(xOffset, 0.2, -1.3);
fighterJetGroup.add(flame);
jetAfterburners.push(flame);
});
fighterJetGroup.visible = false;
group.add(fighterJetGroup);
// Mosasaurus
mosasaurusGroup = new THREE.Group();
const mosaMat = new THREE.MeshToonMaterial({ color: 0x0f766e, shininess: 60 });
const mosaHead = new THREE.Mesh(new THREE.ConeGeometry(0.72, 1.6, 12), mosaMat);
mosaHead.rotation.x = Math.PI / 2;
mosaHead.position.set(0, 0.65, 0.45);
const upperJaw = new THREE.Mesh(new THREE.BoxGeometry(0.68, 0.22, 1.2), mosaMat);
upperJaw.position.set(0, 0.35, 1.15);
mosasaurusGroup.add(mosaHead, upperJaw);
const flipperGeo = new THREE.BoxGeometry(0.85, 0.06, 0.42);
mosaFlipperLeft = new THREE.Mesh(flipperGeo, mosaMat);
mosaFlipperLeft.position.set(-1.0, 0.05, 0.2);
mosaFlipperRight = new THREE.Mesh(flipperGeo, mosaMat);
mosaFlipperRight.position.set(1.0, 0.05, 0.2);
mosasaurusGroup.add(mosaFlipperLeft, mosaFlipperRight);
mosaTail = new THREE.Group();
mosaTail.position.set(0, 0.1, -1.05);
const tailFin = new THREE.Mesh(new THREE.ConeGeometry(0.24, 0.85, 4), mosaMat);
tailFin.position.set(0, 0.38, -0.45);
tailFin.rotation.x = -0.55;
mosaTail.add(tailFin);
mosasaurusGroup.add(mosaTail);
mosasaurusGroup.visible = false;
group.add(mosasaurusGroup);
superMechagodzillaGroup = new THREE.Group();
const titaniumMat = new THREE.MeshToonMaterial({ color: 0xd1d5db, metalness: 0.9, shininess: 90 });
const darkMetalMat = new THREE.MeshToonMaterial({ color: 0x334155, metalness: 0.8 });
const redVisorMat = new THREE.MeshBasicMaterial({ color: 0xef4444 });
const cyanEnergyMat = new THREE.MeshBasicMaterial({ color: 0x00f5ff });
const mechaHelmet = new THREE.Mesh(new THREE.SphereGeometry(0.78, 16, 16), titaniumMat);
mechaHelmet.position.set(0, 0.88, 0.05);
mechaHelmet.scale.set(1.05, 0.9, 1.15);
const visorPlate = new THREE.Mesh(new THREE.BoxGeometry(0.78, 0.18, 0.35), redVisorMat);
visorPlate.position.set(0, 0.88, 0.72);
superMechagodzillaGroup.add(mechaHelmet, visorPlate);
const foreheadCannon = new THREE.Mesh(new THREE.CylinderGeometry(0.08, 0.1, 0.45, 8), darkMetalMat);
foreheadCannon.rotation.x = Math.PI / 2;
foreheadCannon.position.set(0, 1.1, 0.65);
superMechagodzillaGroup.add(foreheadCannon);
// Backpack: Super Garuda Unit
mechaGarudaBackpack = new THREE.Group();
mechaGarudaBackpack.position.set(0, 0.6, -0.9);
const garudaFuselage = new THREE.Mesh(new THREE.BoxGeometry(1.6, 0.6, 1.2), titaniumMat);
mechaGarudaBackpack.add(garudaFuselage);
mechaPlasmaCannons = [];
[-0.65, 0.65].forEach(xOff => {
const cannonGroup = new THREE.Group();
cannonGroup.position.set(xOff, 0.4, 0);
const barrel = new THREE.Mesh(new THREE.CylinderGeometry(0.18, 0.22, 2.2, 12), darkMetalMat);
barrel.rotation.x = Math.PI / 2;
barrel.position.z = 0.5;
const muzzle = new THREE.Mesh(new THREE.CylinderGeometry(0.24, 0.24, 0.3, 12), cyanEnergyMat);
muzzle.rotation.x = Math.PI / 2;
muzzle.position.z = 1.6;
cannonGroup.add(barrel, muzzle);
mechaGarudaBackpack.add(cannonGroup);
mechaPlasmaCannons.push(cannonGroup);
});
mechaSpines = [];
for (let s = 0; s < 4; s++) {
const spine = new THREE.Mesh(new THREE.ConeGeometry(0.2, 0.6, 4), titaniumMat);
spine.rotation.x = -0.6;
spine.position.set(0, 0.3 + s * 0.35, -0.4 - s * 0.35);
superMechagodzillaGroup.add(spine);
mechaSpines.push(spine);
}
mechaThrusters = [];
[-0.5, 0.5].forEach(tx => {
const thrusterNozzle = new THREE.Mesh(new THREE.CylinderGeometry(0.18, 0.25, 0.5, 8), darkMetalMat);
thrusterNozzle.position.set(tx, -0.2, -0.6);
mechaGarudaBackpack.add(thrusterNozzle);
const plume = new THREE.Mesh(new THREE.ConeGeometry(0.16, 0.7, 8), cyanEnergyMat);
plume.rotation.x = -Math.PI / 2;
plume.position.set(tx, -0.2, -1.0);
mechaGarudaBackpack.add(plume);
mechaThrusters.push(plume);
});
superMechagodzillaGroup.add(mechaGarudaBackpack);
superMechagodzillaGroup.visible = false;
group.add(superMechagodzillaGroup);
brolyGroup = new THREE.Group();
const brolyHairMat = new THREE.MeshToonMaterial({
color: 0x86efac,
emissive: 0x22c55e,
emissiveIntensity: 0.65,
shininess: 80
});
const goldJewelryMat = new THREE.MeshToonMaterial({
color: 0xfacc15,
metalness: 0.85,
shininess: 90
});
// Legendary Super Saiyan Wild Spikes
const brolySpikesConfig = [
{ x: 0, y: 1.7, z: -0.15, rx: -0.3, rz: 0, sx: 0.55, sy: 1.8, sz: 0.55 },
{ x: -0.55, y: 1.5, z: 0.0, rx: -0.2, rz: 0.55, sx: 0.5, sy: 1.6, sz: 0.5 },
{ x: 0.55, y: 1.5, z: 0.0, rx: -0.2, rz: -0.55, sx: 0.5, sy: 1.6, sz: 0.5 },
{ x: -0.9, y: 1.1, z: 0.1, rx: 0.1, rz: 0.95, sx: 0.45, sy: 1.4, sz: 0.45 },
{ x: 0.9, y: 1.1, z: 0.1, rx: 0.1, rz: -0.95, sx: 0.45, sy: 1.4, sz: 0.45 },
{ x: 0, y: 1.45, z: -0.55, rx: -0.85, rz: 0, sx: 0.48, sy: 1.5, sz: 0.48 },
{ x: -0.35, y: 1.65, z: 0.25, rx: 0.25, rz: 0.35, sx: 0.4, sy: 1.3, sz: 0.4 },
{ x: 0.35, y: 1.65, z: 0.25, rx: 0.25, rz: -0.35, sx: 0.4, sy: 1.3, sz: 0.4 }
];
brolySpikesConfig.forEach(s => {
const spike = new THREE.Mesh(new THREE.ConeGeometry(s.sx, s.sy, 8), brolyHairMat);
spike.position.set(s.x, s.y, s.z);
spike.rotation.x = s.rx;
spike.rotation.z = s.rz;
brolyGroup.add(spike);
});
// Golden Torc / Torso Jewel
brolyTorcMesh = new THREE.Mesh(new THREE.TorusGeometry(0.85, 0.1, 8, 24), goldJewelryMat);
brolyTorcMesh.rotation.x = Math.PI / 2.3;
brolyTorcMesh.position.set(0, 0.4, 0.15);
const centerGem = new THREE.Mesh(new THREE.SphereGeometry(0.18, 12, 12), new THREE.MeshBasicMaterial({ color: 0xef4444 }));
centerGem.position.set(0, 0.32, 0.95);
brolyGroup.add(brolyTorcMesh, centerGem);
// Golden Arm Bracelets
[-0.98, 0.98].forEach(bx => {
const ring = new THREE.Mesh(new THREE.TorusGeometry(0.38, 0.08, 8, 16), goldJewelryMat);
ring.rotation.y = Math.PI / 2;
ring.position.set(bx, 0.1, 0);
brolyGroup.add(ring);
});
// Emerald Ki Aura Swirling Particles
const brolyKiCount = 50;
const brolyKiGeo = new THREE.BufferGeometry();
const brolyKiPos = new Float32Array(brolyKiCount * 3);
for (let i = 0; i < brolyKiCount * 3; i += 3) {
brolyKiPos[i] = (Math.random() - 0.5) * 3.0;
brolyKiPos[i + 1] = -0.8 + Math.random() * 3.2;
brolyKiPos[i + 2] = (Math.random() - 0.5) * 3.0;
}
brolyKiGeo.setAttribute('position', new THREE.BufferAttribute(brolyKiPos, 3));
brolyAuraParticles = new THREE.Points(
brolyKiGeo,
new THREE.PointsMaterial({ color: 0x22c55e, size: 0.45, transparent: true, opacity: 0.85, blending: THREE.AdditiveBlending })
);
brolyGroup.add(brolyAuraParticles);
brolyGroup.visible = false;
group.add(brolyGroup);
// Magolor (虚言の魔術師 マホロア / クラウンド・マホロア)
magolorGroup = new THREE.Group();
const magolorRobeMat = new THREE.MeshToonMaterial({ color: 0x312e81, shininess: 40 });
const magolorGoldMat = new THREE.MeshToonMaterial({ color: 0xfacc15, metalness: 0.85, shininess: 90 });
const magolorWhiteMat = new THREE.MeshToonMaterial({ color: 0xf8fafc });
// Wizard Cowl / Hood covering Kirby's head
const cowlGeo = new THREE.SphereGeometry(0.85, 20, 20);
const magolorCowl = new THREE.Mesh(cowlGeo, magolorRobeMat);
magolorCowl.position.set(0, 0.85, 0);
magolorCowl.scale.set(1.08, 0.95, 1.15);
magolorGroup.add(magolorCowl);
// Iconic Elongated Wizard Ears / Horn Flaps with Golden Bands
[-0.55, 0.55].forEach((earX, idx) => {
const ear = new THREE.Mesh(new THREE.ConeGeometry(0.26, 1.5, 8), magolorRobeMat);
ear.position.set(earX, 1.5, -0.2);
ear.rotation.z = (idx === 0 ? 0.45 : -0.45);
ear.rotation.x = -0.3;
magolorGroup.add(ear);
const goldRing = new THREE.Mesh(new THREE.TorusGeometry(0.25, 0.05, 8, 16), magolorGoldMat);
goldRing.position.set(earX * 1.05, 1.35, -0.15);
goldRing.rotation.x = Math.PI / 2;
magolorGroup.add(goldRing);
});
// Master Crown atop the Hood
magolorCrownMesh = new THREE.Group();
magolorCrownMesh.position.set(0, 1.75, 0.1);
const crownRing = new THREE.Mesh(new THREE.CylinderGeometry(0.55, 0.65, 0.35, 10), magolorGoldMat);
magolorCrownMesh.add(crownRing);
for (let c = 0; c < 5; c++) {
const point = new THREE.Mesh(new THREE.ConeGeometry(0.16, 0.5, 6), magolorGoldMat);
const ang = (c / 5) * Math.PI * 2;
point.position.set(Math.sin(ang) * 0.55, 0.35, Math.cos(ang) * 0.55);
magolorCrownMesh.add(point);
}
const crownGem = new THREE.Mesh(new THREE.SphereGeometry(0.2, 12, 12), new THREE.MeshBasicMaterial({ color: 0xd946ef }));
crownGem.position.set(0, 0.3, 0);
magolorCrownMesh.add(crownGem);
magolorGroup.add(magolorCrownMesh);
// Floating Disembodied Mittens / Hands
magolorHands = [];
[-1.25, 1.25].forEach((hx, idx) => {
const handGrp = new THREE.Group();
handGrp.position.set(hx, 0.3, 0.3);
const mitten = new THREE.Mesh(new THREE.SphereGeometry(0.32, 16, 16), magolorWhiteMat);
mitten.scale.set(1.0, 1.15, 0.9);
const cuff = new THREE.Mesh(new THREE.TorusGeometry(0.26, 0.06, 8, 16), magolorGoldMat);
cuff.rotation.x = Math.PI / 2;
cuff.position.y = -0.15;
handGrp.add(mitten, cuff);
magolorGroup.add(handGrp);
magolorHands.push(handGrp);
});
// Cosmic Dimension Starlight Aura Particles
const magolorStarCount = 45;
const magolorStarGeo = new THREE.BufferGeometry();
const magolorStarPos = new Float32Array(magolorStarCount * 3);
for (let i = 0; i < magolorStarCount * 3; i += 3) {
magolorStarPos[i] = (Math.random() - 0.5) * 3.2;
magolorStarPos[i + 1] = -0.5 + Math.random() * 3.0;
magolorStarPos[i + 2] = (Math.random() - 0.5) * 3.2;
}
magolorStarGeo.setAttribute('position', new THREE.BufferAttribute(magolorStarPos, 3));
magolorAuraParticles = new THREE.Points(
magolorStarGeo,
new THREE.PointsMaterial({ color: 0xd946ef, size: 0.38, transparent: true, opacity: 0.9, blending: THREE.AdditiveBlending })
);
magolorGroup.add(magolorAuraParticles);
magolorGroup.visible = false;
group.add(magolorGroup);
tyrannoGroup = new THREE.Group();
const rexScalesMat = new THREE.MeshToonMaterial({ color: 0x991b1b, shininess: 35 });
const rexDarkScalesMat = new THREE.MeshToonMaterial({ color: 0x5c1010, shininess: 25 });
const rexTeethMat = new THREE.MeshBasicMaterial({ color: 0xfffbeb });
const rexEyeMat = new THREE.MeshBasicMaterial({ color: 0xf59e0b });
// Tyranno Head Helmet / Massive Upper Jaw
tyrannoUpperJaw = new THREE.Group();
tyrannoUpperJaw.position.set(0, 0.85, 0.1);
const skullDome = new THREE.Mesh(new THREE.SphereGeometry(0.82, 16, 16), rexScalesMat);
skullDome.scale.set(1.05, 0.95, 1.25);
tyrannoUpperJaw.add(skullDome);
const snoutBox = new THREE.Mesh(new THREE.BoxGeometry(0.82, 0.55, 1.35), rexScalesMat);
snoutBox.position.set(0, -0.05, 0.9);
tyrannoUpperJaw.add(snoutBox);
// Predatory Horn Ridges above eyes
[-0.42, 0.42].forEach(hx => {
const ridge = new THREE.Mesh(new THREE.ConeGeometry(0.18, 0.65, 4), rexDarkScalesMat);
ridge.position.set(hx, 0.45, 0.65);
ridge.rotation.x = -0.55;
ridge.rotation.z = (hx < 0 ? 0.3 : -0.3);
tyrannoUpperJaw.add(ridge);
const eye = new THREE.Mesh(new THREE.SphereGeometry(0.14, 8, 8), rexEyeMat);
eye.position.set(hx * 1.08, 0.18, 0.82);
tyrannoUpperJaw.add(eye);
});
// Upper Serrated Fangs
for (let f = 0; f < 8; f++) {
const fang = new THREE.Mesh(new THREE.ConeGeometry(0.08, 0.28, 4), rexTeethMat);
fang.rotation.x = Math.PI;
const side = (f % 2 === 0 ? -0.38 : 0.38);
const zPos = 0.4 + (Math.floor(f / 2) * 0.28);
fang.position.set(side, -0.35, zPos);
tyrannoUpperJaw.add(fang);
}
tyrannoGroup.add(tyrannoUpperJaw);
// Lower Snapping Jaw
tyrannoLowerJaw = new THREE.Group();
tyrannoLowerJaw.position.set(0, 0.45, 0.3);
const lowerJawMesh = new THREE.Mesh(new THREE.BoxGeometry(0.74, 0.24, 1.15), rexDarkScalesMat);
lowerJawMesh.position.set(0, 0, 0.6);
tyrannoLowerJaw.add(lowerJawMesh);
for (let lf = 0; lf < 6; lf++) {
const lFang = new THREE.Mesh(new THREE.ConeGeometry(0.07, 0.24, 4), rexTeethMat);
const lSide = (lf % 2 === 0 ? -0.33 : 0.33);
const lZ = 0.3 + (Math.floor(lf / 2) * 0.3);
lFang.position.set(lSide, 0.18, lZ);
tyrannoLowerJaw.add(lFang);
}
tyrannoGroup.add(tyrannoLowerJaw);
// Muscular Segmented Tail
tyrannoTail = new THREE.Group();
tyrannoTail.position.set(0, 0.1, -0.9);
for (let t = 0; t < 4; t++) {
const seg = new THREE.Mesh(new THREE.ConeGeometry(0.38 - t * 0.07, 0.75, 6), rexScalesMat);
seg.rotation.x = -Math.PI / 2.3;
seg.position.set(0, -t * 0.1, -t * 0.55);
tyrannoTail.add(seg);
}
tyrannoGroup.add(tyrannoTail);
// Ferocious Mini Claws
[-0.92, 0.92].forEach((cx, idx) => {
const arm = new THREE.Mesh(new THREE.BoxGeometry(0.18, 0.45, 0.22), rexScalesMat);
arm.position.set(cx, 0.15, 0.55);
arm.rotation.x = 0.55;
const claw = new THREE.Mesh(new THREE.ConeGeometry(0.08, 0.25, 4), rexTeethMat);
claw.position.set(0, -0.25, 0.1);
claw.rotation.x = 0.6;
arm.add(claw);
tyrannoGroup.add(arm);
});
// Swirling Volcanic Lava Embers
const emberCount = 50;
const emberGeo = new THREE.BufferGeometry();
const emberPos = new Float32Array(emberCount * 3);
for (let i = 0; i < emberCount * 3; i += 3) {
emberPos[i] = (Math.random() - 0.5) * 3.2;
emberPos[i + 1] = -0.6 + Math.random() * 3.2;
emberPos[i + 2] = (Math.random() - 0.5) * 3.2;
}
emberGeo.setAttribute('position', new THREE.BufferAttribute(emberPos, 3));
tyrannoEmberParticles = new THREE.Points(
emberGeo,
new THREE.PointsMaterial({ color: 0xf97316, size: 0.42, transparent: true, opacity: 0.9, blending: THREE.AdditiveBlending })
);
tyrannoGroup.add(tyrannoEmberParticles);
tyrannoGroup.visible = false;
group.add(tyrannoGroup);
group.position.set(0, 1.4, 0);
scene.add(group);
return group;
}
let colliders = [];
let movingPlatforms = [];
let hazards = [];
let enemyProjectiles = [];
let collectables = [];
let enemies = [];
let projectiles = [];
let stageObjects = [];
let goalObject = null;
let currentStageIndex = 0;
let lastSafeIslandPos = new THREE.Vector3(0, 1.4, 0);
let stageIslands = [];
let totalIslandsCount = 0;
let visitedIslandsCount = 0;
let boss = null;
const STAGE_THEMES = [
{ name: "グリーンアイランド", skyColor: 0x60a5fa, grassColor: 0x22c55e, dirtColor: 0xb45309 },
{ name: "サンシャインデザート", skyColor: 0xf59e0b, grassColor: 0xfbbf24, dirtColor: 0x78350f },
{ name: "スカイハイガーデン", skyColor: 0x818cf8, grassColor: 0xa855f7, dirtColor: 0x4c1d95 },
{ name: "フロストスノーランド", skyColor: 0x38bdf8, grassColor: 0xe0f2fe, dirtColor: 0x334155 },
{ name: "ドリームスターウェイ", skyColor: 0x1e1b4b, grassColor: 0xfacc15, dirtColor: 0x581c87 }
];
const STAGE_NAMES = [
"1. 試練の突風草原", "2. 断崖の往復リフト", "3. 砲撃のウィスピー砦", "4. 針地獄のグリーングリーン",
"5. 熱砂のムービングステップ", "6. ゴルドー砂漠回廊", "7. ピラミッド高空トラップ", "8. オアシス大跳躍",
"9. 天空の強風ステップ", "10. 雲上の弾幕ストリート", "11. 浮遊回廊の追撃者", "12. スカイハイ大要塞",
"13. 凍てつく極小ステップ", "14. つららの落下キャニオン", "15. クリスタル迷宮針道", "16. 氷峰の最終関門",
"17. 星屑の激流スペース", "18. コズミック連続リフト", "19. 弾幕渦巻く銀河回廊", "20. 星の泉の極限決戦"
];
function createFloatingIsland(x, y, z, width, depth, height = 3.5, theme = STAGE_THEMES[0], isMoving = false, moveConfig = null, isStart = false, isGoal = false) {
const islandGroup = new THREE.Group();
const topMat = new THREE.MeshToonMaterial({ color: isGoal ? 0xa855f7 : (isMoving ? 0xec4899 : theme.grassColor) });
const topMesh = new THREE.Mesh(new THREE.BoxGeometry(width, 0.8, depth), topMat);
topMesh.receiveShadow = true;
islandGroup.add(topMesh);
const dirtMat = new THREE.MeshToonMaterial({ color: isGoal ? 0x581c87 : (isMoving ? 0x831843 : theme.dirtColor) });
const dirtMesh = new THREE.Mesh(new THREE.BoxGeometry(width * 0.95, height, depth * 0.95), dirtMat);
dirtMesh.position.y = -height / 2 - 0.4;
dirtMesh.receiveShadow = true;
islandGroup.add(dirtMesh);
// Checkpoint Beacon Post
const beaconGroup = new THREE.Group();
beaconGroup.position.set(0, 0.4, -depth * 0.35);
const pole = new THREE.Mesh(new THREE.CylinderGeometry(0.1, 0.1, 2.2, 8), new THREE.MeshToonMaterial({ color: 0xffffff }));
pole.position.y = 1.1;
beaconGroup.add(pole);
const flagOrbMat = new THREE.MeshBasicMaterial({ color: isStart ? 0x22c55e : (isGoal ? 0xa855f7 : 0xef4444) });
const flagOrb = new THREE.Mesh(new THREE.SphereGeometry(0.35, 12, 12), flagOrbMat);
flagOrb.position.y = 2.2;
beaconGroup.add(flagOrb);
islandGroup.add(beaconGroup);
islandGroup.position.set(x, y, z);
scene.add(islandGroup);
stageObjects.push(islandGroup);
const col = {
minX: x - width / 2,
maxX: x + width / 2,
minZ: z - depth / 2,
maxZ: z + depth / 2,
topY: y + 0.4,
width: width,
depth: depth,
isMoving: isMoving,
mesh: islandGroup
};
colliders.push(col);
const islandData = {
id: stageIslands.length + 1,
mesh: islandGroup,
beaconOrb: flagOrb,
visited: isStart,
isGoal: isGoal,
x: x, y: y, z: z,
width: width, depth: depth
};
stageIslands.push(islandData);
if (isMoving && moveConfig) {
movingPlatforms.push({
col: col,
mesh: islandGroup,
baseX: x, baseY: y, baseZ: z,
axis: moveConfig.axis || 'x',
dist: moveConfig.dist || 6,
speed: moveConfig.speed || 2.2,
phase: moveConfig.phase || 0
});
}
return islandGroup;
}
function createBigBoss(x, y, z) {
const bossGroup = new THREE.Group();
// Heavy King Body
const bossMat = new THREE.MeshToonMaterial({ color: 0x3b82f6, shininess: 40 });
const body = new THREE.Mesh(new THREE.SphereGeometry(2.4, 24, 24), bossMat);
body.scale.set(1.1, 1.0, 1.05);
body.castShadow = true;
bossGroup.add(body);
// Face & Fierce Eyes
const faceMat = new THREE.MeshToonMaterial({ color: 0xfde047 });
const face = new THREE.Mesh(new THREE.SphereGeometry(1.6, 20, 20), faceMat);
face.position.set(0, 0.2, 1.2);
face.scale.set(0.9, 0.7, 0.4);
bossGroup.add(face);
const eyeMat = new THREE.MeshBasicMaterial({ color: 0xef4444 });
[-0.5, 0.5].forEach(ex => {
const eye = new THREE.Mesh(new THREE.SphereGeometry(0.24, 8, 8), eyeMat);
eye.position.set(ex, 0.35, 1.65);
bossGroup.add(eye);
});
// Golden Crown
const crownMat = new THREE.MeshToonMaterial({ color: 0xf59e0b, emissive: 0xd97706, emissiveIntensity: 0.3 });
const crownBase = new THREE.Mesh(new THREE.CylinderGeometry(1.2, 1.4, 0.7, 12), crownMat);
crownBase.position.set(0, 2.3, 0);
bossGroup.add(crownBase);
for (let c = 0; c < 5; c++) {
const point = new THREE.Mesh(new THREE.ConeGeometry(0.25, 0.6, 6), crownMat);
const ang = (c / 5) * Math.PI * 2;
point.position.set(Math.sin(ang) * 1.1, 2.8, Math.cos(ang) * 1.1);
bossGroup.add(point);
}
// Gigantic Spiked Hammer
const hammerGroup = new THREE.Group();
hammerGroup.position.set(2.4, 0.5, 0.5);
const handle = new THREE.Mesh(new THREE.CylinderGeometry(0.2, 0.2, 4.0, 8), new THREE.MeshToonMaterial({ color: 0x78350f }));
handle.rotation.z = -0.5;
const hammerHead = new THREE.Mesh(new THREE.CylinderGeometry(1.0, 1.0, 2.2, 12), new THREE.MeshToonMaterial({ color: 0x1f2937, metalness: 0.8 }));
hammerHead.rotation.x = Math.PI / 2;
hammerHead.position.set(0.8, 1.6, 0);
hammerGroup.add(handle, hammerHead);
bossGroup.add(hammerGroup);
bossGroup.position.set(x, y + 2.5, z);
scene.add(bossGroup);
stageObjects.push(bossGroup);
boss = {
mesh: bossGroup,
hammer: hammerGroup,
hp: 100,
maxHp: 100,
alive: true,
baseX: x, baseY: y + 2.5, baseZ: z,
state: 'idle',
timer: 0,
attackCooldown: 2.0,
shockwaveCooldown: 4.0
};
const bossHud = document.getElementById('boss-hud');
bossHud.style.display = 'flex';
document.getElementById('boss-hp-fill').style.width = '100%';
document.getElementById('boss-hp-pct').textContent = '100%';
}
function createSpikeHazard(x, y, z, count = 3) {
const group = new THREE.Group();
const spikeGeo = new THREE.ConeGeometry(0.35, 0.9, 8);
const spikeMat = new THREE.MeshToonMaterial({ color: 0xdc2626, metalness: 0.8 });
for (let i = 0; i < count; i++) {
const s = new THREE.Mesh(spikeGeo, spikeMat);
s.position.set((i - (count - 1) / 2) * 0.8, 0.45, 0);
group.add(s);
}
group.position.set(x, y, z);
scene.add(group);
stageObjects.push(group);
hazards.push({
type: 'spike',
pos: new THREE.Vector3(x, y + 0.45, z),
radius: 0.5 * count,
mesh: group
});
}
function createGordoObstacle(x, y, z, moveRange = 5, axis = 'x') {
const group = new THREE.Group();
const bodyMat = new THREE.MeshToonMaterial({ color: 0x1e293b, metalness: 0.9, shininess: 80 });
const core = new THREE.Mesh(new THREE.SphereGeometry(0.85, 16, 16), bodyMat);
group.add(core);
const spikeGeo = new THREE.ConeGeometry(0.24, 0.75, 8);
const spikeMat = new THREE.MeshToonMaterial({ color: 0x94a3b8 });
const dirs = [
[1, 0, 0], [-1, 0, 0], [0, 1, 0], [0, -1, 0], [0, 0, 1], [0, 0, -1],
[0.7, 0.7, 0], [-0.7, 0.7, 0], [0.7, -0.7, 0], [-0.7, -0.7, 0]
];
dirs.forEach(d => {
const sp = new THREE.Mesh(spikeGeo, spikeMat);
sp.position.set(d[0] * 0.85, d[1] * 0.85, d[2] * 0.85);
sp.quaternion.setFromUnitVectors(new THREE.Vector3(0, 1, 0), new THREE.Vector3(d[0], d[1], d[2]).normalize());
group.add(sp);
});
const eyeMat = new THREE.MeshBasicMaterial({ color: 0xfacc15 });
const e1 = new THREE.Mesh(new THREE.SphereGeometry(0.2, 8, 8), eyeMat);
e1.position.set(-0.3, 0.15, 0.8);
const e2 = e1.clone();
e2.position.x = 0.3;
group.add(e1, e2);
group.position.set(x, y, z);
scene.add(group);
stageObjects.push(group);
hazards.push({
type: 'gordo',
pos: group.position,
baseX: x, baseY: y, baseZ: z,
axis: axis,
range: moveRange,
speed: 3.2,
radius: 1.4,
mesh: group
});
}
function createStarShape(outerRadius = 0.6, innerRadius = 0.3) {
const shape = new THREE.Shape();
const points = 5;
for (let i = 0; i < points * 2; i++) {
const r = (i % 2 === 0) ? outerRadius : innerRadius;
const angle = (i / (points * 2)) * Math.PI * 2 - Math.PI / 2;
const px = Math.cos(angle) * r;
const py = Math.sin(angle) * r;
if (i === 0) shape.moveTo(px, py);
else shape.lineTo(px, py);
}
shape.closePath();
return new THREE.ExtrudeGeometry(shape, { depth: 0.25, bevelEnabled: true, bevelSegments: 3, steps: 1, bevelSize: 0.08, bevelThickness: 0.08 });
}
function spawnStar(x, y, z) {
const starGeo = createStarShape(0.65, 0.32);
const starMat = new THREE.MeshToonMaterial({ color: 0xffdd17, emissive: 0xffaa00, emissiveIntensity: 0.4 });
const mesh = new THREE.Mesh(starGeo, starMat);
mesh.position.set(x, y, z);
scene.add(mesh);
stageObjects.push(mesh);
collectables.push({ mesh: mesh, type: 'star', baseY: y, collected: false });
}
function spawnEnemy(x, y, z, abilityType = 'normal', isTurret = false) {
const group = new THREE.Group();
let bodyColor = 0xff8c3b;
if (abilityType === 'sword') bodyColor = 0x22c55e;
else if (abilityType === 'fire') bodyColor = 0xef4444;
else if (abilityType === 'cutter') bodyColor = 0xeab308;
else if (abilityType === 'goku') bodyColor = 0xf97316;
else if (abilityType === 'broly') bodyColor = 0x15803d;
else if (abilityType === 'magolor') bodyColor = 0x312e81;
else if (abilityType === 'tyranno') bodyColor = 0x991b1b;
else if (abilityType === 'pteranodon') bodyColor = 0xd90429;
else if (abilityType === 'fighter') bodyColor = 0x475569;
else if (abilityType === 'helicopter') bodyColor = 0x3f6212;
else if (abilityType === 'mosasaurus') bodyColor = 0x0d9488;
else if (abilityType === 'mechagodzilla') bodyColor = 0x94a3b8;
if (isTurret) bodyColor = 0x7c3aed;
const body = new THREE.Mesh(new THREE.SphereGeometry(0.75, 20, 20), new THREE.MeshToonMaterial({
color: bodyColor,
metalness: abilityType === 'mechagodzilla' ? 0.9 : (abilityType === 'broly' ? 0.4 : 0.0),
shininess: abilityType === 'mechagodzilla' ? 100 : (abilityType === 'broly' ? 60 : 30)
}));
body.castShadow = true;
group.add(body);
const face = new THREE.Mesh(new THREE.SphereGeometry(0.55, 16, 16), new THREE.MeshToonMaterial({
color: abilityType === 'mechagodzilla' ? 0xe2e8f0 : (abilityType === 'broly' ? 0xfef08a : (abilityType === 'magolor' ? 0xede9fe : 0xffe4bf))
}));
face.scale.set(0.9, 0.9, 0.5);
face.position.set(0, 0.05, 0.46);
group.add(face);
// Magolor Super Copy Enemy: Wizard Hood, Crown & Star Magic Circle
if (abilityType === 'magolor') {
const wizardHood = new THREE.Mesh(new THREE.ConeGeometry(0.5, 0.9, 8), new THREE.MeshToonMaterial({ color: 0x3730a3 }));
wizardHood.position.set(0, 0.85, -0.15);
wizardHood.rotation.x = -0.35;
group.add(wizardHood);
const miniCrown = new THREE.Mesh(new THREE.TorusGeometry(0.32, 0.07, 8, 16), new THREE.MeshBasicMaterial({ color: 0xfacc15 }));
miniCrown.position.set(0, 1.05, 0);
miniCrown.rotation.x = Math.PI / 2;
group.add(miniCrown);
const magicRune = new THREE.Mesh(new THREE.RingGeometry(0.7, 0.95, 16), new THREE.MeshBasicMaterial({ color: 0xc084fc, side: THREE.DoubleSide }));
magicRune.rotation.x = Math.PI / 2;
magicRune.position.y = -0.3;
group.add(magicRune);
}
// Broly Super Copy Enemy distinctive ornaments & emerald aura
if (abilityType === 'broly') {
const torc = new THREE.Mesh(new THREE.TorusGeometry(0.78, 0.1, 8, 16), new THREE.MeshToonMaterial({ color: 0xfacc15, metalness: 0.8 }));
torc.rotation.x = Math.PI / 2;
torc.position.y = 0.2;
group.add(torc);
const greenSpikes = new THREE.Mesh(new THREE.ConeGeometry(0.3, 0.9, 6), new THREE.MeshBasicMaterial({ color: 0x22c55e }));
greenSpikes.position.set(0, 0.9, -0.2);
group.add(greenSpikes);
const aura = new THREE.Mesh(new THREE.TorusGeometry(1.0, 0.09, 8, 16), new THREE.MeshBasicMaterial({ color: 0x4ade80 }));
aura.rotation.x = Math.PI / 2;
group.add(aura);
}
if (abilityType === 'tyranno') {
const snout = new THREE.Mesh(new THREE.BoxGeometry(0.75, 0.45, 0.8), new THREE.MeshToonMaterial({ color: 0x7f1d1d }));
snout.position.set(0, 0.25, 0.65);
group.add(snout);
[-0.22, 0.22].forEach(fx => {
const fang = new THREE.Mesh(new THREE.ConeGeometry(0.12, 0.32, 4), new THREE.MeshBasicMaterial({ color: 0xffffff }));
fang.rotation.x = Math.PI;
fang.position.set(fx, 0.06, 0.85);
group.add(fang);
});
const aura = new THREE.Mesh(new THREE.TorusGeometry(1.0, 0.1, 8, 16), new THREE.MeshBasicMaterial({ color: 0xef4444 }));
aura.rotation.x = Math.PI / 2;
group.add(aura);
}
// Super Mechagodzilla Distinct Model Head & Cannons
if (abilityType === 'mechagodzilla') {
const crest = new THREE.Mesh(new THREE.ConeGeometry(0.25, 0.8, 4), new THREE.MeshToonMaterial({ color: 0x475569, metalness: 0.8 }));
crest.position.set(0, 0.8, 0);
crest.rotation.x = -0.4;
group.add(crest);
[-0.6, 0.6].forEach(sx => {
const cannon = new THREE.Mesh(new THREE.CylinderGeometry(0.12, 0.12, 0.6, 8), new THREE.MeshToonMaterial({ color: 0xef4444 }));
cannon.rotation.x = Math.PI / 2;
cannon.position.set(sx, 0.4, 0.2);
group.add(cannon);
});
const aura = new THREE.Mesh(new THREE.TorusGeometry(0.95, 0.08, 8, 16), new THREE.MeshBasicMaterial({ color: 0x38bdf8 }));
aura.rotation.x = Math.PI / 2;
group.add(aura);
}
if (isTurret) {
const barrel = new THREE.Mesh(new THREE.CylinderGeometry(0.25, 0.28, 0.9, 8), new THREE.MeshToonMaterial({ color: 0x1e1b4b }));
barrel.rotation.x = Math.PI / 2;
barrel.position.set(0, 0.35, 0.7);
group.add(barrel);
}
group.position.set(x, y, z);
scene.add(group);
stageObjects.push(group);
enemies.push({
mesh: group,
startX: x,
alive: true,
dir: 1,
range: 3.5,
speed: 2.4,
ability: abilityType,
isTurret: isTurret,
fireCooldown: 1.8 + Math.random() * 1.5,
hp: isTurret ? 2 : ((abilityType === 'mechagodzilla' || abilityType === 'broly' || abilityType === 'magolor' || abilityType === 'tyranno') ? 3 : 1)
});
}
function createGoalWarpStar(x, y, z) {
const group = new THREE.Group();
const starGeo = createStarShape(1.8, 0.9);
const bigStar = new THREE.Mesh(starGeo, new THREE.MeshToonMaterial({ color: 0xffea00, emissive: 0xffb300, emissiveIntensity: 0.6 }));
bigStar.rotation.x = 0.3;
group.add(bigStar);
const ring = new THREE.Mesh(new THREE.TorusGeometry(2.4, 0.25, 16, 32), new THREE.MeshToonMaterial({ color: 0x5ce1e6 }));
ring.rotation.x = Math.PI / 2;
ring.position.y = -1.2;
group.add(ring);
group.position.set(x, y, z);
scene.add(group);
stageObjects.push(group);
goalObject = {
mesh: group,
starMesh: bigStar,
pos: new THREE.Vector3(x, y, z),
cleared: false,
unlocked: false
};
// Keep hidden until all islands and boss are defeated
group.visible = false;
}
function clearCurrentStage() {
stageObjects.forEach(obj => scene.remove(obj));
stageObjects = [];
colliders = [];
movingPlatforms = [];
hazards = [];
collectables = [];
enemies = [];
enemyProjectiles.forEach(ep => scene.remove(ep.mesh));
enemyProjectiles = [];
projectiles.forEach(p => scene.remove(p.mesh));
projectiles = [];
stageIslands = [];
goalObject = null;
boss = null;
const bossHud = document.getElementById('boss-hud');
if (bossHud) bossHud.style.display = 'none';
}
function updateIslandTrackerUI() {
const countEl = document.getElementById('island-count-text');
countEl.textContent = visitedIslandsCount + ' / ' + totalIslandsCount + ' 島';
if (visitedIslandsCount >= totalIslandsCount) {
countEl.classList.add('ready');
} else {
countEl.classList.remove('ready');
}
}
function showMissionToast(text) {
const toast = document.getElementById('mission-toast');
toast.textContent = text;
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
}, 2400);
}
function buildStage(stageIndex) {
clearCurrentStage();
const safeIndex = Math.max(0, Math.min(stageIndex, STAGE_NAMES.length - 1));
const themeIdx = Math.floor(safeIndex / 4);
const theme = STAGE_THEMES[themeIdx];
const skyColorObj = new THREE.Color(theme.skyColor);
scene.background = skyColorObj;
if (renderer) renderer.setClearColor(skyColorObj, 1.0);
document.getElementById('stage-title-text').textContent = STAGE_NAMES[safeIndex];
const stageSubNum = (safeIndex % 4);
const islandCount = 6 + stageSubNum;
totalIslandsCount = islandCount + 2; // start base + intermediate islands + final boss island
visitedIslandsCount = 1;
let currentZ = 0;
let currentY = 0;
let currentX = 0;
// 1. Starting Island Base
createFloatingIsland(0, 0, 0, 12, 12, 4, theme, false, null, true, false);
lastSafeIslandPos.set(0, 1.4, 0);
spawnStar(-2.5, 1.8, 1.5);
spawnStar(2.5, 1.8, 1.5);
// Initial Starter Enemy Pool (Includes Tyrannosaurus, Magolor, Broly & Super Mechagodzilla)
const starterPool = ['tyranno', 'magolor', 'broly', 'mechagodzilla', 'fighter', 'helicopter', 'mosasaurus', 'pteranodon', 'goku', 'sword'];
spawnEnemy(3.2, 1.4, -2, starterPool[safeIndex % starterPool.length]);
// 2. Intermediate Island Platforms
const abilitiesPool = ['tyranno', 'magolor', 'broly', 'mechagodzilla', 'fighter', 'helicopter', 'mosasaurus', 'pteranodon', 'goku', 'sword', 'fire', 'cutter'];
for (let i = 1; i <= islandCount; i++) {
const chasmGap = 20.0 + (safeIndex * 0.45);
currentZ -= chasmGap;
if (stageSubNum === 1) {
currentX = (i % 2 === 0 ? 7.5 : -7.5);
currentY += 1.8;
} else if (stageSubNum === 2) {
currentX = Math.sin(i * 1.5) * 8.0;
currentY += (i % 2 === 0 ? 2.5 : -1.0);
} else if (stageSubNum === 3) {
currentX = Math.cos(i * 1.7) * 8.5;
currentY += 2.2;
} else {
currentX = Math.sin(i * 1.2) * 6.5;
currentY += 1.5;
}
const isLift = (i % 2 === 1) || (safeIndex >= 8 && i % 3 === 0);
const width = Math.max(5.5, 9.5 - (safeIndex * 0.15));
const depth = Math.max(5.5, 8.5 - (safeIndex * 0.15));
createFloatingIsland(
currentX, currentY, currentZ, width, depth, 3.5, theme,
isLift,
isLift ? { axis: (i % 2 === 0 ? 'z' : 'x'), dist: 6.5 + (safeIndex * 0.2), speed: 2.5 + (safeIndex * 0.08), phase: i } : null,
false,
false
);
const midZ = currentZ + chasmGap * 0.5;
const midY = currentY + 3.2;
const midX = currentX * 0.5;
if (i % 2 === 0) {
createGordoObstacle(midX, midY, midZ, 6.0, 'x');
} else {
spawnStar(midX - 1.5, midY + 0.8, midZ + 2.0);
spawnStar(midX, midY + 1.6, midZ);
spawnStar(midX + 1.5, midY + 0.8, midZ - 2.0);
}
if (i % 3 === 0) {
createSpikeHazard(currentX - 1.2, currentY + 0.4, currentZ, 2);
}
const isShooter = (i % 2 === 1 && safeIndex >= 2);
const chosenAbility = abilitiesPool[i % abilitiesPool.length];
spawnEnemy(currentX + 1.2, currentY + 1.4, currentZ, chosenAbility, isShooter);
}
// 3. Final Goal & Boss Island
const finalChasm = 28.0;
const goalZ = currentZ - finalChasm;
const goalY = currentY + 3.5;
createFloatingIsland(0, goalY, goalZ, 22, 22, 6, theme, false, null, false, true);
// Spawn Big Boss and Locked Goal Star
createBigBoss(0, goalY, goalZ - 2.0);
createGoalWarpStar(0, goalY + 3.4, goalZ);
updateIslandTrackerUI();
// Reset Player State
player.position.set(0, 1.4, 0);
player.velocity.set(0, 0, 0);
player.isGrounded = true;
player.isHovering = false;
player.mouthFull = null;
player.targetRotationY = Math.PI;
player.currentRotationY = Math.PI;
if (kirby) {
kirby.position.copy(player.position);
kirby.rotation.y = player.currentRotationY;
kirby.visible = true;
}
if (camera) {
camera.position.set(0, player.position.y + 6.5, player.position.z + 13.0);
camera.lookAt(player.position.x, player.position.y + 0.6, player.position.z);
}
if (lightTarget) {
lightTarget.position.copy(player.position);
}
}
const player = {
position: new THREE.Vector3(0, 1.4, 0),
velocity: new THREE.Vector3(0, 0, 0),
targetRotationY: Math.PI,
currentRotationY: Math.PI,
speed: 12.5,
jumpForce: 14.0,
hoverForce: 8.0,
gravity: 32.0,
isGrounded: true,
isHovering: false,
hoverCount: 0,
maxHovers: 12,
mouthFull: null,
ability: 'normal',
isInhaling: false,
hp: 100,
score: 0,
invincibleTimer: 0,
isPteraDiving: false
};
const keys = {
forward: false,
backward: false,
left: false,
right: false,
jump: false,
actionInhale: false,
actionAttack: false
};
function setPlayerAbility(abilityName) {
player.ability = abilityName;
const iconEl = document.getElementById('ability-icon');
const nameEl = document.getElementById('ability-name');
const dropBtn = document.getElementById('btn-drop-ability');
const mAbilityBtn = document.getElementById('btn-ability-atk');
const mTeleportBtn = document.getElementById('btn-teleport');
swordGroup.visible = (abilityName === 'sword');
fireHatGroup.visible = (abilityName === 'fire');
cutterHatGroup.visible = (abilityName === 'cutter');
dbGokuGroup.visible = (abilityName === 'goku');
if (brolyGroup) brolyGroup.visible = (abilityName === 'broly');
if (magolorGroup) magolorGroup.visible = (abilityName === 'magolor');
if (tyrannoGroup) tyrannoGroup.visible = (abilityName === 'tyranno');
pteranodonGroup.visible = (abilityName === 'pteranodon');
if (fighterJetGroup) fighterJetGroup.visible = (abilityName === 'fighter');
if (helicopterGroup) helicopterGroup.visible = (abilityName === 'helicopter');
if (mosasaurusGroup) mosasaurusGroup.visible = (abilityName === 'mosasaurus');
if (superMechagodzillaGroup) superMechagodzillaGroup.visible = (abilityName === 'mechagodzilla');
if (abilityName === 'normal') {
iconEl.textContent = '✨';
nameEl.textContent = 'ノーマル';
dropBtn.style.display = 'none';
mAbilityBtn.style.display = 'none';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
} else if (abilityName === 'tyranno') {
iconEl.textContent = '🦖';
nameEl.textContent = '★白亜紀の暴君 ティラノサウルス★';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>ギガント・バイト / 暴君咆哮</span><span>T-REX</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
SoundController.tyrannoRoar();
} else if (abilityName === 'magolor') {
iconEl.textContent = '🌌';
nameEl.textContent = '★虚言の魔術師 マホロア★';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>ブラックホール / 魔力弾</span><span>MAGOLOR</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
} else if (abilityName === 'broly') {
iconEl.textContent = '👑';
nameEl.textContent = '★伝説の超サイヤ人 ブロリー★';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>ギガンティック・ミーティア</span><span>BROLY</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
} else if (abilityName === 'mechagodzilla') {
iconEl.textContent = '🤖';
nameEl.textContent = '★スーパーメカゴジラ★';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>メガ・バスター / プラズマ</span><span>SUPER MECHA</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
} else if (abilityName === 'mosasaurus') {
iconEl.textContent = '🌊';
nameEl.textContent = 'モササウルス';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>津波/噛み砕き</span><span>MOSASAUR</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
SoundController.mosasaurRoar();
} else if (abilityName === 'helicopter') {
iconEl.textContent = '🚁';
nameEl.textContent = '戦闘ヘリ';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>ガトリング/ロケット</span><span>HELI ATTACK</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
SoundController.helicopterRotor();
} else if (abilityName === 'fighter') {
iconEl.textContent = '✈️';
nameEl.textContent = '戦闘機';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>ミサイル/突進</span><span>JET MISSILE</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
SoundController.jetEngine();
} else if (abilityName === 'pteranodon') {
iconEl.textContent = '🦖';
nameEl.textContent = 'プテラノドン';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>竜巻/ダイブ</span><span>PTERA</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
SoundController.pteraRoar();
} else if (abilityName === 'goku') {
iconEl.textContent = '⚡';
nameEl.textContent = '超サイヤ人 孫悟空';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>かめはめ波</span><span>BEAM</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'flex';
SoundController.superSaiyanRoar();
} else if (abilityName === 'sword') {
iconEl.textContent = '🗡️';
nameEl.textContent = 'ソード';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>ソード斬り</span><span>SLASH</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
SoundController.copyFanfare();
} else if (abilityName === 'fire') {
iconEl.textContent = '🔥';
nameEl.textContent = 'ファイア';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>火炎放射</span><span>FIRE</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
SoundController.copyFanfare();
} else if (abilityName === 'cutter') {
iconEl.textContent = '🪃';
nameEl.textContent = 'カッター';
dropBtn.style.display = 'inline-block';
mAbilityBtn.style.display = 'flex';
mAbilityBtn.innerHTML = '<span>カッター</span><span>BOOMERANG</span>';
if (mTeleportBtn) mTeleportBtn.style.display = 'none';
SoundController.copyFanfare();
}
}
function dropPlayerAbility() {
if (player.ability === 'normal') return;
SoundController.jump();
spawnStar(player.position.x, player.position.y + 1.0, player.position.z);
setPlayerAbility('normal');
}
let suctionParticles;
function createSuctionParticles() {
const pCount = 40;
const pGeo = new THREE.BufferGeometry();
const positions = new Float32Array(pCount * 3);
for (let i = 0; i < pCount * 3; i += 3) {
positions[i] = (Math.random() - 0.5) * 3.5;
positions[i + 1] = (Math.random() - 0.5) * 2;
positions[i + 2] = 2 + Math.random() * 3.5;
}
pGeo.setAttribute('position', new THREE.BufferAttribute(positions, 3));
const pMat = new THREE.PointsMaterial({ color: 0xffffff, size: 0.28, transparent: true, opacity: 0.0 });
suctionParticles = new THREE.Points(pGeo, pMat);
kirby.add(suctionParticles);
}
function setupInputListeners() {
window.addEventListener('keydown', (e) => {
SoundController.init();
switch (e.code) {
case 'KeyW': case 'ArrowUp': keys.forward = true; break;
case 'KeyS': case 'ArrowDown': keys.backward = true; break;
case 'KeyA': case 'ArrowLeft': keys.left = true; break;
case 'KeyD': case 'ArrowRight': keys.right = true; break;
case 'Space':
if (!keys.jump) handleJumpPress();
keys.jump = true;
break;
case 'KeyZ': case 'KeyJ':
if (player.mouthFull) {
swallowMouthFull();
} else {
keys.actionInhale = true;
}
break;
case 'KeyX': case 'KeyK':
handleActionPress();
break;
case 'KeyE': case 'KeyL':
if (player.ability === 'goku') performInstantTransmission();
break;
case 'KeyC':
dropPlayerAbility();
break;
}
});
window.addEventListener('keyup', (e) => {
switch (e.code) {
case 'KeyW': case 'ArrowUp': keys.forward = false; break;
case 'KeyS': case 'ArrowDown': keys.backward = false; break;
case 'KeyA': case 'ArrowLeft': keys.left = false; break;
case 'KeyD': case 'ArrowRight': keys.right = false; break;
case 'Space': keys.jump = false; break;
case 'KeyZ': case 'KeyJ': keys.actionInhale = false; break;
}
});
// Touch controls
const btnJump = document.getElementById('btn-jump');
const btnAction = document.getElementById('btn-action');
const btnAbility = document.getElementById('btn-ability-atk');
const btnTeleport = document.getElementById('btn-teleport');
btnJump.addEventListener('touchstart', (e) => {
e.preventDefault();
SoundController.init();
handleJumpPress();
}, { passive: false });
const startInhale = (e) => {
if (e) e.preventDefault();
SoundController.init();
if (player.mouthFull) {
handleActionPress();
} else {
keys.actionInhale = true;
}
};
const stopInhale = (e) => {
if (e) e.preventDefault();
keys.actionInhale = false;
};
btnAction.addEventListener('touchstart', startInhale, { passive: false });
btnAction.addEventListener('touchend', stopInhale, { passive: false });
btnAction.addEventListener('mousedown', startInhale);
btnAction.addEventListener('mouseup', stopInhale);
const triggerAbilityAttack = (e) => {
if (e) e.preventDefault();
SoundController.init();
handleActionPress();
};
btnAbility.addEventListener('touchstart', triggerAbilityAttack, { passive: false });
btnAbility.addEventListener('mousedown', triggerAbilityAttack);
if (btnTeleport) {
btnTeleport.addEventListener('touchstart', (e) => {
e.preventDefault();
SoundController.init();
if (player.ability === 'goku') performInstantTransmission();
}, { passive: false });
btnTeleport.addEventListener('mousedown', () => {
if (player.ability === 'goku') performInstantTransmission();
});
}
document.getElementById('btn-drop-ability').addEventListener('click', dropPlayerAbility);
// Virtual D-pad
const dpadZone = document.getElementById('dpad-zone');
const dpadKnob = document.getElementById('dpad-knob');
let touchId = null;
let dpadCenter = { x: 0, y: 0 };
dpadZone.addEventListener('touchstart', (e) => {
SoundController.init();
const touch = e.changedTouches[0];
touchId = touch.identifier;
const rect = dpadZone.getBoundingClientRect();
dpadCenter = { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
updateJoystick(touch.clientX, touch.clientY);
});
window.addEventListener('touchmove', (e) => {
if (touchId === null) return;
for (let i = 0; i < e.changedTouches.length; i++) {
if (e.changedTouches[i].identifier === touchId) {
updateJoystick(e.changedTouches[i].clientX, e.changedTouches[i].clientY);
break;
}
}
});
const resetJoystick = () => {
touchId = null;
dpadKnob.style.transform = 'translate(0px, 0px)';
keys.forward = keys.backward = keys.left = keys.right = false;
};
window.addEventListener('touchend', (e) => {
for (let i = 0; i < e.changedTouches.length; i++) {
if (e.changedTouches[i].identifier === touchId) resetJoystick();
}
});
window.addEventListener('touchcancel', resetJoystick);
function updateJoystick(cx, cy) {
const dx = cx - dpadCenter.x;
const dy = cy - dpadCenter.y;
const dist = Math.sqrt(dx * dx + dy * dy);
const maxR = 40;
const clampedDist = Math.min(dist, maxR);
const angle = Math.atan2(dy, dx);
const kx = Math.cos(angle) * clampedDist;
const ky = Math.sin(angle) * clampedDist;
dpadKnob.style.transform = 'translate(' + kx + 'px, ' + ky + 'px)';
const deadzone = 10;
keys.right = dx > deadzone;
keys.left = dx < -deadzone;
keys.backward = dy > deadzone;
keys.forward = dy < -deadzone;
}
document.getElementById('btn-reset').addEventListener('click', restartGame);
window.addEventListener('resize', onWindowResize);
}
function handleJumpPress() {
if (player.isGrounded) {
player.velocity.y = player.jumpForce;
player.isGrounded = false;
player.isHovering = false;
player.hoverCount = 0;
SoundController.jump();
} else if (player.ability === 'tyranno') {
player.velocity.y = 14.5;
player.isHovering = true;
SoundController.tyrannoStomp();
} else if (player.ability === 'magolor') {
player.velocity.y = 13.0;
player.isHovering = true;
SoundController.magolorMagicChime();
} else if (player.ability === 'broly') {
player.velocity.y = 13.5;
player.isHovering = true;
SoundController.kiExplosion();
} else if (player.ability === 'mechagodzilla') {
player.velocity.y = 12.8;
player.isHovering = true;
SoundController.hover();
} else if (player.ability === 'mosasaurus') {
player.velocity.y = 11.8;
player.isHovering = true;
SoundController.waterSurge();
} else if (player.ability === 'helicopter') {
player.velocity.y = 11.0;
player.isHovering = true;
SoundController.helicopterRotor();
} else if (player.ability === 'fighter') {
player.velocity.y = 12.0;
player.isHovering = true;
SoundController.jetEngine();
} else if (player.ability === 'pteranodon') {
player.velocity.y = 11.5;
player.isHovering = true;
SoundController.pteraFlap();
} else if (player.hoverCount < player.maxHovers) {
player.velocity.y = player.hoverForce;
player.isHovering = true;
player.hoverCount++;
SoundController.hover();
}
}
function playSuperCinematicCutscene(abilityName, callback) {
isCinematicPlaying = true;
activeCinematicAbility = abilityName;
cinematicTime = 0;
cinematicTargetPos.copy(player.position);
const overlay = document.getElementById('cinematic-overlay');
const cineWarning = document.getElementById('cine-warning');
const cineTitle = document.getElementById('cine-title');
const cineSpecs = document.getElementById('cine-specs');
overlay.classList.add('active');
cineTitle.classList.remove('show');
if (abilityName === 'tyranno') {
cineTitle.classList.remove('broly-theme');
cineTitle.classList.remove('magolor-theme');
cineTitle.classList.add('tyranno-theme');
cineWarning.textContent = '⚠ SUPER COPY ABILITY: 白亜紀の絶対捕食者 覚醒 ⚠';
cineWarning.style.color = '#ef4444';
cineTitle.textContent = '⚡ APEX PREDATOR TYRANNOSAURUS ⚡';
cineSpecs.textContent = 'PRIMAL BEAST INSTINCT // CRUSH EVERYTHING IN YOUR JAWS';
SoundController.tyrannoRoar();
setTimeout(() => {
SoundController.tyrannoStomp();
cineTitle.classList.add('show');
}, 850);
setTimeout(() => {
SoundController.tyrannoBite();
SoundController.superFanfare();
}, 1600);
} else if (abilityName === 'magolor') {
cineTitle.classList.remove('broly-theme');
cineTitle.classList.remove('tyranno-theme');
cineTitle.classList.add('magolor-theme');
cineWarning.textContent = '⚠ SUPER COPY ABILITY: 異空間の魔術師 覚醒 ⚠';
cineWarning.style.color = '#c084fc';
cineTitle.textContent = '⚡ MASTER OF DIMENSIONS MAGOLOR ⚡';
cineSpecs.textContent = 'DIMENSION: LOR STARCUTTER // MASTER CROWN PROTOCOL ACTIVE';
SoundController.magolorMagicChime();
setTimeout(() => {
SoundController.dimensionalRift();
cineTitle.classList.add('show');
}, 850);
setTimeout(() => {
SoundController.magolorLaser();
SoundController.superFanfare();
}, 1600);
} else if (abilityName === 'broly') {
cineTitle.classList.remove('magolor-theme');
cineTitle.classList.add('broly-theme');
cineWarning.textContent = '⚠ 警告:伝説の超サイヤ人 覚醒 ⚠';
cineWarning.style.color = '#4ade80';
cineTitle.textContent = '⚡ 伝説の超サイヤ人 ブロリー ⚡';
cineSpecs.textContent = '戦闘力:測定不能 // 手加減など知らぬ!全てを破壊し尽くすのみ!';
SoundController.brolyRoar();
setTimeout(() => {
SoundController.giganticMeteorCharge();
cineTitle.classList.add('show');
}, 850);
setTimeout(() => {
SoundController.kiExplosion();
SoundController.superFanfare();
}, 1600);
} else {
cineTitle.classList.remove('broly-theme');
cineTitle.classList.remove('magolor-theme');
cineWarning.textContent = '⚠ SUPER COPY ABILITY DETECTED ⚠';
cineWarning.style.color = '#38bdf8';
cineTitle.textContent = '⚡ SUPER MECHAGODZILLA ⚡';
cineSpecs.textContent = 'SYSTEM: NT-1 GARUDA MERGE // ALL WEAPONS ONLINE';
SoundController.mechTransform();
setTimeout(() => {
SoundController.megaBusterBeam();
cineTitle.classList.add('show');
}, 850);
setTimeout(() => {
SoundController.superFanfare();
}, 1600);
}
for (let i = 0; i < 22; i++) {
setTimeout(() => {
createSparkleBurst(player.position.clone().add(new THREE.Vector3((Math.random() - 0.5) * 3, Math.random() * 2.5, (Math.random() - 0.5) * 3)));
}, i * 75);
}
setTimeout(() => {
overlay.classList.remove('active');
cineTitle.classList.remove('show');
isCinematicPlaying = false;
if (callback) callback();
}, 2800);
}
function swallowMouthFull() {
if (!player.mouthFull) return;
const item = player.mouthFull;
player.mouthFull = null;
if (typeof item === 'object' && item.ability === 'tyranno') {
SoundController.swallow();
playSuperCinematicCutscene('tyranno', () => {
setPlayerAbility('tyranno');
showMissionToast('🦖 白亜紀の暴君 ティラノサウルス 覚醒!「全ての獲物を噛み砕け!」 🦖');
});
} else if (typeof item === 'object' && item.ability === 'magolor') {
SoundController.swallow();
playSuperCinematicCutscene('magolor', () => {
setPlayerAbility('magolor');
showMissionToast('🌌 虚言の魔術師 マホロア 覚醒!「ボクの魔力で銀河を支配シテアゲルヨォ!」 🌌');
});
} else if (typeof item === 'object' && item.ability === 'broly') {
SoundController.swallow();
playSuperCinematicCutscene('broly', () => {
setPlayerAbility('broly');
showMissionToast('💥 伝説の超サイヤ人 ブロリー 覚醒!「オレがバケモノ?…違う、オレは悪魔だ」 💥');
});
} else if (typeof item === 'object' && item.ability === 'mechagodzilla') {
SoundController.swallow();
playSuperCinematicCutscene('mechagodzilla', () => {
setPlayerAbility('mechagodzilla');
showMissionToast('⚡ SUPER COPY ABILITY: スーパーメカゴジラ 起動! ⚡');
});
} else {
SoundController.swallow();
if (typeof item === 'object' && item.ability) {
setPlayerAbility(item.ability);
}
createSparkleBurst(player.position.clone().add(new THREE.Vector3(0, 1.2, 0)));
}
}
function handleActionPress() {
if (player.mouthFull) {
shootStarProjectile();
player.mouthFull = null;
updateActionButtonsUI();
return;
}
if (player.ability === 'tyranno') {
performTyrannosaurusAttack();
} else if (player.ability === 'magolor') {
performMagolorAttack();
} else if (player.ability === 'broly') {
performBrolyAttack();
} else if (player.ability === 'mechagodzilla') {
performMechagodzillaAttack();
} else if (player.ability === 'mosasaurus') {
performMosasaurusAttack();
} else if (player.ability === 'helicopter') {
performHelicopterAttack();
} else if (player.ability === 'fighter') {
performFighterJetAttack();
} else if (player.ability === 'pteranodon') {
performPteranodonAttack();
} else if (player.ability === 'goku') {
performGokuKamehameha();
} else if (player.ability === 'sword') {
performSwordAttack();
} else if (player.ability === 'fire') {
performFireAttack();
} else if (player.ability === 'cutter') {
performCutterAttack();
} else {
performSlidingKick();
}
}
function shootStarProjectile() {
SoundController.spit();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
const starGeo = createStarShape(0.8, 0.4);
const starMat = new THREE.MeshToonMaterial({ color: 0xffea00, emissive: 0xffaa00, emissiveIntensity: 0.6 });
const starMesh = new THREE.Mesh(starGeo, starMat);
starMesh.position.copy(player.position).add(forwardDir.clone().multiplyScalar(1.4));
scene.add(starMesh);
projectiles.push({
mesh: starMesh,
dir: forwardDir.clone(),
speed: 28.0,
life: 1.8,
damage: 4.0,
type: 'spitStar',
hitRadius: 1.8
});
}
function performTyrannosaurusAttack() {
SoundController.tyrannoRoar();
SoundController.tyrannoBite();
SoundController.tyrannoStomp();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
player.invincibleTimer = 0.75;
player.velocity.x = forwardDir.x * 24.0;
player.velocity.z = forwardDir.z * 24.0;
// 1. Colossal Phantom Jaws Snapping (Gigant Bite)
const jawGroup = new THREE.Group();
const jawMat = new THREE.MeshBasicMaterial({ color: 0xef4444, transparent: true, opacity: 0.85, side: THREE.DoubleSide });
const topPhantom = new THREE.Mesh(new THREE.ConeGeometry(1.8, 3.2, 8), jawMat);
topPhantom.rotation.x = Math.PI / 2;
topPhantom.position.set(0, 0.6, 1.4);
const bottomPhantom = new THREE.Mesh(new THREE.ConeGeometry(1.6, 3.0, 8), jawMat);
bottomPhantom.rotation.x = -Math.PI / 2;
bottomPhantom.position.set(0, -0.6, 1.4);
jawGroup.add(topPhantom, bottomPhantom);
jawGroup.position.copy(player.position).add(forwardDir.clone().multiplyScalar(2.0));
scene.add(jawGroup);
projectiles.push({
mesh: jawGroup,
dir: forwardDir.clone(),
speed: 26.0,
life: 1.25,
damage: 13.5,
type: 'tyrannoBite',
hitRadius: 3.5
});
// 2. Earth-shattering Roar Tremor Shockwave
const tremorRing = new THREE.Mesh(
new THREE.RingGeometry(1.0, 4.5, 24),
new THREE.MeshBasicMaterial({ color: 0xf97316, side: THREE.DoubleSide, transparent: true, opacity: 0.9 })
);
tremorRing.rotation.x = -Math.PI / 2;
tremorRing.position.copy(player.position);
scene.add(tremorRing);
projectiles.push({
mesh: tremorRing,
dir: new THREE.Vector3(0, 0, 0),
speed: 0,
life: 0.55,
damage: 5.0,
type: 'shockwave',
hitRadius: 4.2
});
// 3. Volcanic Magma Fang Projectiles Spread
for (let f = 0; f < 4; f++) {
setTimeout(() => {
const rock = new THREE.Mesh(
new THREE.ConeGeometry(0.5, 1.2, 6),
new THREE.MeshToonMaterial({ color: 0xdc2626, emissive: 0xb91c1c, emissiveIntensity: 0.6 })
);
rock.rotation.x = Math.PI / 2;
const spread = (f - 1.5) * 0.24;
const rDir = forwardDir.clone().applyAxisAngle(new THREE.Vector3(0, 1, 0), spread);
rock.position.copy(player.position).add(new THREE.Vector3(0, 0.8, 1.2).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY));
scene.add(rock);
projectiles.push({
mesh: rock,
dir: rDir,
speed: 34.0,
life: 1.1,
damage: 4.2,
type: 'magmaFang',
hitRadius: 2.0
});
}, f * 70);
}
}
function performMagolorAttack() {
SoundController.dimensionalRift();
SoundController.magolorLaser();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
player.invincibleTimer = 0.7;
// 1. Black Hole / Dimensional Rift Vortex
const riftGroup = new THREE.Group();
const blackHoleCore = new THREE.Mesh(
new THREE.SphereGeometry(1.2, 16, 16),
new THREE.MeshBasicMaterial({ color: 0x1e1b4b })
);
const accretionDisk = new THREE.Mesh(
new THREE.RingGeometry(1.4, 2.8, 24),
new THREE.MeshBasicMaterial({ color: 0xd946ef, side: THREE.DoubleSide, transparent: true, opacity: 0.85 })
);
accretionDisk.rotation.x = -Math.PI / 3;
const outerRing = new THREE.Mesh(
new THREE.TorusGeometry(2.6, 0.12, 8, 24),
new THREE.MeshBasicMaterial({ color: 0xfacc15 })
);
riftGroup.add(blackHoleCore, accretionDisk, outerRing);
riftGroup.position.copy(player.position).add(forwardDir.clone().multiplyScalar(2.2));
scene.add(riftGroup);
projectiles.push({
mesh: riftGroup,
dir: forwardDir.clone(),
speed: 24.0,
life: 1.3,
damage: 13.0,
type: 'magolorRift',
hitRadius: 3.5
});
// 2. Kill Needle / Dimensional Magic Star Spheres Barrage
for (let s = 0; s < 5; s++) {
setTimeout(() => {
const starGeo = createStarShape(0.45, 0.22);
const starMesh = new THREE.Mesh(
starGeo,
new THREE.MeshToonMaterial({ color: 0xc084fc, emissive: 0xa855f7, emissiveIntensity: 0.6 })
);
const spreadAngle = (s - 2) * 0.18;
const sDir = forwardDir.clone().applyAxisAngle(new THREE.Vector3(0, 1, 0), spreadAngle);
starMesh.position.copy(player.position).add(new THREE.Vector3(0, 0.9, 1.2).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY));
scene.add(starMesh);
projectiles.push({
mesh: starMesh,
dir: sDir,
speed: 36.0,
life: 1.1,
damage: 3.8,
type: 'magolorStar',
hitRadius: 1.8
});
}, s * 60);
}
}
function performBrolyAttack() {
SoundController.giganticMeteorCharge();
SoundController.kiExplosion();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
player.invincibleTimer = 0.7;
// 1. Gigantic Meteor: Colossal Emerald Sphere of Cataclysm
const meteorGeo = new THREE.SphereGeometry(1.4, 20, 20);
const meteorMat = new THREE.MeshBasicMaterial({
color: 0x4ade80,
wireframe: false
});
const meteor = new THREE.Mesh(meteorGeo, meteorMat);
meteor.position.copy(player.position).add(forwardDir.clone().multiplyScalar(2.2));
scene.add(meteor);
// Glowing Emerald Aura Shell
const auraShell = new THREE.Mesh(
new THREE.SphereGeometry(1.9, 16, 16),
new THREE.MeshBasicMaterial({ color: 0x22c55e, transparent: true, opacity: 0.55 })
);
meteor.add(auraShell);
projectiles.push({
mesh: meteor,
dir: forwardDir.clone(),
speed: 26.0,
life: 1.2,
damage: 12.0,
type: 'giganticMeteor',
hitRadius: 3.4
});
// 2. Eraser Cannon Multi-Barrage
for (let b = 0; b < 4; b++) {
setTimeout(() => {
const eraser = new THREE.Mesh(
new THREE.SphereGeometry(0.55, 12, 12),
new THREE.MeshBasicMaterial({ color: 0x86efac })
);
const spreadAngle = (b - 1.5) * 0.22;
const bDir = forwardDir.clone().applyAxisAngle(new THREE.Vector3(0, 1, 0), spreadAngle);
eraser.position.copy(player.position).add(new THREE.Vector3(0, 0.6, 1.2).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY));
scene.add(eraser);
projectiles.push({
mesh: eraser,
dir: bDir,
speed: 35.0,
life: 1.1,
damage: 4.5,
type: 'eraserCannon',
hitRadius: 2.0
});
}, b * 70);
}
}
function performMechagodzillaAttack() {
SoundController.megaBusterBeam();
SoundController.plasmaGrenade();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
player.invincibleTimer = 0.65;
// Dual Mega-Buster Beams
[-0.65, 0.65].forEach(xOffset => {
const beamGeo = new THREE.CylinderGeometry(0.35, 0.45, 18.0, 16);
const beamMat = new THREE.MeshBasicMaterial({ color: 0x00f5ff, transparent: true, opacity: 0.95 });
const beam = new THREE.Mesh(beamGeo, beamMat);
beam.rotation.x = Math.PI / 2;
const offsetVec = new THREE.Vector3(xOffset, 0.6, 9.0).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
beam.position.copy(player.position).add(offsetVec);
scene.add(beam);
projectiles.push({
mesh: beam,
dir: forwardDir.clone(),
speed: 28.0,
life: 0.75,
damage: 8.5,
type: 'megaBuster',
hitRadius: 2.5
});
});
// Multi Plasma Grenade Volley
for (let g = 0; g < 3; g++) {
setTimeout(() => {
const grenade = new THREE.Mesh(
new THREE.SphereGeometry(0.65, 12, 12),
new THREE.MeshBasicMaterial({ color: 0xf59e0b })
);
const spreadAngle = (g - 1) * 0.25;
const gDir = forwardDir.clone().applyAxisAngle(new THREE.Vector3(0, 1, 0), spreadAngle);
grenade.position.copy(player.position).add(new THREE.Vector3(0, 0.8, 1.2).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY));
scene.add(grenade);
projectiles.push({
mesh: grenade,
dir: gDir,
speed: 34.0,
life: 1.2,
damage: 5.5,
type: 'plasmaGrenade',
hitRadius: 2.2
});
}, g * 80);
}
}
function performFighterJetAttack() {
SoundController.missileLaunch();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
player.invincibleTimer = 0.5;
player.velocity.x = forwardDir.x * 26.0;
player.velocity.z = forwardDir.z * 26.0;
[-0.8, 0.8].forEach(xOff => {
const missile = new THREE.Mesh(
new THREE.CylinderGeometry(0.18, 0.18, 1.1, 8),
new THREE.MeshToonMaterial({ color: 0xef4444 })
);
missile.rotation.x = Math.PI / 2;
missile.position.copy(player.position).add(new THREE.Vector3(xOff, 0.4, 0.5).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY));
scene.add(missile);
projectiles.push({
mesh: missile,
dir: forwardDir.clone(),
speed: 32.0,
life: 1.5,
damage: 3.5,
type: 'missile',
hitRadius: 1.6
});
});
}
function performHelicopterAttack() {
SoundController.gatlingFire();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
for (let i = 0; i < 4; i++) {
setTimeout(() => {
const bullet = new THREE.Mesh(
new THREE.SphereGeometry(0.24, 8, 8),
new THREE.MeshBasicMaterial({ color: 0xfbbf24 })
);
const side = (i % 2 === 0 ? -0.7 : 0.7);
bullet.position.copy(player.position).add(new THREE.Vector3(side, 0.3, 0.8).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY));
scene.add(bullet);
projectiles.push({
mesh: bullet,
dir: forwardDir.clone(),
speed: 36.0,
life: 1.2,
damage: 1.5,
type: 'gatling',
hitRadius: 1.2
});
}, i * 65);
}
}
function performMosasaurusAttack() {
SoundController.mosasaurRoar();
SoundController.chompBite();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
player.invincibleTimer = 0.55;
player.velocity.x = forwardDir.x * 24.0;
player.velocity.z = forwardDir.z * 24.0;
const wave = new THREE.Mesh(
new THREE.RingGeometry(0.8, 3.2, 16),
new THREE.MeshBasicMaterial({ color: 0x06b6d4, side: THREE.DoubleSide, transparent: true, opacity: 0.85 })
);
wave.rotation.x = -Math.PI / 2;
wave.position.copy(player.position);
scene.add(wave);
projectiles.push({
mesh: wave,
dir: forwardDir.clone(),
speed: 18.0,
life: 0.6,
damage: 4.5,
type: 'tsunami',
hitRadius: 2.8
});
}
function performPteranodonAttack() {
if (!player.isGrounded) {
SoundController.pteraRoar();
player.isPteraDiving = true;
player.velocity.y = -35.0;
} else {
SoundController.tornadoGust();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
const gust = new THREE.Mesh(
new THREE.ConeGeometry(1.2, 2.5, 12),
new THREE.MeshBasicMaterial({ color: 0x67e8f9, wireframe: true })
);
gust.rotation.x = Math.PI / 2;
gust.position.copy(player.position).add(forwardDir.clone().multiplyScalar(1.5));
scene.add(gust);
projectiles.push({
mesh: gust,
dir: forwardDir.clone(),
speed: 22.0,
life: 1.2,
damage: 3.0,
type: 'tornado',
hitRadius: 2.0
});
}
}
function performGokuKamehameha() {
SoundController.kamehameha();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
const beam = new THREE.Mesh(
new THREE.CylinderGeometry(0.9, 0.9, 8.0, 16),
new THREE.MeshBasicMaterial({ color: 0x60a5fa, transparent: true, opacity: 0.9 })
);
beam.rotation.x = Math.PI / 2;
beam.position.copy(player.position).add(forwardDir.clone().multiplyScalar(4.5));
scene.add(beam);
projectiles.push({
mesh: beam,
dir: forwardDir.clone(),
speed: 20.0,
life: 0.7,
damage: 8.0,
type: 'kamehameha',
hitRadius: 2.6
});
}
function performInstantTransmission() {
SoundController.instantTransmission();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
createSparkleBurst(player.position);
player.position.add(forwardDir.multiplyScalar(9.0));
createSparkleBurst(player.position);
player.invincibleTimer = 0.4;
}
function performSlidingKick() {
SoundController.jump();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
player.invincibleTimer = 0.45;
player.velocity.x = forwardDir.x * 22.0;
player.velocity.z = forwardDir.z * 22.0;
if (player.isGrounded) player.velocity.y = 2.5;
const dust = new THREE.Mesh(
new THREE.SphereGeometry(0.65, 8, 8),
new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, opacity: 0.8 })
);
dust.position.copy(player.position).add(forwardDir.clone().multiplyScalar(0.8));
scene.add(dust);
projectiles.push({
mesh: dust,
dir: forwardDir.clone(),
speed: 20.0,
life: 0.35,
damage: 2.5,
type: 'slide',
hitRadius: 1.6
});
}
function performSwordAttack() {
SoundController.swordSlash();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
const wave = new THREE.Mesh(new THREE.TorusGeometry(1.2, 0.15, 8, 16, Math.PI), new THREE.MeshBasicMaterial({ color: 0x48c74c }));
wave.rotation.x = Math.PI / 2;
wave.rotation.z = player.currentRotationY - Math.PI / 2;
wave.position.copy(player.position).add(forwardDir.clone().multiplyScalar(1.0));
scene.add(wave);
projectiles.push({ mesh: wave, dir: forwardDir.clone(), speed: 22.0, life: 0.8, damage: 2.0, type: 'sword', hitRadius: 1.5 });
}
function performFireAttack() {
SoundController.fireBreath();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
const flame = new THREE.Mesh(new THREE.SphereGeometry(0.55, 12, 12), new THREE.MeshToonMaterial({ color: 0xff4500, emissive: 0xff3300, emissiveIntensity: 0.8 }));
flame.position.copy(player.position).add(forwardDir.clone().multiplyScalar(1.2));
scene.add(flame);
projectiles.push({ mesh: flame, dir: forwardDir.clone(), speed: 22.0, life: 0.9, damage: 1.8, type: 'fire', hitRadius: 1.4 });
}
function performCutterAttack() {
SoundController.cutterThrow();
const forwardDir = new THREE.Vector3(0, 0, 1).applyAxisAngle(new THREE.Vector3(0, 1, 0), player.currentRotationY);
const blade = new THREE.Mesh(new THREE.CylinderGeometry(0.6, 0.6, 0.08, 3), new THREE.MeshToonMaterial({ color: 0xffd700, emissive: 0xffaa00, emissiveIntensity: 0.6 }));
blade.position.copy(player.position).add(forwardDir.clone().multiplyScalar(1.2));
scene.add(blade);
projectiles.push({ mesh: blade, dir: forwardDir.clone(), speed: 24.0, life: 1.6, isReturning: false, damage: 2.0, type: 'cutter', hitRadius: 1.3 });
}
let walkAnimClock = 0;
let inhaleSoundCooldown = 0;
function updateActionButtonsUI() {
const actionTop = document.getElementById('m-action-top');
const actionSub = document.getElementById('m-action-sub');
if (player.mouthFull) {
actionTop.textContent = 'はきだし';
actionSub.textContent = '★スター弾';
} else {
actionTop.textContent = 'すいこみ';
actionSub.textContent = '長押し';
}
}
function checkGoalStarUnlock() {
if (!goalObject || goalObject.unlocked) return;
const allIslandsDone = (visitedIslandsCount >= totalIslandsCount);
const bossDefeated = (!boss || !boss.alive);
if (allIslandsDone && bossDefeated) {
goalObject.unlocked = true;
goalObject.mesh.visible = true;
SoundController.allIslandsUnlocked();
showMissionToast('🌟 全島踏破&大ボス撃破!ゴールスター降臨! 🌟');
createSparkleBurst(goalObject.pos);
}
}
function updatePlayer(delta) {
if (!kirby) return;
if (isCinematicPlaying) {
cinematicTime += delta;
const orbitRadius = 6.0 - Math.min(2.5, cinematicTime * 0.8);
const orbitAngle = cinematicTime * 3.5;
camera.position.x = cinematicTargetPos.x + Math.sin(orbitAngle) * orbitRadius;
camera.position.z = cinematicTargetPos.z + Math.cos(orbitAngle) * orbitRadius;
camera.position.y = cinematicTargetPos.y + 2.2 + Math.sin(cinematicTime * 2.0) * 0.5;
camera.lookAt(cinematicTargetPos.x, cinematicTargetPos.y + 1.2, cinematicTargetPos.z);
kirby.rotation.y += 6.0 * delta;
if (activeCinematicAbility === 'tyranno' && tyrannoGroup) {
tyrannoGroup.visible = true;
if (tyrannoEmberParticles) tyrannoEmberParticles.rotation.y += 12.0 * delta;
if (tyrannoUpperJaw) tyrannoUpperJaw.rotation.x = Math.sin(cinematicTime * 12.0) * 0.25 - 0.15;
if (tyrannoLowerJaw) tyrannoLowerJaw.rotation.x = -Math.sin(cinematicTime * 12.0) * 0.25 + 0.15;
} else if (activeCinematicAbility === 'magolor' && magolorGroup) {
magolorGroup.visible = true;
if (magolorAuraParticles) {
magolorAuraParticles.rotation.y += 12.0 * delta;
}
if (magolorCrownMesh) {
magolorCrownMesh.rotation.y += 8.0 * delta;
}
} else if (activeCinematicAbility === 'broly' && brolyGroup) {
brolyGroup.visible = true;
if (brolyAuraParticles) {
brolyAuraParticles.rotation.y += 12.0 * delta;
}
} else if (superMechagodzillaGroup) {
superMechagodzillaGroup.visible = true;
mechaGarudaBackpack.position.y = 0.6 + Math.sin(cinematicTime * 8) * 0.15;
}
return;
}
player.isInhaling = (keys.actionInhale && !player.mouthFull);
if (player.isInhaling) {
inhaleSoundCooldown -= delta;
if (inhaleSoundCooldown <= 0) {
SoundController.inhale();
inhaleSoundCooldown = 0.16;
}
mouthMesh.scale.set(1.4, 1.4, 0.7);
if (suctionParticles) {
suctionParticles.material.opacity = 0.85;
suctionParticles.rotation.z += 10.0 * delta;
}
} else {
mouthMesh.scale.set(0.9, 0.5, 0.3);
if (suctionParticles) {
suctionParticles.material.opacity = 0.0;
}
}
if (player.mouthFull) {
kirbyBodyMesh.scale.set(1.25, 1.25, 1.25);
} else {
kirbyBodyMesh.scale.set(1.0, 1.0, 1.0);
}
if (!isFinite(player.position.x) || !isFinite(player.position.y) || !isFinite(player.position.z)) {
player.position.copy(lastSafeIslandPos);
player.velocity.set(0, 0, 0);
}
if (player.invincibleTimer > 0) {
player.invincibleTimer -= delta;
kirby.visible = Math.floor(Date.now() / 60) % 2 === 0;
} else {
kirby.visible = true;
}
const moveDir = new THREE.Vector3(0, 0, 0);
if (keys.forward) moveDir.z -= 1;
if (keys.backward) moveDir.z += 1;
if (keys.left) moveDir.x -= 1;
if (keys.right) moveDir.x += 1;
const isMoving = moveDir.lengthSq() > 0.01;
const currentSpeed = (player.ability === 'fighter' && player.isHovering) ? player.speed * 1.55 : player.speed;
if (isMoving) {
moveDir.normalize();
player.targetRotationY = Math.atan2(moveDir.x, moveDir.z);
player.position.x += moveDir.x * currentSpeed * delta;
player.position.z += moveDir.z * currentSpeed * delta;
}
let diff = player.targetRotationY - player.currentRotationY;
while (diff < -Math.PI) diff += Math.PI * 2;
while (diff > Math.PI) diff -= Math.PI * 2;
player.currentRotationY += diff * Math.min(1.0, 16.0 * delta);
kirby.rotation.y = player.currentRotationY;
if (player.ability === 'tyranno') {
if (tyrannoEmberParticles) tyrannoEmberParticles.rotation.y += 8.0 * delta;
if (tyrannoTail) tyrannoTail.rotation.y = Math.sin(Date.now() * 0.008) * 0.45;
if (player.isHovering) {
player.velocity.y -= player.gravity * 0.1 * delta;
player.velocity.y = Math.max(player.velocity.y, -1.2);
}
} else if (player.ability === 'magolor') {
if (magolorAuraParticles) {
magolorAuraParticles.rotation.y += 8.0 * delta;
}
if (magolorHands.length === 2) {
const wave = Math.sin(Date.now() * 0.006) * 0.18;
magolorHands[0].position.y = 0.3 + wave;
magolorHands[1].position.y = 0.3 - wave;
}
if (player.isHovering) {
player.velocity.y -= player.gravity * 0.1 * delta;
player.velocity.y = Math.max(player.velocity.y, -1.2);
}
} else if (player.ability === 'broly') {
if (brolyAuraParticles) {
brolyAuraParticles.rotation.y += 6.0 * delta;
}
if (player.isHovering) {
player.velocity.y -= player.gravity * 0.1 * delta;
player.velocity.y = Math.max(player.velocity.y, -1.2);
}
} else if (player.ability === 'mechagodzilla' && player.isHovering) {
player.velocity.y -= player.gravity * 0.12 * delta;
player.velocity.y = Math.max(player.velocity.y, -1.5);
mechaThrusters.forEach(t => {
t.scale.set(1.0 + Math.random() * 0.5, 1.2 + Math.random() * 0.6, 1.0);
});
} else if (player.ability === 'mosasaurus' && player.isHovering) {
player.velocity.y -= player.gravity * 0.2 * delta;
player.velocity.y = Math.max(player.velocity.y, -2.2);
} else if (player.ability === 'helicopter' && player.isHovering) {
player.velocity.y -= player.gravity * 0.15 * delta;
player.velocity.y = Math.max(player.velocity.y, -1.8);
} else if (player.ability === 'fighter' && player.isHovering) {
player.velocity.y -= player.gravity * 0.18 * delta;
player.velocity.y = Math.max(player.velocity.y, -2.0);
} else if (player.ability === 'pteranodon' && !player.isGrounded && !player.isPteraDiving) {
player.velocity.y -= player.gravity * 0.22 * delta;
player.velocity.y = Math.max(player.velocity.y, -2.8);
} else if (player.isHovering) {
player.velocity.y -= player.gravity * 0.42 * delta;
player.velocity.y = Math.max(player.velocity.y, -4.5);
} else {
player.velocity.y -= player.gravity * delta;
}
const prevY = player.position.y;
player.position.y += player.velocity.y * delta;
player.position.x = Math.max(-24, Math.min(24, player.position.x));
player.position.z = Math.min(7, player.position.z);
let minStageZ = -360;
if (goalObject && goalObject.pos) {
minStageZ = goalObject.pos.z - 16;
}
player.position.z = Math.max(minStageZ, player.position.z);
// Island Landing & Checkpoint Resolution
player.isGrounded = false;
for (let i = 0; i < colliders.length; i++) {
const c = colliders[i];
let islandX = c.minX + c.width / 2;
let islandZ = c.minZ + c.depth / 2;
if (c.mesh) {
islandX = c.mesh.position.x;
islandZ = c.mesh.position.z;
}
const halfW = c.width / 2 + 0.8;
const halfD = c.depth / 2 + 0.8;
if (
player.position.x >= islandX - halfW &&
player.position.x <= islandX + halfW &&
player.position.z >= islandZ - halfD &&
player.position.z <= islandZ + halfD
) {
const targetFloor = c.topY + 1.0;
if (prevY >= targetFloor - 3.8 && player.position.y <= targetFloor + 0.9 && player.velocity.y <= 0) {
player.position.y = targetFloor;
player.velocity.y = 0;
player.isGrounded = true;
player.isHovering = false;
player.hoverCount = 0;
if (c.isMoving && c.mesh && c.mesh.userData.deltaX !== undefined) {
player.position.x += c.mesh.userData.deltaX;
player.position.z += c.mesh.userData.deltaZ;
}
lastSafeIslandPos.set(islandX, targetFloor, islandZ);
// Checkpoint landing on this island
const matchingIsland = stageIslands[i];
if (matchingIsland && !matchingIsland.visited) {
matchingIsland.visited = true;
visitedIslandsCount++;
matchingIsland.beaconOrb.material.color.setHex(0x22c55e);
matchingIsland.beaconOrb.scale.set(1.4, 1.4, 1.4);
SoundController.checkpointChime();
createSparkleBurst(matchingIsland.beaconOrb.position.clone().add(c.mesh.position));
updateIslandTrackerUI();
showMissionToast('🚩 島をチェック (' + visitedIslandsCount + '/' + totalIslandsCount + ')');
checkGoalStarUnlock();
}
break;
}
}
}
// Pit Respawn
if (player.position.y < -4.5) {
damagePlayer(20);
player.position.copy(lastSafeIslandPos);
player.velocity.set(0, 0, 0);
player.isHovering = false;
keys.actionInhale = false;
player.isInhaling = false;
camera.position.set(player.position.x, player.position.y + 6.5, player.position.z + 13.0);
camera.lookAt(player.position.x, player.position.y + 0.8, player.position.z);
}
if (player.isPteraDiving && player.isGrounded) {
player.isPteraDiving = false;
SoundController.diveImpact();
createSparkleBurst(player.position);
const shockwave = new THREE.Mesh(
new THREE.RingGeometry(0.8, 2.8, 16),
new THREE.MeshBasicMaterial({ color: 0xff3b75, side: THREE.DoubleSide })
);
shockwave.rotation.x = -Math.PI / 2;
shockwave.position.copy(player.position);
scene.add(shockwave);
projectiles.push({
mesh: shockwave,
dir: new THREE.Vector3(0, 0, 0),
speed: 0,
life: 0.35,
damage: 4.0,
type: 'shockwave',
hitRadius: 2.8
});
}
if (isMoving && player.isGrounded) {
walkAnimClock += delta * 15;
leftFoot.position.z = 0.15 + Math.sin(walkAnimClock) * 0.35;
rightFoot.position.z = 0.15 - Math.sin(walkAnimClock) * 0.35;
kirbyBodyMesh.position.y = Math.abs(Math.sin(walkAnimClock)) * 0.12;
} else {
leftFoot.position.set(-0.48, -0.75, 0.15);
rightFoot.position.set(0.48, -0.75, 0.15);
kirbyBodyMesh.position.y = Math.sin(Date.now() * 0.003) * 0.05;
}
kirby.position.copy(player.position);
if (lightTarget) lightTarget.position.copy(player.position);
if (dirLight) dirLight.position.set(player.position.x + 20, player.position.y + 45, player.position.z + 25);
const targetCamX = player.position.x * 0.75;
const targetCamY = player.position.y + 6.0;
const targetCamZ = player.position.z + 12.5;
camera.position.x = THREE.MathUtils.lerp(camera.position.x, targetCamX, 0.18);
camera.position.y = THREE.MathUtils.lerp(camera.position.y, targetCamY, 0.18);
camera.position.z = THREE.MathUtils.lerp(camera.position.z, targetCamZ, 0.18);
camera.lookAt(player.position.x, player.position.y + 0.8, player.position.z);
}
function damageBoss(damageAmount) {
if (!boss || !boss.alive) return;
boss.hp = Math.max(0, boss.hp - damageAmount);
const hpPct = Math.round((boss.hp / boss.maxHp) * 100);
document.getElementById('boss-hp-fill').style.width = hpPct + '%';
document.getElementById('boss-hp-pct').textContent = hpPct + '%';
boss.mesh.position.y += 0.3;
createSparkleBurst(boss.mesh.position);
SoundController.hit();
if (boss.hp <= 0) {
boss.alive = false;
SoundController.win();
for (let b = 0; b < 18; b++) {
setTimeout(() => {
createSparkleBurst(boss.mesh.position.clone().add(new THREE.Vector3((Math.random() - 0.5) * 5, Math.random() * 4, (Math.random() - 0.5) * 5)));
}, b * 60);
}
scene.remove(boss.mesh);
document.getElementById('boss-hud').style.display = 'none';
addScore(3000);
showMissionToast('🏆 巨獣大王 ギガ・ハンマー撃破!');
checkGoalStarUnlock();
}
}
function updateBossAI(delta) {
if (!boss || !boss.alive) return;
const toPlayer = kirby.position.clone().sub(boss.mesh.position);
const dist = toPlayer.length();
boss.timer += delta;
boss.hammer.rotation.x = Math.sin(boss.timer * 4.0) * 0.4;
// Follow player slightly when within range
if (dist < 26.0) {
toPlayer.y = 0;
toPlayer.normalize();
boss.mesh.position.addScaledVector(toPlayer, 2.5 * delta);
boss.attackCooldown -= delta;
if (boss.attackCooldown <= 0) {
boss.attackCooldown = 3.2 + Math.random() * 1.5;
SoundController.turretFire();
// Fire 3 dark energy shots
for (let b = -1; b <= 1; b++) {
const bDir = toPlayer.clone().applyAxisAngle(new THREE.Vector3(0, 1, 0), b * 0.25);
const bulletMesh = new THREE.Mesh(
new THREE.SphereGeometry(0.5, 10, 10),
new THREE.MeshBasicMaterial({ color: 0x7c3aed })
);
bulletMesh.position.copy(boss.mesh.position).add(new THREE.Vector3(0, 1.2, 0));
scene.add(bulletMesh);
enemyProjectiles.push({
mesh: bulletMesh,
dir: bDir,
speed: 16.0,
life: 3.5
});
}
}
// Giant Ground Slam Shockwave
boss.shockwaveCooldown -= delta;
if (boss.shockwaveCooldown <= 0) {
boss.shockwaveCooldown = 5.0 + Math.random() * 2.0;
SoundController.bossRoar();
SoundController.bossSlam();
const slamRing = new THREE.Mesh(
new THREE.RingGeometry(1.2, 8.5, 24),
new THREE.MeshBasicMaterial({ color: 0xef4444, side: THREE.DoubleSide, transparent: true, opacity: 0.85 })
);
slamRing.rotation.x = -Math.PI / 2;
slamRing.position.copy(boss.mesh.position);
slamRing.position.y = boss.baseY - 2.0;
scene.add(slamRing);
enemyProjectiles.push({
mesh: slamRing,
dir: new THREE.Vector3(0, 0, 0),
speed: 0,
life: 0.65,
isShockwave: true
});
}
}
// Direct boss contact damage
if (dist < 3.2 && player.invincibleTimer <= 0) {
damagePlayer(25);
player.velocity.y = 8.0;
player.velocity.z = 8.0;
}
}
function updateEntities(delta) {
const timeNow = performance.now() * 0.001;
// 1. Moving Platforms
movingPlatforms.forEach(p => {
const offset = Math.sin(timeNow * p.speed + p.phase) * p.dist;
const oldX = p.mesh.position.x;
const oldZ = p.mesh.position.z;
if (p.axis === 'x') {
p.mesh.position.x = p.baseX + offset;
} else if (p.axis === 'z') {
p.mesh.position.z = p.baseZ + offset;
}
p.mesh.userData.deltaX = p.mesh.position.x - oldX;
p.mesh.userData.deltaZ = p.mesh.position.z - oldZ;
});
// 2. Hazards
hazards.forEach(h => {
if (h.type === 'gordo') {
const gOffset = Math.sin(timeNow * h.speed) * h.range;
if (h.axis === 'x') h.mesh.position.x = h.baseX + gOffset;
else if (h.axis === 'y') h.mesh.position.y = h.baseY + gOffset;
else h.mesh.position.z = h.baseZ + gOffset;
h.mesh.rotation.y += 2.0 * delta;
h.mesh.rotation.z += 1.5 * delta;
if (kirby.position.distanceTo(h.mesh.position) < h.radius && player.invincibleTimer <= 0) {
damagePlayer(35);
SoundController.spikeHit();
player.velocity.y = 9.0;
player.velocity.z = 8.0;
}
} else if (h.type === 'spike') {
if (kirby.position.distanceTo(h.pos) < h.radius && player.isGrounded && player.invincibleTimer <= 0) {
damagePlayer(30);
SoundController.spikeHit();
player.velocity.y = 8.0;
}
}
});
// 3. Collectables
collectables.forEach(c => {
if (c.collected) return;
c.mesh.rotation.y += 2.0 * delta;
c.mesh.position.y = c.baseY + Math.sin(Date.now() * 0.004 + c.mesh.position.x) * 0.25;
if (player.isInhaling) {
const toKirby = kirby.position.clone().sub(c.mesh.position);
const dist = toKirby.length();
if (dist < 7.5 && dist > 0.001) {
c.mesh.position.add(toKirby.normalize().multiplyScalar(15.0 * delta));
if (dist < 1.4) {
c.collected = true;
scene.remove(c.mesh);
player.mouthFull = c.type;
keys.actionInhale = false;
player.isInhaling = false;
updateActionButtonsUI();
SoundController.starCollect();
addScore(200);
}
}
}
if (!c.collected && c.mesh.position.distanceTo(kirby.position) < 1.6) {
c.collected = true;
scene.remove(c.mesh);
SoundController.starCollect();
addScore(100);
createSparkleBurst(c.mesh.position);
}
});
// 4. Regular Enemies & Inhaling
enemies.forEach(e => {
if (!e.alive) return;
if (e.isTurret) {
e.fireCooldown -= delta;
if (e.fireCooldown <= 0) {
e.fireCooldown = 2.4 + Math.random() * 1.2;
SoundController.turretFire();
const toKirby = kirby.position.clone().sub(e.mesh.position).normalize();
const bulletMesh = new THREE.Mesh(
new THREE.SphereGeometry(0.35, 8, 8),
new THREE.MeshBasicMaterial({ color: 0xef4444 })
);
bulletMesh.position.copy(e.mesh.position).add(new THREE.Vector3(0, 0.4, 0));
scene.add(bulletMesh);
enemyProjectiles.push({
mesh: bulletMesh,
dir: toKirby,
speed: 14.0,
life: 3.5
});
}
} else {
e.mesh.position.x += e.dir * e.speed * delta;
if (Math.abs(e.mesh.position.x - e.startX) > e.range) {
e.dir *= -1;
e.mesh.rotation.y = e.dir > 0 ? 0 : Math.PI;
}
}
const toKirby = kirby.position.clone().sub(e.mesh.position);
const distToKirby = toKirby.length();
if (player.isInhaling) {
if (distToKirby < 8.5 && distToKirby > 0.001) {
e.isBeingInhaled = true;
e.mesh.position.add(toKirby.clone().normalize().multiplyScalar(16.0 * delta));
if (distToKirby < 1.9) {
e.alive = false;
scene.remove(e.mesh);
player.mouthFull = { type: 'enemy', ability: e.ability };
keys.actionInhale = false;
player.isInhaling = false;
updateActionButtonsUI();
SoundController.starCollect();
addScore(300);
setTimeout(() => {
if (player.mouthFull && player.mouthFull.type === 'enemy') {
swallowMouthFull();
updateActionButtonsUI();
}
}, 1000);
return;
}
}
} else {
e.isBeingInhaled = false;
}
if (!e.isBeingInhaled && !player.isInhaling && distToKirby < 1.3 && player.invincibleTimer <= 0) {
damagePlayer(20);
player.velocity.y = 7.0;
player.velocity.z = 4.0;
}
});
// 5. Boss AI Update
updateBossAI(delta);
// 6. Enemy Projectiles
for (let epIdx = enemyProjectiles.length - 1; epIdx >= 0; epIdx--) {
const ep = enemyProjectiles[epIdx];
ep.life -= delta;
ep.mesh.position.add(ep.dir.clone().multiplyScalar(ep.speed * delta));
if (ep.isShockwave) {
ep.mesh.scale.multiplyScalar(1.0 + 3.0 * delta);
if (ep.mesh.position.distanceTo(kirby.position) < (ep.mesh.scale.x * 4.2) && player.isGrounded && player.invincibleTimer <= 0) {
damagePlayer(28);
SoundController.spikeHit();
player.velocity.y = 10.0;
}
} else if (ep.mesh.position.distanceTo(kirby.position) < 1.2 && player.invincibleTimer <= 0) {
damagePlayer(20);
scene.remove(ep.mesh);
enemyProjectiles.splice(epIdx, 1);
continue;
}
if (ep.life <= 0) {
scene.remove(ep.mesh);
enemyProjectiles.splice(epIdx, 1);
}
}
// 7. Player Projectiles against Enemies and Boss
for (let i = projectiles.length - 1; i >= 0; i--) {
const p = projectiles[i];
p.life -= delta;
p.mesh.position.add(p.dir.clone().multiplyScalar(p.speed * delta));
p.mesh.rotation.z += 12 * delta;
const hitRadius = p.hitRadius || 1.4;
enemies.forEach(e => {
if (e.alive && p.mesh.position.distanceTo(e.mesh.position) < hitRadius + 0.6) {
e.alive = false;
scene.remove(e.mesh);
if (p.type !== 'kamehameha' && p.type !== 'megaBuster' && p.type !== 'giganticMeteor' && p.type !== 'magolorRift' && p.type !== 'tyrannoBite') p.life = 0;
createSparkleBurst(e.mesh.position);
SoundController.hit();
addScore(500);
}
});
// Hit Big Boss
if (boss && boss.alive && p.mesh.position.distanceTo(boss.mesh.position) < hitRadius + 2.2) {
damageBoss(p.damage || 2.0);
if (p.type !== 'kamehameha' && p.type !== 'megaBuster' && p.type !== 'giganticMeteor' && p.type !== 'magolorRift' && p.type !== 'tyrannoBite') p.life = 0;
createSparkleBurst(p.mesh.position);
SoundController.hit();
addScore(150);
}
if (p.life <= 0) {
scene.remove(p.mesh);
projectiles.splice(i, 1);
}
}
// 8. Goal Warp Star Check
if (goalObject && goalObject.unlocked && !goalObject.cleared) {
goalObject.starMesh.rotation.y += 2.0 * delta;
goalObject.starMesh.rotation.z = Math.sin(Date.now() * 0.003) * 0.2;
if (kirby.position.distanceTo(goalObject.pos) < 3.5) {
triggerStageClear();
}
}
}
function createSparkleBurst(pos) {
const burstCount = 12;
for (let i = 0; i < burstCount; i++) {
const sGeo = new THREE.SphereGeometry(0.14, 8, 8);
const sMat = new THREE.MeshBasicMaterial({ color: 0xffea00 });
const sparkle = new THREE.Mesh(sGeo, sMat);
sparkle.position.copy(pos);
scene.add(sparkle);
const v = new THREE.Vector3(
(Math.random() - 0.5) * 6,
(Math.random() - 0.2) * 6,
(Math.random() - 0.5) * 6
);
let elapsed = 0;
const anim = () => {
elapsed += 0.02;
sparkle.position.addScaledVector(v, 0.02);
sparkle.scale.multiplyScalar(0.92);
if (elapsed < 0.4) requestAnimationFrame(anim);
else scene.remove(sparkle);
};
anim();
}
}
function addScore(points) {
player.score += points;
document.getElementById('score-text').textContent = player.score;
}
function damagePlayer(amount) {
if (player.invincibleTimer > 0) return;
player.hp = Math.max(0, player.hp - amount);
player.invincibleTimer = 1.6;
document.getElementById('hp-bar').style.width = player.hp + '%';
SoundController.hit();
if (amount >= 25 && player.ability !== 'normal') {
dropPlayerAbility();
}
if (player.hp <= 0) {
triggerGameOver();
}
}
function initStageModal() {
const grid = document.getElementById('stage-grid');
grid.innerHTML = '';
STAGE_NAMES.forEach((name, idx) => {
const worldIdx = Math.floor(idx / 4);
const tile = document.createElement('div');
tile.className = 'stage-tile ' + (idx === currentStageIndex ? 'active' : '');
tile.innerHTML = '<div class="stage-num">STAGE ' + (idx + 1) + '</div>' +
'<div class="stage-world-tag">' + STAGE_THEMES[worldIdx].name + '</div>';
tile.addEventListener('click', () => {
currentStageIndex = idx;
document.getElementById('stage-modal').classList.remove('open');
buildStage(currentStageIndex);
updateModalActive();
});
grid.appendChild(tile);
});
document.getElementById('btn-open-stages').addEventListener('click', () => {
updateModalActive();
document.getElementById('stage-modal').classList.add('open');
});
document.getElementById('btn-close-modal').addEventListener('click', () => {
document.getElementById('stage-modal').classList.remove('open');
});
document.getElementById('btn-next-stage').addEventListener('click', () => {
document.getElementById('message-banner').classList.remove('show');
if (currentStageIndex < STAGE_NAMES.length - 1) {
currentStageIndex++;
buildStage(currentStageIndex);
} else {
currentStageIndex = 0;
buildStage(currentStageIndex);
}
});
}
function updateModalActive() {
const tiles = document.querySelectorAll('.stage-tile');
tiles.forEach((t, i) => {
if (i === currentStageIndex) t.classList.add('active');
else t.classList.remove('active');
});
}
function triggerStageClear() {
goalObject.cleared = true;
SoundController.win();
const banner = document.getElementById('message-banner');
const nextBtn = document.getElementById('btn-next-stage');
if (currentStageIndex >= STAGE_NAMES.length - 1) {
document.getElementById('banner-title').textContent = '全20難関ステージ完全制覇!🏆';
document.getElementById('banner-desc').textContent = '全島を踏破し、大ボスを撃退しました!最終スコア: ' + player.score;
nextBtn.textContent = '最初から挑戦 (Stage 1)';
} else {
document.getElementById('banner-title').textContent = 'ステージクリア!⭐';
document.getElementById('banner-desc').textContent = 'STAGE ' + (currentStageIndex + 1) + ' を踏破&ボス撃破! スコア: ' + player.score;
nextBtn.textContent = '次のステージ (' + (currentStageIndex + 2) + ') へ ➔';
}
banner.classList.add('show');
}
function triggerGameOver() {
const banner = document.getElementById('message-banner');
document.getElementById('banner-title').textContent = 'GAME OVER 😢';
document.getElementById('banner-desc').textContent = '大ボスやトラップに阻まれてしまった… コピー能力を活用して再挑戦しよう!';
document.getElementById('btn-next-stage').style.display = 'none';
banner.classList.add('show');
}
function restartGame() {
document.getElementById('message-banner').classList.remove('show');
document.getElementById('btn-next-stage').style.display = 'inline-block';
player.hp = 100;
document.getElementById('hp-bar').style.width = '100%';
setPlayerAbility('normal');
buildStage(currentStageIndex);
}
function onWindowResize() {
if (!renderer || !camera) return;
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
let lastFrameTime = performance.now();
function animate() {
requestAnimationFrame(animate);
try {
const now = performance.now();
const delta = Math.min((now - lastFrameTime) / 1000, 0.1);
lastFrameTime = now;
updatePlayer(delta);
updateEntities(delta);
if (renderer && scene && camera) {
renderer.render(scene, camera);
}
} catch (err) {
console.error("Game loop error:", err);
}
}
let isInitialized = false;
function initGame() {
if (isInitialized) return;
isInitialized = true;
initScene();
kirby = createKirbyModel();
createSuctionParticles();
initStageModal();
buildStage(currentStageIndex);
setupInputListeners();
animate();
}
if (document.readyState === 'complete' || document.readyState === 'interactive') {
initGame();
} else {
window.addEventListener('DOMContentLoaded', initGame);
}
</script>
</body>
</html>
カービィが3Dになっています。僕が考えたオリジナルコピー能力がはいってます。