Spaces:
Running

LOVIEQUEST / index.html
Jakecybr's picture
Upload 41 files
ae70b3b verified
Raw History Blame Contribute Delete
30 kB
<!DOCTYPE html>
<html>
<head>
<title>Mom's Kindness Quest: Ultimate Edition</title>
<style>
body { background: #ffdef2; font-family: 'Courier New', Courier, monospace; text-align: center; margin: 0; overflow: hidden; }
canvas { background: #a2d5ab; border: 6px solid #fff; image-rendering: pixelated; display: block; margin: 10px auto; }
/* UI Panels */
.ui-panel { background: white; padding: 10px; border-bottom: 4px solid #ff69b4; display: flex; justify-content: center; gap: 20px; font-weight: bold; color: #d63384; }
.controls-hint { position: absolute; bottom: 10px; width: 100%; color: #d63384; font-size: 14px; }
/* Overlays */
.full-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: black; color: white; display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 100; transition: opacity 1s; }
.overlay-content { width: 80%; max-width: 600px; text-align: center; }
.hero-preview { width: 200px; margin-bottom: 20px; border: 4px solid gold; border-radius: 10px; }
/* Post-Game Skin Gallery */
#galleryOverlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 222, 242, 0.95); display: none; flex-direction: column; justify-content: center; align-items: center; z-index: 50; }
.skin-card { display: inline-block; background: white; padding: 15px; margin: 10px; border-radius: 15px; border: 3px solid #ff69b4; cursor: pointer; transition: transform 0.2s; }
.skin-card:hover { transform: scale(1.1); }
.skin-img-hd { width: 120px; height: 120px; object-fit: contain; }
button { background: #ff69b4; color: white; border: none; padding: 15px 30px; font-size: 20px; border-radius: 50px; cursor: pointer; margin-top: 20px; font-family: 'Courier New'; }
button:hover { background: #d63384; }
.hidden { display: none !important; }
/* Infinite-mode progress panel (right side) */
#progressPanel {
position: fixed;
right: 12px;
top: 74px;
width: 220px;
background: white;
border: 4px solid #ff69b4;
border-radius: 18px;
padding: 12px 12px 10px;
color: #d63384;
z-index: 60;
box-shadow: 0 8px 18px rgba(0,0,0,0.12);
text-align: left;
user-select: none;
}
#progressTitle { font-weight: 900; font-size: 16px; margin-bottom: 6px; }
#loviesLine { font-weight: 900; font-size: 14px; }
#loviesClickable { cursor: pointer; text-decoration: underline; }
#loviesHint { margin-top: 6px; font-size: 12px; opacity: 0.8; }
#progressBarOuter {
margin-top: 10px;
height: 10px;
background: #ffd1e7;
border-radius: 999px;
overflow: hidden;
}
#progressBarInner { height: 100%; width: 0%; background: #ff69b4; }
</style>
</head>
<body>
<div id="introOverlay" class="full-overlay">
<div class="overlay-content">
<img src="momhero.png" class="hero-preview">
<h1 style="color: gold;">URGENT MESSAGE</h1>
<p id="typewriter" style="font-size: 18px; line-height: 1.6;"></p>
<button id="startBtn" class="hidden" onclick="startGame()">I'M ON MY WAY!</button>
</div>
</div>
<div id="outroOverlay" class="full-overlay hidden" style="background: linear-gradient(to bottom, #000, #4b0082);">
<div class="overlay-content">
<h1 style="color: #ff69b4;">MISSION ACCOMPLISHED</h1>
<p id="outroTypewriter" style="font-size: 18px; line-height: 1.6;"></p>
<button id="infiniteBtn" class="hidden" onclick="resetToInfinite()">CONTINUE SPREADING LOVE</button>
</div>
</div>
<div id="galleryOverlay">
<h1 style="color: #d63384;">Mom's Super-Skins Collection</h1>
<div id="skinContainer"></div>
<button onclick="closeGallery()">BACK TO KINDNESS</button>
</div>
<div class="ui-panel">
<div>Level: <span id="lv">1</span></div>
<div id="goalText">Current Mission: Loading...</div>
<div>Progress: <span id="itemCount">0</span></div>
<button id="galleryBtn" style="margin: 0; padding: 5px 10px; font-size: 12px;" class="hidden" onclick="openGallery()">VIEW SKINS</button>
</div>
<div id="progressPanel" class="hidden">
<div id="progressTitle">INFINITE MODE</div>
<div id="loviesLine">
Lovies:
<span id="loviesClickable" title="Click to edit">
<span id="loviesNow">0</span> / <span id="loviesTotal">1,000,000</span>
</span>
</div>
<div id="progressBarOuter"><div id="progressBarInner"></div></div>
<div id="loviesHint">Click the number to set it.</div>
</div>
<canvas id="gameCanvas" width="800" height="500"></canvas>
<div id="hint" class="controls-hint">ARROWS to Move | SPACE to Interact</div>
<script>
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
const assets = {
hero: new Image(), cat: new Image(), horse: new Image(), diver: new Image(), key: new Image(),
flower: new Image(), cookie: new Image(), heart: new Image(), tea: new Image(),
people: [],
bosses: [],
maps: [] // ✅ NEW
};
assets.hero.src = 'momhero.png';
assets.cat.src = 'momcat.png';
assets.horse.src = 'momhorse.png';
assets.diver.src = 'momdiver.png';
assets.key.src = 'momkey.png';
assets.flower.src = 'flower3.png';
assets.cookie.src = 'cookie1.jpg';
assets.heart.src = 'heart2.png';
assets.tea.src = 'tea1.png';
for (let i = 1; i <= 13; i++) {
let img = new Image();
img.src = `p${i}.png`;
assets.people.push(img);
}
// Bosses
for (let i = 1; i <= 9; i++) {
let b = new Image();
b.src = `boss${i}.png`;
assets.bosses.push(b);
}
// ✅ NEW: Maps m1..m8
for (let i = 1; i <= 8; i++) {
let m = new Image();
m.src = `m${i}.png`;
assets.maps.push(m);
}
let level = 1;
let skinIndex = 0;
let skinList = ['hero', 'cat', 'horse', 'diver', 'key'];
let player = { x: 400, y: 250, size: 75 };
let items = [];
let particles = [];
let floatingTexts = [];
let keys = {};
let spacePressed = false;
let skinsUnlocked = false;
let gameActive = false;
// Endless mode + lovies target
let infiniteMode = false;
let loviesGiven = 0;
const TARGET_LOVIES = 1000000;
let millionReached = false;
// ✅ NEW: current map selection (1..8)
let currentMapIndex = 1;
// Progress panel
const progressPanel = document.getElementById('progressPanel');
const loviesNowEl = document.getElementById('loviesNow');
const barInner = document.getElementById('progressBarInner');
const loviesClickable = document.getElementById('loviesClickable');
function clamp(n, min, max) { return Math.max(min, Math.min(max, n)); }
function updateProgressUI() {
if (!infiniteMode) return;
loviesNowEl.textContent = loviesGiven.toLocaleString();
const pct = (TARGET_LOVIES === 0) ? 0 : (loviesGiven / TARGET_LOVIES) * 100;
barInner.style.width = clamp(pct, 0, 100) + "%";
}
// Click-to-edit lovies
loviesClickable.addEventListener('click', () => {
if (!infiniteMode) return;
const raw = prompt("Set lovies count (0 to 1,000,000+). Example: 500000", String(loviesGiven));
if (raw === null) return;
const cleaned = raw.replace(/,/g, '').trim();
const parsed = Number(cleaned);
if (!Number.isFinite(parsed) || parsed < 0) {
alert("That wasn't a valid number. Try like: 250000");
return;
}
loviesGiven = Math.floor(parsed);
updateProgressUI();
nextMilestoneBoss = (Math.floor(loviesGiven / 100) * 100) + 100;
if (loviesGiven >= TARGET_LOVIES && !millionReached) triggerMillionWin();
});
// ✅ BOSS SYSTEM -----------------------------------------------------
let gameMode = 'mission'; // 'mission' | 'boss'
let bossContext = null;
let projectiles = [];
let boss = { x: 560, y: 220, size: 140, speed: 2.2, hp: 100, maxHp: 100, img: null };
let momHP = 100, momMaxHP = 100;
let throwCooldown = 0;
let contactCooldown = 0;
let momIFrames = 0;
let nextMilestoneBoss = 100;
function drawBackground() {
const idx = clamp(currentMapIndex, 1, 8) - 1;
const bg = assets.maps[idx];
if (bg && bg.complete && bg.naturalWidth > 0) {
ctx.globalAlpha = 1.0;
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
} else {
// fallback in case map not loaded
ctx.fillStyle = "#a2d5ab";
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
}
function startBossFight(ctxObj) {
gameMode = 'boss';
bossContext = ctxObj;
momMaxHP = 100;
momHP = momMaxHP;
const bi = ((ctxObj.bossIndex ?? 0) % 9 + 9) % 9;
boss.img = assets.bosses[bi];
const baseBossHP = ctxObj.milestone ? 180 : 120;
const scale = ctxObj.milestone ? 40 : 20;
boss.maxHp = baseBossHP + scale * (bi);
boss.hp = boss.maxHp;
boss.size = ctxObj.milestone ? 170 : 140;
boss.speed = ctxObj.milestone ? 2.8 : 2.2;
boss.x = 560;
boss.y = 180;
projectiles = [];
throwCooldown = 0;
contactCooldown = 0;
momIFrames = 0;
spacePressed = false;
document.getElementById('goalText').innerText = ctxObj.milestone ? "BOSS FIGHT: MILESTONE!" : "BOSS FIGHT!";
document.getElementById('itemCount').innerText = "—";
document.getElementById('hint').innerText = "BOSS FIGHT! ARROWS to Move | SPACE to Throw Lovies!";
}
function restartBossFightSame() {
startBossFight({ ...bossContext });
}
function endBossFightWin() {
gameMode = 'mission';
bossContext = null;
if (!infiniteMode) {
document.getElementById('hint').innerText = "ARROWS to Move | SPACE to Interact";
} else {
document.getElementById('hint').innerText = "ARROWS to Move | SPACE to Interact | S to Change Skin!";
}
if (!infiniteMode) {
if (pendingStoryEndAfterBoss) {
pendingStoryEndAfterBoss = false;
triggerEndGame();
return;
}
level++;
spawnLevel();
} else {
level++;
spawnLevel();
}
}
function spawnProjectile() {
const lovies = [assets.flower, assets.cookie, assets.heart, assets.tea];
const img = lovies[Math.floor(Math.random() * lovies.length)];
const px = player.x + player.size / 2;
const py = player.y + player.size / 2;
const bx = boss.x + boss.size / 2;
const by = boss.y + boss.size / 2;
const dx = bx - px;
const dy = by - py;
const mag = Math.hypot(dx, dy) || 1;
const speed = 9.0;
const vx = (dx / mag) * speed;
const vy = (dy / mag) * speed;
projectiles.push({ x: px, y: py, vx, vy, img, size: 34, life: 120 });
}
function drawBar(x, y, w, h, ratio, label) {
ratio = clamp(ratio, 0, 1);
ctx.globalAlpha = 1.0;
ctx.fillStyle = "rgba(255,255,255,0.85)";
ctx.fillRect(x, y, w, h);
ctx.fillStyle = "#ff69b4";
ctx.fillRect(x, y, w * ratio, h);
ctx.strokeStyle = "#d63384";
ctx.lineWidth = 3;
ctx.strokeRect(x, y, w, h);
ctx.fillStyle = "#d63384";
ctx.font = "bold 14px Arial";
ctx.fillText(label, x + 6, y + 14);
}
function drawHealthBars() {
drawBar(20, 16, 260, 18, momHP / momMaxHP, "MOM HP");
drawBar(canvas.width - 280, 16, 260, 18, boss.hp / boss.maxHp, bossContext?.milestone ? "BOSS HP (MILESTONE)" : "BOSS HP");
}
function updateBossMode() {
if (keys['ArrowUp'] && player.y > 0) player.y -= 6;
if (keys['ArrowDown'] && player.y < canvas.height - player.size) player.y += 6;
if (keys['ArrowLeft'] && player.x > 0) player.x -= 6;
if (keys['ArrowRight'] && player.x < canvas.width - player.size) player.x += 6;
if (throwCooldown > 0) throwCooldown--;
if (contactCooldown > 0) contactCooldown--;
if (momIFrames > 0) momIFrames--;
if (keys['Space'] && throwCooldown <= 0) {
spawnProjectile();
throwCooldown = 10;
}
const targetX = player.x + player.size / 2;
const targetY = player.y + player.size / 2;
const bossX = boss.x + boss.size / 2;
const bossY = boss.y + boss.size / 2;
const dx = targetX - bossX;
const dy = targetY - bossY;
const mag = Math.hypot(dx, dy) || 1;
boss.x += (dx / mag) * boss.speed;
boss.y += (dy / mag) * boss.speed;
boss.x = clamp(boss.x, 0, canvas.width - boss.size);
boss.y = clamp(boss.y, 40, canvas.height - boss.size);
const dist = Math.hypot(bossX - targetX, bossY - targetY);
const hitRange = (boss.size * 0.45) + (player.size * 0.35);
if (dist < hitRange && contactCooldown <= 0 && momIFrames <= 0) {
momHP -= bossContext?.milestone ? 12 : 9;
momIFrames = 18;
contactCooldown = 12;
floatingTexts.push({ x: player.x + 40, y: player.y - 10, text: "OUCH!", life: 1.0 });
}
for (let i = projectiles.length - 1; i >= 0; i--) {
const p = projectiles[i];
p.x += p.vx;
p.y += p.vy;
p.life--;
const bx2 = boss.x + boss.size / 2;
const by2 = boss.y + boss.size / 2;
const pd = Math.hypot(p.x - bx2, p.y - by2);
if (pd < boss.size * 0.45) {
const dmg = bossContext?.milestone ? 14 : 11;
boss.hp -= dmg;
createBurst(p.x, p.y);
floatingTexts.push({ x: p.x, y: p.y - 20, text: `-${dmg}`, life: 1.0 });
projectiles.splice(i, 1);
continue;
}
if (p.life <= 0 || p.x < -50 || p.x > canvas.width + 50 || p.y < -50 || p.y > canvas.height + 50) {
projectiles.splice(i, 1);
}
}
if (momHP <= 0) {
restartBossFightSame();
return;
}
if (boss.hp <= 0) {
endBossFightWin();
return;
}
particles.forEach((p, i) => { p.x += p.vx; p.y += p.vy; p.life -= 0.02; if (p.life <= 0) particles.splice(i, 1); });
floatingTexts.forEach((t, i) => { t.y -= 0.6; t.life -= 0.01; if (t.life <= 0) floatingTexts.splice(i, 1); });
}
function drawBossMode() {
drawBackground(); // ✅ NEW
if (boss.img && boss.img.complete) {
ctx.drawImage(boss.img, boss.x, boss.y, boss.size, boss.size);
} else {
ctx.fillStyle = "rgba(0,0,0,0.35)";
ctx.fillRect(boss.x, boss.y, boss.size, boss.size);
}
const currentSkinName = skinList[skinIndex];
const momImg = assets[currentSkinName];
if (momImg.complete) {
ctx.globalAlpha = (momIFrames > 0 && (momIFrames % 4 < 2)) ? 0.35 : 1.0;
ctx.drawImage(momImg, player.x, player.y, player.size, player.size);
ctx.globalAlpha = 1.0;
}
projectiles.forEach(p => {
if (p.img && p.img.complete) ctx.drawImage(p.img, p.x - p.size/2, p.y - p.size/2, p.size, p.size);
});
particles.forEach(p => { ctx.globalAlpha = p.life; ctx.drawImage(assets.heart, p.x, p.y, p.size, p.size); });
ctx.globalAlpha = 1.0;
ctx.fillStyle = "#d63384";
ctx.font = "bold 20px Arial";
floatingTexts.forEach(t => { ctx.globalAlpha = t.life; ctx.fillText(t.text, t.x - 30, t.y); });
ctx.globalAlpha = 1.0;
drawHealthBars();
ctx.fillStyle = "#d63384";
ctx.font = "bold 22px Arial";
ctx.fillText(bossContext?.milestone ? "MILESTONE BOSS FIGHT!" : "BOSS FIGHT!", canvas.width/2 - 120, 52);
}
// -----------------------------------------------------------------------
const introText = "The world has grown cold... Hissing and Grumpiness are at an all-time high. Only ONE person has the power to restore the lovies. Mom... the Healthcare Hero. WE NEED YOU!";
let charIndex = 0;
function typeWriter() {
if (charIndex < introText.length) {
document.getElementById("typewriter").innerHTML += introText.charAt(charIndex);
charIndex++;
setTimeout(typeWriter, 50);
} else {
document.getElementById("startBtn").classList.remove("hidden");
}
}
function startGame() {
document.getElementById("introOverlay").style.opacity = "0";
setTimeout(() => {
document.getElementById("introOverlay").classList.add("hidden");
gameActive = true;
progressPanel.classList.add('hidden');
gameMode = 'mission';
spawnLevel();
draw();
}, 1000);
}
function triggerEndGame() {
gameActive = false;
const outroOverlay = document.getElementById("outroOverlay");
outroOverlay.style.opacity = "1";
outroOverlay.classList.remove("hidden");
const outroText = "The shadows have fled. The 'lovies' have been restored to every corner of the world. Because of you, the light of kindness shines brighter than ever before... \n\nTo the BEST mom ever, you spread kindness wherever you go. Thank you for being the BEST mom EVER!";
let outroIndex = 0;
const outroEl = document.getElementById("outroTypewriter");
outroEl.innerHTML = "";
const btn = document.getElementById("infiniteBtn");
btn.classList.add("hidden");
btn.innerText = "CONTINUE SPREADING LOVE";
btn.onclick = resetToInfinite;
function typeOutro() {
if (outroIndex < outroText.length) {
outroEl.innerHTML += outroText.charAt(outroIndex);
outroIndex++;
setTimeout(typeOutro, 50);
} else {
btn.classList.remove("hidden");
}
}
typeOutro();
}
function triggerMillionWin() {
gameActive = false;
millionReached = true;
const outroOverlay = document.getElementById("outroOverlay");
outroOverlay.style.opacity = "1";
outroOverlay.classList.remove("hidden");
const outroEl = document.getElementById("outroTypewriter");
outroEl.innerHTML = "ONE. MILLION. LOVIES.<br><br>MOM: WORLD-SAVING KINDNESS LEGEND. ❤️<br><br>You can keep spreading love forever.";
const btn = document.getElementById("infiniteBtn");
btn.classList.remove("hidden");
btn.innerText = "KEEP SPREADING LOVE";
btn.onclick = () => {
outroOverlay.style.opacity = "0";
setTimeout(() => {
outroOverlay.classList.add("hidden");
outroOverlay.style.opacity = "1";
gameActive = true;
draw();
}, 800);
};
}
function resetToInfinite() {
document.getElementById("outroOverlay").style.opacity = "0";
setTimeout(() => {
const outroOverlay = document.getElementById("outroOverlay");
outroOverlay.classList.add("hidden");
outroOverlay.style.opacity = "1";
skinsUnlocked = true;
document.getElementById('galleryBtn').classList.remove('hidden');
document.getElementById('hint').innerText = "ARROWS to Move | SPACE to Interact | S to Change Skin!";
infiniteMode = true;
loviesGiven = 0;
millionReached = false;
nextMilestoneBoss = 100;
progressPanel.classList.remove('hidden');
updateProgressUI();
level = 1;
gameMode = 'mission';
gameActive = true;
spawnLevel();
draw();
}, 1000);
}
function openGallery() {
const container = document.getElementById('skinContainer');
container.innerHTML = '';
skinList.forEach((s, index) => {
const card = document.createElement('div');
card.className = 'skin-card';
card.innerHTML = `<img src="mom${s === 'hero' ? 'hero' : s}.png" class="skin-img-hd"><br>${s.toUpperCase()}`;
card.onclick = () => { skinIndex = index; closeGallery(); };
container.appendChild(card);
});
document.getElementById('galleryOverlay').style.display = 'flex';
}
function closeGallery() { document.getElementById('galleryOverlay').style.display = 'none'; }
const levelConfig = {
1: { type: 'collect', goal: "Gather Flowers", img: assets.flower, count: 5, msg: "Got one! 🌸" },
2: { type: 'collect', goal: "Bake Cookies", img: assets.cookie, count: 6, msg: "Smells good! 🍪" },
3: { type: 'collect', goal: "Collect Hugs", img: assets.heart, count: 8, msg: "Warm heart! ❤️" },
4: { type: 'collect', goal: "Brew Tea", img: assets.tea, count: 6, msg: "Steam fresh! ☕" },
5: { type: 'give', goal: "Help Neighbors (Flowers)", gift: assets.flower, count: 5, msg: "Thank you, Mom! 🌸" },
6: { type: 'give', goal: "Share Cookies", gift: assets.cookie, count: 5, msg: "Best cookie ever! 🍪" },
7: { type: 'give', goal: "Distribute Hugs", gift: assets.heart, count: 6, msg: "I needed that! ❤️" },
8: { type: 'give', goal: "Serve Warm Tea", gift: assets.tea, count: 7, msg: "So cozy! ☕" }
};
function getCfg() {
if (!infiniteMode) return levelConfig[level];
const base = ((level - 1) % 8) + 1;
return levelConfig[base];
}
// ✅ NEW: select map based on story or infinite rules
function chooseMapForNewMission() {
if (!infiniteMode) {
// Story: m1 for lvl1, ... m8 for lvl8
currentMapIndex = clamp(level, 1, 8);
} else {
// Infinite: random m1..m8 every mission (boss uses same until next mission)
currentMapIndex = Math.floor(Math.random() * 8) + 1;
}
}
function spawnLevel() {
// ✅ NEW: pick map BEFORE spawning (so mission + upcoming boss share it)
chooseMapForNewMission();
items = [];
const cfg = getCfg();
document.getElementById('lv').innerText = level;
document.getElementById('goalText').innerText = cfg.goal;
for (let i = 0; i < cfg.count; i++) {
let randomPerson = assets.people[Math.floor(Math.random() * assets.people.length)];
items.push({ x: Math.floor(Math.random() * 700) + 50, y: Math.floor(Math.random() * 400) + 50, done: false, npcImg: randomPerson });
}
}
function createBurst(x, y) {
for (let i = 0; i < 12; i++) {
particles.push({ x, y, vx: (Math.random()-0.5)*7, vy: (Math.random()-0.5)*7, life: 1.0, size: Math.random()*20+10 });
}
floatingTexts.push({ x, y: y-30, text: getCfg().msg, life: 1.0 });
}
window.addEventListener('keydown', e => {
keys[e.code] = true;
if (e.code === 'KeyS' && skinsUnlocked && gameMode === 'mission') {
skinIndex = (skinIndex + 1) % skinList.length;
}
});
window.addEventListener('keyup', e => {
keys[e.code] = false;
if (e.code === 'Space') spacePressed = false;
});
let pendingStoryEndAfterBoss = false;
function updateMissionMode() {
if (keys['ArrowUp'] && player.y > 0) player.y -= 6;
if (keys['ArrowDown'] && player.y < canvas.height-player.size) player.y += 6;
if (keys['ArrowLeft'] && player.x > 0) player.x -= 6;
if (keys['ArrowRight'] && player.x < canvas.width-player.size) player.x += 6;
if (keys['Space'] && !spacePressed) {
let hit = false;
items.forEach(it => {
let dist = Math.hypot((player.x + 37) - it.x, (player.y + 37) - it.y);
if (dist < 85 && !it.done) {
it.done = true;
hit = true;
createBurst(it.x, it.y);
if (infiniteMode && !millionReached) {
loviesGiven++;
updateProgressUI();
if (loviesGiven >= TARGET_LOVIES) {
triggerMillionWin();
return;
}
}
}
});
if (hit) spacePressed = true;
}
const remaining = items.filter(i => !i.done).length;
document.getElementById('itemCount').innerText = remaining;
if (items.length > 0 && remaining === 0) {
const baseBossIndex = (level - 1) % 9;
let milestone = false;
if (infiniteMode && loviesGiven >= nextMilestoneBoss) {
milestone = true;
nextMilestoneBoss += 100;
}
if (!infiniteMode && level === 8) {
pendingStoryEndAfterBoss = true;
}
startBossFight({
afterWin: (!infiniteMode && level === 8) ? 'endGame' : 'nextLevel',
milestone,
bossIndex: milestone ? ((Math.floor(loviesGiven / 100) - 1) % 9) : baseBossIndex
});
return;
}
particles.forEach((p, i) => { p.x += p.vx; p.y += p.vy; p.life -= 0.02; if(p.life <= 0) particles.splice(i,1); });
floatingTexts.forEach((t, i) => { t.y -= 0.6; t.life -= 0.01; if(t.life <= 0) floatingTexts.splice(i,1); });
}
function drawMissionMode() {
drawBackground(); // ✅ NEW
const cfg = getCfg();
items.forEach(it => {
if (!it.done) {
if (cfg.type === 'collect') {
ctx.drawImage(cfg.img, it.x, it.y, 55, 55);
} else {
if (it.npcImg.complete) ctx.drawImage(it.npcImg, it.x, it.y, 75, 75);
ctx.globalAlpha = 0.8;
ctx.drawImage(cfg.gift, it.x + 50, it.y - 20, 35, 35);
ctx.globalAlpha = 1.0;
}
}
});
const currentSkinName = skinList[skinIndex];
const momImg = assets[currentSkinName];
if (momImg.complete) ctx.drawImage(momImg, player.x, player.y, player.size, player.size);
particles.forEach(p => { ctx.globalAlpha = p.life; ctx.drawImage(assets.heart, p.x, p.y, p.size, p.size); });
ctx.globalAlpha = 1.0;
ctx.fillStyle = "#d63384";
ctx.font = "bold 20px Arial";
floatingTexts.forEach(t => { ctx.globalAlpha = t.life; ctx.fillText(t.text, t.x-50, t.y); });
ctx.globalAlpha = 1.0;
}
function update() {
if (!gameActive) return;
if (gameMode === 'boss') updateBossMode();
else updateMissionMode();
}
function draw() {
if (!gameActive) return;
if (gameMode === 'boss') drawBossMode();
else drawMissionMode();
requestAnimationFrame(() => { update(); draw(); });
}
window.onload = typeWriter;
</script>
</body>
</html>