VPN Ball — Elakomen Edition
by SolarPenguin641200 lines48.8 KB
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>VPN Ball — Elakomen Edition</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
background: #05050a;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: 'Segoe UI', Arial, sans-serif;
overflow: hidden;
touch-action: none;
-webkit-user-select: none;
user-select: none;
}
canvas {
border: 2px solid #4a4aff;
border-radius: 12px;
box-shadow: 0 0 50px #4a4aff88;
background: #0a0a1e;
max-height: 100vh;
max-width: 100vw;
display: block;
}
</style>
</head>
<body>
<canvas id="game" width="480" height="640"></canvas>
<script>
"use strict";
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d', { alpha: false });
const W = canvas.width, H = canvas.height;
// ===== ПРОМОКОДЫ =====
const PROMOCODES = [
{ code: 'LOPHS45', discount: '45%' },
{ code: 'ROLP35', discount: '35%' },
{ code: 'VIP25', discount: '25%' },
{ code: 'ELAK10', discount: '10%' },
{ code: 'SUMMER5', discount: '5%' },
{ code: 'FRIDAY13', discount: '50%' },
{ code: 'EDIN2026', discount: '20%' },
{ code: 'ELAK20', discount: '20%' },
{ code: 'PAPA30', discount: '30%' },
{ code: 'HOLOP', discount: '15%' }
];
let currentPromo = null;
let promoRevealed = false;
let promoParticles = [];
function pickRandomPromo() {
const idx = Math.floor(Math.random() * PROMOCODES.length);
currentPromo = { ...PROMOCODES[idx] };
promoRevealed = false;
promoParticles = [];
}
// ===== АУДИО =====
let audioCtx = null;
let soundEnabled = true;
let musicInterval = null;
let musicGain = null;
function initAudio() {
if (audioCtx) return;
try {
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
musicGain = audioCtx.createGain();
musicGain.gain.value = 0.05;
musicGain.connect(audioCtx.destination);
startMusic();
} catch(e) { console.warn('Audio not supported'); }
}
function playSound(type) {
if (!audioCtx || !soundEnabled) return;
const now = audioCtx.currentTime;
const osc = audioCtx.createOscillator();
const gain = audioCtx.createGain();
osc.connect(gain);
gain.connect(audioCtx.destination);
if (type === 'shoot') {
osc.type = 'square'; osc.frequency.setValueAtTime(800, now); osc.frequency.exponentialRampToValueAtTime(200, now + 0.1);
gain.gain.setValueAtTime(0.1, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.1);
osc.start(now); osc.stop(now + 0.1);
} else if (type === 'explosion') {
osc.type = 'sawtooth'; osc.frequency.setValueAtTime(150, now); osc.frequency.exponentialRampToValueAtTime(40, now + 0.4);
gain.gain.setValueAtTime(0.2, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.4);
osc.start(now); osc.stop(now + 0.4);
} else if (type === 'coin') {
osc.type = 'sine'; osc.frequency.setValueAtTime(880, now); osc.frequency.setValueAtTime(1320, now + 0.05);
gain.gain.setValueAtTime(0.1, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.2);
osc.start(now); osc.stop(now + 0.2);
} else if (type === 'hurt') {
osc.type = 'sawtooth'; osc.frequency.setValueAtTime(300, now); osc.frequency.exponentialRampToValueAtTime(80, now + 0.3);
gain.gain.setValueAtTime(0.15, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.3);
osc.start(now); osc.stop(now + 0.3);
} else if (type === 'bossDie') {
osc.type = 'sawtooth'; osc.frequency.setValueAtTime(400, now); osc.frequency.exponentialRampToValueAtTime(30, now + 0.8);
gain.gain.setValueAtTime(0.25, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.8);
osc.start(now); osc.stop(now + 0.8);
} else if (type === 'victory') {
[523, 659, 784, 1046].forEach((f, i) => {
const o = audioCtx.createOscillator(); const g = audioCtx.createGain();
o.connect(g); g.connect(audioCtx.destination); o.type = 'sine';
o.frequency.setValueAtTime(f, now + i*0.12);
g.gain.setValueAtTime(0.15, now + i*0.12); g.gain.exponentialRampToValueAtTime(0.001, now + i*0.12 + 0.3);
o.start(now + i*0.12); o.stop(now + i*0.12 + 0.3);
});
} else if (type === 'powerup') {
osc.type = 'triangle'; osc.frequency.setValueAtTime(400, now); osc.frequency.linearRampToValueAtTime(1200, now + 0.2);
gain.gain.setValueAtTime(0.12, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.3);
osc.start(now); osc.stop(now + 0.3);
}
}
function startMusic() {
if (musicInterval) return;
let note = 0;
const bassNotes = [65.41, 73.42, 82.41, 98.00, 82.41, 73.42];
const melodyNotes = [261.63, 329.63, 392.00, 523.25, 493.88, 440.00, 392.00, 329.63];
const padNotes = [130.81, 164.81, 196.00, 261.63];
musicInterval = setInterval(() => {
if (!audioCtx || !soundEnabled) return;
const now = audioCtx.currentTime;
const step = note % 16;
const bassOsc = audioCtx.createOscillator();
const bassGain = audioCtx.createGain();
bassOsc.connect(bassGain); bassGain.connect(musicGain);
bassOsc.type = 'triangle';
bassOsc.frequency.value = bassNotes[Math.floor(note/4) % bassNotes.length];
bassGain.gain.setValueAtTime(0.35, now);
bassGain.gain.exponentialRampToValueAtTime(0.01, now + 0.18);
bassOsc.start(now); bassOsc.stop(now + 0.2);
if (step % 2 === 1) {
const melOsc = audioCtx.createOscillator();
const melGain = audioCtx.createGain();
melOsc.connect(melGain); melGain.connect(musicGain);
melOsc.type = 'sine';
melOsc.frequency.value = melodyNotes[Math.floor(note/3) % melodyNotes.length] * 1.5;
melGain.gain.setValueAtTime(0.12, now);
melGain.gain.exponentialRampToValueAtTime(0.01, now + 0.25);
melOsc.start(now); melOsc.stop(now + 0.3);
}
if (step % 4 === 0) {
padNotes.forEach((freq, i) => {
const padOsc = audioCtx.createOscillator();
const padGain = audioCtx.createGain();
padOsc.connect(padGain); padGain.connect(musicGain);
padOsc.type = 'sine';
padOsc.frequency.value = freq * (1 + i * 0.001);
padGain.gain.setValueAtTime(0.06, now + i * 0.02);
padGain.gain.exponentialRampToValueAtTime(0.005, now + 0.5 + i * 0.05);
padOsc.start(now + i * 0.02); padOsc.stop(now + 0.6 + i * 0.05);
});
}
if (step === 8) {
const bellOsc = audioCtx.createOscillator();
const bellGain = audioCtx.createGain();
bellOsc.connect(bellGain); bellGain.connect(musicGain);
bellOsc.type = 'sine';
bellOsc.frequency.value = 1046.50;
bellGain.gain.setValueAtTime(0.08, now);
bellGain.gain.exponentialRampToValueAtTime(0.001, now + 0.6);
bellOsc.start(now); bellOsc.stop(now + 0.65);
}
note++;
}, 220);
}
// ===== ПРЕДРЕНДЕР =====
const sprites = {};
function makeCanvas(w, h) { const c = document.createElement('canvas'); c.width = w; c.height = h; return c; }
function prerenderStars() {
const small = makeCanvas(8, 8); const sctx = small.getContext('2d');
const g1 = sctx.createRadialGradient(4, 4, 0, 4, 4, 4);
g1.addColorStop(0, 'rgba(255,255,255,1)'); g1.addColorStop(0.4, 'rgba(200,200,255,0.8)'); g1.addColorStop(1, 'rgba(200,200,255,0)');
sctx.fillStyle = g1; sctx.fillRect(0, 0, 8, 8); sprites.starSmall = small;
const big = makeCanvas(16, 16); const bctx = big.getContext('2d');
const g2 = bctx.createRadialGradient(8, 8, 0, 8, 8, 8);
g2.addColorStop(0, 'rgba(255,255,255,1)'); g2.addColorStop(0.3, 'rgba(200,200,255,0.6)'); g2.addColorStop(1, 'rgba(200,200,255,0)');
bctx.fillStyle = g2; bctx.fillRect(0, 0, 16, 16);
bctx.strokeStyle = 'rgba(200,200,255,0.4)'; bctx.lineWidth = 1;
bctx.beginPath(); bctx.moveTo(8, 2); bctx.lineTo(8, 14); bctx.moveTo(2, 8); bctx.lineTo(14, 8); bctx.stroke();
sprites.starBig = big;
}
// УПРОЩЁННЫЙ ФОН (ТОЛЬКО ФИОЛЕТОВЫЙ ГРАДИЕНТ И ТОЧКИ)
function prerenderBackground() {
const bg = makeCanvas(W, H);
const bctx = bg.getContext('2d');
// Глубокий фиолетово-синий градиент
const baseGrad = bctx.createLinearGradient(0, 0, 0, H);
baseGrad.addColorStop(0, '#0a0515');
baseGrad.addColorStop(0.4, '#150a2e');
baseGrad.addColorStop(0.7, '#1a0a3a');
baseGrad.addColorStop(1, '#05020a');
bctx.fillStyle = baseGrad;
bctx.fillRect(0, 0, W, H);
// Радиальное свечение по центру (фиолетовое)
const centerGlow = bctx.createRadialGradient(W/2, H/2, 0, W/2, H/2, H*0.7);
centerGlow.addColorStop(0, 'rgba(80, 30, 150, 0.15)');
centerGlow.addColorStop(0.5, 'rgba(50, 20, 100, 0.08)');
centerGlow.addColorStop(1, 'transparent');
bctx.fillStyle = centerGlow;
bctx.fillRect(0, 0, W, H);
// Мелкие светящиеся точки (звёздная пыль)
for (let i = 0; i < 150; i++) {
const x = Math.random() * W;
const y = Math.random() * H;
const r = Math.random() * 1.5 + 0.3;
const alpha = Math.random() * 0.7 + 0.2;
const colors = ['rgba(180, 160, 255,', 'rgba(150, 180, 255,', 'rgba(200, 150, 255,'];
const c = colors[Math.floor(Math.random() * colors.length)];
bctx.fillStyle = c + alpha + ')';
bctx.beginPath(); bctx.arc(x, y, r, 0, Math.PI * 2); bctx.fill();
}
sprites.background = bg;
}
function prerenderPlayer() {
const size = 80;
const drawBall = (boost) => {
const c = makeCanvas(size, size); const pctx = c.getContext('2d');
const cx = size/2, cy = size/2, r = 15;
const auraGrad = pctx.createRadialGradient(cx, cy, r*0.5, cx, cy, r*2);
auraGrad.addColorStop(0, boost ? 'rgba(51,255,136,0.4)' : 'rgba(74,74,255,0.4)');
auraGrad.addColorStop(1, 'transparent');
pctx.fillStyle = auraGrad; pctx.beginPath(); pctx.arc(cx, cy, r*2, 0, Math.PI*2); pctx.fill();
const grad = pctx.createRadialGradient(cx - r*0.4, cy - r*0.4, r*0.1, cx, cy, r);
if (boost) {
grad.addColorStop(0, '#ffffff'); grad.addColorStop(0.3, '#aaffcc'); grad.addColorStop(0.7, '#33ff88'); grad.addColorStop(1, '#006633');
} else {
grad.addColorStop(0, '#ffffff'); grad.addColorStop(0.3, '#bbbbff'); grad.addColorStop(0.7, '#4a4aff'); grad.addColorStop(1, '#1a1a66');
}
pctx.beginPath(); pctx.arc(cx, cy, r, 0, Math.PI*2); pctx.fillStyle = grad; pctx.fill();
pctx.beginPath(); pctx.arc(cx - r*0.35, cy - r*0.35, r*0.25, 0, Math.PI*2); pctx.fillStyle = 'rgba(255,255,255,0.9)'; pctx.fill();
pctx.beginPath(); pctx.arc(cx - r*0.15, cy - r*0.45, r*0.1, 0, Math.PI*2); pctx.fillStyle = 'rgba(255,255,255,0.6)'; pctx.fill();
return c;
};
sprites.player = drawBall(false); sprites.playerBoost = drawBall(true);
}
function prerenderMine() {
const size = 64; const c = makeCanvas(size, size); const mctx = c.getContext('2d');
const cx = size/2, cy = size/2, r = 16;
for (let i = 0; i < 8; i++) {
const angle = (Math.PI*2/8) * i; const spikeLen = r * 1.5; const spikeWidth = 0.15;
mctx.beginPath();
mctx.moveTo(cx + Math.cos(angle - spikeWidth) * r * 0.8, cy + Math.sin(angle - spikeWidth) * r * 0.8);
mctx.lineTo(cx + Math.cos(angle) * spikeLen, cy + Math.sin(angle) * spikeLen);
mctx.lineTo(cx + Math.cos(angle + spikeWidth) * r * 0.8, cy + Math.sin(angle + spikeWidth) * r * 0.8);
mctx.closePath();
const spikeGrad = mctx.createLinearGradient(cx + Math.cos(angle) * r, cy + Math.sin(angle) * r, cx + Math.cos(angle) * spikeLen, cy + Math.sin(angle) * spikeLen);
spikeGrad.addColorStop(0, '#ff4466'); spikeGrad.addColorStop(1, '#660011');
mctx.fillStyle = spikeGrad; mctx.fill();
}
const bodyGrad = mctx.createRadialGradient(cx - r*0.3, cy - r*0.3, 2, cx, cy, r);
bodyGrad.addColorStop(0, '#553344'); bodyGrad.addColorStop(0.5, '#2a0011'); bodyGrad.addColorStop(1, '#110005');
mctx.beginPath(); mctx.arc(cx, cy, r, 0, Math.PI*2); mctx.fillStyle = bodyGrad; mctx.fill();
mctx.strokeStyle = '#ff2255'; mctx.lineWidth = 2; mctx.stroke();
const coreGrad = mctx.createRadialGradient(cx, cy, 1, cx, cy, r*0.5);
coreGrad.addColorStop(0, '#ffffff'); coreGrad.addColorStop(0.3, '#ff6688'); coreGrad.addColorStop(1, '#ff0033');
mctx.beginPath(); mctx.arc(cx, cy, r*0.5, 0, Math.PI*2); mctx.fillStyle = coreGrad; mctx.fill();
sprites.mine = c;
}
function prerenderDiscount() {
const size = 64; const c = makeCanvas(size, size); const dctx = c.getContext('2d');
const cx = size/2, cy = size/2, r = 15;
const coinGrad = dctx.createRadialGradient(cx - r*0.3, cy - r*0.3, 1, cx, cy, r);
coinGrad.addColorStop(0, '#ffff88'); coinGrad.addColorStop(0.4, '#ffcc00'); coinGrad.addColorStop(0.8, '#ff9900'); coinGrad.addColorStop(1, '#663300');
dctx.beginPath(); dctx.arc(cx, cy, r, 0, Math.PI*2); dctx.fillStyle = coinGrad; dctx.fill();
dctx.strokeStyle = '#fff888'; dctx.lineWidth = 2; dctx.stroke();
dctx.beginPath(); dctx.arc(cx, cy, r * 0.75, 0, Math.PI*2);
dctx.strokeStyle = '#ffaa00'; dctx.lineWidth = 1.5; dctx.stroke();
dctx.font = `bold ${r * 1.1}px Segoe UI`; dctx.textAlign = 'center'; dctx.textBaseline = 'middle';
dctx.fillStyle = '#663300'; dctx.fillText('★', cx, cy + 1);
dctx.beginPath(); dctx.arc(cx - r*0.3, cy - r*0.4, 2, 0, Math.PI*2);
dctx.fillStyle = 'rgba(255,255,255,0.9)'; dctx.fill();
sprites.discount = c;
}
function prerenderBoost() {
const size = 64; const c = makeCanvas(size, size); const bctx = c.getContext('2d');
const cx = size/2, cy = size/2, r = 15;
const crystalGrad = bctx.createLinearGradient(cx - r, cy - r, cx + r, cy + r);
crystalGrad.addColorStop(0, '#aaffcc'); crystalGrad.addColorStop(0.5, '#33ff88'); crystalGrad.addColorStop(1, '#006633');
bctx.beginPath(); bctx.moveTo(cx, cy - r*1.3); bctx.lineTo(cx + r*0.8, cy); bctx.lineTo(cx, cy + r*1.3); bctx.lineTo(cx - r*0.8, cy);
bctx.closePath(); bctx.fillStyle = crystalGrad; bctx.fill();
bctx.strokeStyle = '#aaffcc'; bctx.lineWidth = 1.5; bctx.stroke();
bctx.beginPath(); bctx.moveTo(cx, cy - r*1.3); bctx.lineTo(cx, cy + r*1.3); bctx.moveTo(cx - r*0.8, cy); bctx.lineTo(cx + r*0.8, cy);
bctx.strokeStyle = 'rgba(255,255,255,0.5)'; bctx.lineWidth = 1; bctx.stroke();
sprites.boost = c;
}
function prerenderShield() {
const size = 64; const c = makeCanvas(size, size); const sctx = c.getContext('2d');
const cx = size/2, cy = size/2, r = 15;
const shieldGrad = sctx.createRadialGradient(cx - r*0.3, cy - r*0.3, 1, cx, cy, r);
shieldGrad.addColorStop(0, '#ffffff'); shieldGrad.addColorStop(0.4, '#66ddff'); shieldGrad.addColorStop(1, '#004488');
sctx.beginPath();
for (let i = 0; i < 6; i++) { const a = (Math.PI/3) * i - Math.PI/2; const x = cx + Math.cos(a) * r; const y = cy + Math.sin(a) * r; if (i === 0) sctx.moveTo(x, y); else sctx.lineTo(x, y); }
sctx.closePath(); sctx.fillStyle = shieldGrad; sctx.fill();
sctx.strokeStyle = '#aaddff'; sctx.lineWidth = 2; sctx.stroke();
sctx.beginPath(); sctx.moveTo(cx, cy - r*0.4); sctx.lineTo(cx + r*0.5, cy - r*0.2); sctx.lineTo(cx + r*0.5, cy + r*0.2);
sctx.quadraticCurveTo(cx + r*0.3, cy + r*0.6, cx, cy + r*0.7); sctx.quadraticCurveTo(cx - r*0.3, cy + r*0.6, cx - r*0.5, cy + r*0.2);
sctx.lineTo(cx - r*0.5, cy - r*0.2); sctx.closePath(); sctx.fillStyle = 'rgba(255,255,255,0.8)'; sctx.fill();
sprites.shield = c;
}
function prerenderOrb() {
const size = 64; const c = makeCanvas(size, size); const octx = c.getContext('2d');
const cx = size/2, cy = size/2, r = 13;
const grad = octx.createRadialGradient(cx - r*0.3, cy - r*0.3, 1, cx, cy, r);
grad.addColorStop(0, '#ffffff'); grad.addColorStop(0.4, '#aaffff'); grad.addColorStop(0.8, '#00ffff'); grad.addColorStop(1, '#0055ff');
octx.beginPath(); octx.arc(cx, cy, r, 0, Math.PI*2); octx.fillStyle = grad; octx.fill();
octx.beginPath(); octx.arc(cx - r*0.3, cy - r*0.3, r*0.25, 0, Math.PI*2); octx.fillStyle = 'rgba(255,255,255,0.9)'; octx.fill();
sprites.orb = c;
}
function prerenderProjectile() {
const size = 32; const c = makeCanvas(size, size); const pctx = c.getContext('2d');
const cx = size/2, cy = size/2, r = 8;
const grad = pctx.createRadialGradient(cx, cy, 1, cx, cy, r);
grad.addColorStop(0, '#ffffff'); grad.addColorStop(0.3, '#ffaaaa'); grad.addColorStop(0.7, '#ff3355'); grad.addColorStop(1, '#660011');
pctx.beginPath(); pctx.arc(cx, cy, r, 0, Math.PI*2); pctx.fillStyle = grad; pctx.fill();
sprites.projectile = c;
}
function prerenderWeapon() {
const size = 64; const c = makeCanvas(size, size); const wctx = c.getContext('2d');
const cx = size/2, cy = size/2, r = 15;
const grad = wctx.createRadialGradient(cx - r*0.3, cy - r*0.3, 1, cx, cy, r);
grad.addColorStop(0, '#ffffff'); grad.addColorStop(0.4, '#88ddff'); grad.addColorStop(0.8, '#00aaff'); grad.addColorStop(1, '#003366');
wctx.beginPath(); wctx.arc(cx, cy, r, 0, Math.PI*2); wctx.fillStyle = grad; wctx.fill();
wctx.font = `bold ${r*1.2}px Segoe UI`; wctx.textAlign = 'center'; wctx.textBaseline = 'middle';
wctx.fillStyle = '#003366'; wctx.fillText('🔫', cx, cy + 1);
sprites.weapon = c;
}
function prerenderBullet() {
const size = 16; const c = makeCanvas(size, size); const bctx = c.getContext('2d');
const cx = size/2, cy = size/2, r = 4;
const grad = bctx.createRadialGradient(cx, cy, 0, cx, cy, r);
grad.addColorStop(0, '#ffffff'); grad.addColorStop(0.5, '#88ddff'); grad.addColorStop(1, 'rgba(0,170,255,0)');
bctx.beginPath(); bctx.arc(cx, cy, r, 0, Math.PI*2); bctx.fillStyle = grad; bctx.fill();
sprites.bullet = c;
}
function prerenderBoss() {
const size = 140; const c = makeCanvas(size, size); const bctx = c.getContext('2d');
const cx = size/2, cy = size/2, r = 45;
bctx.strokeStyle = 'rgba(255,100,255,0.5)'; bctx.lineWidth = 2;
for (let i = 0; i < 6; i++) {
const a = (Math.PI*2/6) * i;
bctx.beginPath(); bctx.moveTo(cx + Math.cos(a) * r * 0.5, cy + Math.sin(a) * r * 0.5);
bctx.quadraticCurveTo(cx + Math.cos(a + 0.3) * r * 1.1, cy + Math.sin(a + 0.3) * r * 1.1, cx + Math.cos(a) * r * 1.3, cy + Math.sin(a) * r * 1.3);
bctx.stroke();
}
const bGrad = bctx.createRadialGradient(cx - r*0.3, cy - r*0.3, 5, cx, cy, r);
bGrad.addColorStop(0, '#ddaaff'); bGrad.addColorStop(0.3, '#9933ff'); bGrad.addColorStop(0.7, '#5500aa'); bGrad.addColorStop(1, '#220033');
bctx.beginPath(); bctx.arc(cx, cy, r, 0, Math.PI*2); bctx.fillStyle = bGrad; bctx.fill();
bctx.fillStyle = '#2a0044'; bctx.strokeStyle = '#ff66ff'; bctx.lineWidth = 2;
[-1, 1].forEach(side => {
bctx.beginPath(); bctx.moveTo(cx + side * r * 0.5, cy - r * 0.7);
bctx.quadraticCurveTo(cx + side * r * 1.2, cy - r * 1.3, cx + side * r * 0.9, cy - r * 1.6);
bctx.quadraticCurveTo(cx + side * r * 0.8, cy - r * 1.2, cx + side * r * 0.3, cy - r * 0.8);
bctx.closePath(); bctx.fill(); bctx.stroke();
});
bctx.beginPath(); bctx.arc(cx, cy, r * 0.55, 0, Math.PI*2);
bctx.fillStyle = '#fff'; bctx.fill(); bctx.strokeStyle = '#ff00ff'; bctx.lineWidth = 2; bctx.stroke();
sprites.boss = c;
}
function initSprites() {
prerenderStars(); prerenderBackground(); prerenderPlayer(); prerenderMine();
prerenderDiscount(); prerenderBoost(); prerenderShield(); prerenderOrb();
prerenderProjectile(); prerenderWeapon(); prerenderBullet(); prerenderBoss();
}
// ===== СОСТОЯНИЕ =====
let state = 'intro';
let score, discount, hp, time, speed;
let player, items, particles, stars;
let isDragging = false;
let boss, bossProjectiles, damageOrbs, bossDefeated;
let screenShake = 0;
let spawnTimer = 0, orbTimer = 0;
let lastTime = 0, fpsInterval = 1000/60;
let bullets = [];
let copyFeedback = 0;
let trailParticles = [];
const keys = {};
addEventListener('keydown', e => {
keys[e.key.toLowerCase()] = true;
if (e.key === ' ') {
e.preventDefault();
if (state === 'play') shoot();
}
});
addEventListener('keyup', e => keys[e.key.toLowerCase()] = false);
function getMousePos(evt) {
const rect = canvas.getBoundingClientRect();
return { x: (evt.clientX - rect.left) * (W / rect.width), y: (evt.clientY - rect.top) * (H / rect.height) };
}
function copyToClipboard(text) {
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).catch(() => {});
} else {
const ta = document.createElement('textarea');
ta.value = text;
ta.style.position = 'fixed';
ta.style.opacity = '0';
document.body.appendChild(ta);
ta.select();
try { document.execCommand('copy'); } catch(e) {}
document.body.removeChild(ta);
}
}
function handleClick(pos) {
if (pos.x > W - 55 && pos.y > 10 && pos.y < 55) {
soundEnabled = !soundEnabled;
return;
}
if (state === 'intro') {
if (pos.y > H/2 + 100 && pos.y < H/2 + 160) {
state = 'rules';
return;
}
}
if (state === 'rules') {
if (pos.y > H - 150 && pos.y < H - 80) {
reset();
return;
}
}
if (state === 'over') {
if (pos.y > H/2 + 80 && pos.y < H/2 + 180) {
reset();
return;
}
}
if (state === 'win') {
if (!promoRevealed && currentPromo) {
const promoY = H/2 + 55;
if (pos.x > W/2 - 120 && pos.x < W/2 + 120 && pos.y > promoY - 25 && pos.y < promoY + 25) {
promoRevealed = true;
playSound('powerup');
for (let i = 0; i < 20; i++) {
promoParticles.push({
x: W/2 + (Math.random() - 0.5) * 200,
y: promoY + (Math.random() - 0.5) * 40,
vx: (Math.random() - 0.5) * 4,
vy: (Math.random() - 0.5) * 4 - 2,
life: 30,
maxLife: 30,
color: '#ffcc00'
});
}
return;
}
}
if (promoRevealed && currentPromo) {
const copyBtnY = H/2 + 105;
if (pos.y > copyBtnY - 20 && pos.y < copyBtnY + 20 && pos.x > W/2 - 80 && pos.x < W/2 + 80) {
copyToClipboard(currentPromo.code);
copyFeedback = 90;
playSound('coin');
return;
}
}
if (pos.y > H/2 + 180 && pos.y < H/2 + 260) {
reset();
return;
}
}
if (state === 'play') {
isDragging = true;
player.x = pos.x;
player.vx = 0;
shoot();
}
}
canvas.addEventListener('mousedown', e => {
initAudio();
handleClick(getMousePos(e));
});
canvas.addEventListener('mousemove', e => {
if (isDragging && state === 'play') {
const pos = getMousePos(e);
player.x = pos.x;
player.vx = 0;
}
});
canvas.addEventListener('mouseup', () => isDragging = false);
canvas.addEventListener('mouseleave', () => isDragging = false);
canvas.addEventListener('touchstart', e => {
e.preventDefault();
initAudio();
handleClick(getMousePos(e.touches[0]));
}, {passive: false});
canvas.addEventListener('touchmove', e => {
e.preventDefault();
if (isDragging && state === 'play') {
const pos = getMousePos(e.touches[0]);
player.x = pos.x;
player.vx = 0;
}
}, {passive: false});
canvas.addEventListener('touchend', () => isDragging = false);
const TYPES = { mine: { r: 16 }, boost: { r: 15 }, shield: { r: 15 }, discount: { r: 15 }, weapon: { r: 15 } };
function reset() {
state = 'play'; score = 0; discount = 0; hp = 3; time = 0; speed = 2.6;
player = { x: W/2, y: H - 90, r: 15, vx: 0, shield: 0, boost: 0, invuln: 60, trail: [], ammo: 0 };
items = []; particles = []; bossProjectiles = []; damageOrbs = []; bullets = [];
isDragging = false; boss = null; bossDefeated = false; screenShake = 0;
copyFeedback = 0;
currentPromo = null;
promoRevealed = false;
promoParticles = [];
trailParticles = [];
stars = Array.from({length: 70}, () => ({
x: Math.random()*W, y: Math.random()*H,
size: Math.random() > 0.7 ? 'big' : 'small',
s: Math.random()*1.5 + 0.5, v: Math.random()*2 + 0.5,
twinkle: Math.random() * Math.PI * 2
}));
}
function shoot() {
if (player.ammo > 0 && state === 'play') {
player.ammo--;
bullets.push({ x: player.x, y: player.y - player.r, vy: -12 });
playSound('shoot');
}
}
function spawnItem() {
const roll = Math.random();
let type;
if (boss && !bossDefeated) {
if (roll < 0.35) type = 'mine';
else if (roll < 0.55) type = 'boost';
else if (roll < 0.75) type = 'shield';
else type = 'weapon';
} else {
// Увеличен шанс выпадения звезд (+1 очко), чтобы игра шла быстрее
if (roll < 0.60) type = 'mine';
else if (roll < 0.85) type = 'discount';
else if (roll < 0.91) type = 'boost';
else if (roll < 0.97) type = 'shield';
else type = 'weapon';
}
items.push({
x: Math.random() * (W - 40) + 20,
y: -20, type, r: TYPES[type].r,
wobble: Math.random() * Math.PI * 2,
rotation: Math.random() * Math.PI * 2,
vy: speed * (0.9 + Math.random() * 0.6)
});
}
function burst(x, y, color, count = 12) {
if (particles.length > 150) count = Math.min(count, 5);
for (let i = 0; i < count; i++) {
const a = Math.random() * Math.PI * 2;
const sp = Math.random() * 5 + 1;
particles.push({ x, y, vx: Math.cos(a)*sp, vy: Math.sin(a)*sp, life: 30 + Math.random()*20, maxLife: 30, color, size: Math.random()*3+1, gravity: 0.05 });
}
}
function shieldExplosion(x, y) {
const radius = 120;
playSound('explosion');
screenShake = 20;
for (let i = items.length - 1; i >= 0; i--) {
const it = items[i];
if (it.type === 'mine') {
const dx = it.x - x, dy = it.y - y;
if (dx*dx + dy*dy < radius*radius) { burst(it.x, it.y, '#ff3355', 15); score += 1; items.splice(i, 1); }
}
}
for (let i = bossProjectiles.length - 1; i >= 0; i--) {
const p = bossProjectiles[i];
const dx = p.x - x, dy = p.y - y;
if (dx*dx + dy*dy < radius*radius) { burst(p.x, p.y, '#ff3355', 8); bossProjectiles.splice(i, 1); }
}
burst(x, y, '#33ccff', 40); burst(x, y, '#ffffff', 20); burst(x, y, '#00ffff', 30);
}
function update() {
if (copyFeedback > 0) copyFeedback--;
if (state !== 'play') {
for (let i = promoParticles.length - 1; i >= 0; i--) {
const p = promoParticles[i];
p.x += p.vx; p.y += p.vy; p.vy += 0.15;
p.life--;
if (p.life <= 0) promoParticles.splice(i, 1);
}
return;
}
time++; speed = 2.6 + time * 0.0012;
if (screenShake > 0) screenShake *= 0.9;
const accel = 0.8;
const maxV = 6.5 + (player.boost > 0 ? 2.5 : 0);
if (!isDragging) {
if (keys['arrowleft'] || keys['a'] || keys['ф']) player.vx -= accel;
if (keys['arrowright'] || keys['d'] || keys['в']) player.vx += accel;
player.vx *= 0.85; player.vx = Math.max(-maxV, Math.min(maxV, player.vx)); player.x += player.vx;
}
player.x = Math.max(player.r, Math.min(W - player.r, player.x));
for (let i = 0; i < 2; i++) {
if (Math.random() > 0.3) {
trailParticles.push({
x: player.x + (Math.random() - 0.5) * 10,
y: player.y + player.r * 0.8,
vx: (Math.random() - 0.5) * 0.8,
vy: Math.random() * 1.5 + 0.5,
life: 25 + Math.random() * 15,
maxLife: 40,
size: Math.random() * 4 + 2,
color: player.boost > 0 ? '#33ff88' : '#4a4aff'
});
}
}
for (let i = trailParticles.length - 1; i >= 0; i--) {
const t = trailParticles[i];
t.x += t.vx; t.y += t.vy;
t.vx *= 0.95; t.vy *= 0.95;
t.life--;
t.size *= 0.97;
if (t.life <= 0) trailParticles.splice(i, 1);
}
if (Math.abs(player.vx) > 1 || time % 2 === 0) {
player.trail.push({ x: player.x, y: player.y, life: 12 });
if (player.trail.length > 8) player.trail.shift();
}
for (let i = player.trail.length - 1; i >= 0; i--) { player.trail[i].life--; if (player.trail[i].life <= 0) player.trail.splice(i, 1); }
if (player.shield > 0) player.shield--; if (player.boost > 0) player.boost--; if (player.invuln > 0) player.invuln--;
for (let i = bullets.length - 1; i >= 0; i--) {
const b = bullets[i]; b.y += b.vy;
let hit = false;
for (let j = items.length - 1; j >= 0; j--) {
const it = items[j];
if (it.type === 'mine') {
const dx = b.x - it.x, dy = b.y - it.y;
if (dx*dx + dy*dy < (it.r + 5) * (it.r + 5)) { burst(it.x, it.y, '#ff3355', 15); playSound('explosion'); items.splice(j, 1); score += 2; hit = true; break; }
}
}
if (!hit && boss) {
const dx = b.x - boss.x, dy = b.y - boss.y;
if (dx*dx + dy*dy < (boss.r + 5) * (boss.r + 5)) {
boss.hp--; burst(b.x, b.y, '#00aaff', 15); playSound('shoot'); hit = true;
if (boss.hp <= 0) {
burst(boss.x, boss.y, '#ffaa00', 60); burst(boss.x, boss.y, '#ffffff', 40); playSound('bossDie');
score += 20; if (hp < 3) hp++;
boss = null; bossDefeated = true; bossProjectiles = []; damageOrbs = []; screenShake = 25;
}
}
}
if (hit || b.y < -20) bullets.splice(i, 1);
}
if (!boss && !bossDefeated && score >= 20) { boss = { x: W/2, y: -100, r: 45, hp: 15, maxHp: 15, vx: 3, shootTimer: 40, phase: 0, pulse: 0 }; }
if (boss) {
boss.phase += 0.04; boss.pulse += 0.08;
boss.y += (130 - boss.y) * 0.04; boss.x += boss.vx;
if (boss.x > W - boss.r || boss.x < boss.r) boss.vx *= -1;
boss.shootTimer--;
if (boss.shootTimer <= 0) {
for (let i = -1; i <= 1; i++) bossProjectiles.push({ x: boss.x, y: boss.y + boss.r/2, vx: i * 2.5, vy: 5 + Math.random()*2, r: 8 });
boss.shootTimer = Math.max(25, 60 - Math.floor(time/500)*10);
}
if (damageOrbs.length < 2) {
orbTimer--; if (orbTimer <= 0) {
damageOrbs.push({ x: Math.random() * (W - 40) + 20, y: -20, r: 13, vy: 3 + Math.random() * 2, wobble: Math.random() * Math.PI * 2, pulse: 0 });
orbTimer = 60 + Math.random() * 60;
}
}
}
for (let i = bossProjectiles.length - 1; i >= 0; i--) {
const p = bossProjectiles[i]; p.x += p.vx; p.y += p.vy;
const dx = p.x - player.x, dy = p.y - player.y; const rad = p.r + player.r;
if (dx*dx + dy*dy < rad*rad) {
if (player.shield > 0) { player.shield = 0; shieldExplosion(player.x, player.y); }
else if (player.invuln <= 0) { hp--; player.invuln = 60; screenShake = 15; playSound('hurt'); burst(p.x, p.y, '#ff3355', 25); }
bossProjectiles.splice(i, 1); continue;
}
if (p.y > H + 30 || p.x < -30 || p.x > W + 30) bossProjectiles.splice(i, 1);
}
for (let i = damageOrbs.length - 1; i >= 0; i--) {
const o = damageOrbs[i]; o.y += o.vy; o.wobble += 0.08; o.x += Math.sin(o.wobble) * 0.8; o.pulse += 0.15;
const dx = o.x - player.x, dy = o.y - player.y; const rad = o.r + player.r;
if (dx*dx + dy*dy < rad*rad) {
if (boss) {
boss.hp--; burst(o.x, o.y, '#00ffff', 25); screenShake = 8;
if (boss.hp <= 0) {
burst(boss.x, boss.y, '#ffaa00', 60); burst(boss.x, boss.y, '#ffffff', 40); playSound('bossDie');
score += 20; if (hp < 3) hp++;
boss = null; bossDefeated = true; bossProjectiles = []; damageOrbs = []; screenShake = 25;
}
}
damageOrbs.splice(i, 1); continue;
}
if (o.y > H + 30) damageOrbs.splice(i, 1);
}
spawnTimer--;
if (spawnTimer <= 0) { spawnItem(); spawnTimer = Math.max(14, 35 - time * 0.025); }
for (let i = items.length - 1; i >= 0; i--) {
const it = items[i]; it.y += it.vy; it.wobble += 0.08; it.rotation += 0.05; it.x += Math.sin(it.wobble) * 0.8;
const dx = it.x - player.x, dy = it.y - player.y; const rad = it.r + player.r;
if (dx*dx + dy*dy < rad*rad) { handleCollision(it); items.splice(i, 1); continue; }
if (it.y > H + 30) items.splice(i, 1);
}
for (let i = particles.length - 1; i >= 0; i--) {
const p = particles[i]; p.x += p.vx; p.y += p.vy; p.vy += p.gravity;
p.vx *= 0.94; p.vy *= 0.94; p.life--;
if (p.life <= 0) particles.splice(i, 1);
}
for (let i = 0; i < stars.length; i++) {
const s = stars[i]; s.y += s.v; s.twinkle += 0.1;
if (s.y > H) { s.y = 0; s.x = Math.random()*W; }
}
if (score >= 50) {
state = 'win';
burst(player.x, player.y, '#ffcc00', 80);
playSound('victory');
pickRandomPromo();
}
if (hp <= 0) { state = 'over'; burst(player.x, player.y, '#ff3355', 70); screenShake = 20; playSound('explosion'); }
}
function handleCollision(it) {
if (it.type === 'mine') {
if (player.shield > 0) { player.shield = 0; shieldExplosion(player.x, player.y); }
else if (player.invuln <= 0) { hp--; player.invuln = 80; screenShake = 15; playSound('hurt'); burst(it.x, it.y, '#ff3355', 40); }
} else if (it.type === 'discount') {
if (score < 50) { score += 2; playSound('coin'); burst(it.x, it.y, '#ffcc00', 30); } // +2 очка за звезду
} else if (it.type === 'boost') {
player.boost = 150; playSound('powerup'); burst(it.x, it.y, '#33ff88', 25);
} else if (it.type === 'shield') {
player.shield = 250; playSound('powerup'); burst(it.x, it.y, '#33ccff', 25);
} else if (it.type === 'weapon') {
player.ammo += 5; score += 1; playSound('powerup'); burst(it.x, it.y, '#00aaff', 25);
}
}
// ===== ОТРИСОВКА =====
function draw() {
ctx.drawImage(sprites.background, 0, 0);
for (let i = 0; i < stars.length; i++) {
const s = stars[i]; const tw = 0.5 + Math.sin(s.twinkle) * 0.5;
ctx.globalAlpha = 0.3 + tw * 0.7;
const sprite = s.size === 'big' ? sprites.starBig : sprites.starSmall;
ctx.drawImage(sprite, s.x - sprite.width/2, s.y - sprite.height/2);
}
ctx.globalAlpha = 1;
if (state === 'intro') { drawIntro(); return; }
if (state === 'rules') { drawRules(); return; }
ctx.save();
if (screenShake > 0.5) ctx.translate((Math.random() - 0.5) * screenShake, (Math.random() - 0.5) * screenShake);
for (let i = 0; i < trailParticles.length; i++) {
const t = trailParticles[i];
const alpha = t.life / t.maxLife;
ctx.globalAlpha = alpha * 0.6;
ctx.fillStyle = t.color;
ctx.beginPath();
ctx.arc(t.x, t.y, t.size * alpha, 0, Math.PI * 2);
ctx.fill();
}
ctx.globalAlpha = 1;
for (let i = 0; i < damageOrbs.length; i++) {
const o = damageOrbs[i]; const scale = 1 + Math.sin(o.pulse) * 0.15;
ctx.save(); ctx.translate(o.x, o.y); ctx.scale(scale, scale);
ctx.shadowBlur = 15; ctx.shadowColor = '#00ffff';
ctx.drawImage(sprites.orb, -sprites.orb.width/2, -sprites.orb.height/2);
ctx.restore();
}
for (let i = 0; i < items.length; i++) {
const it = items[i];
if (it.y < -50 || it.y > H + 50) continue;
if (it.type === 'mine') {
ctx.save(); ctx.translate(it.x, it.y); ctx.rotate(it.rotation);
ctx.shadowBlur = 15; ctx.shadowColor = '#ff0033';
ctx.drawImage(sprites.mine, -sprites.mine.width/2, -sprites.mine.height/2); ctx.restore();
} else if (it.type === 'discount') {
const wobbleX = 0.7 + Math.abs(Math.sin(it.rotation)) * 0.3;
ctx.save(); ctx.translate(it.x, it.y); ctx.scale(wobbleX, 1);
ctx.shadowBlur = 15; ctx.shadowColor = '#ffaa00';
ctx.drawImage(sprites.discount, -sprites.discount.width/2, -sprites.discount.height/2); ctx.restore();
} else if (it.type === 'boost') {
ctx.save(); ctx.translate(it.x, it.y); ctx.rotate(Math.sin(it.rotation*0.5) * 0.2);
ctx.shadowBlur = 15; ctx.shadowColor = '#00ff66';
ctx.drawImage(sprites.boost, -sprites.boost.width/2, -sprites.boost.height/2); ctx.restore();
} else if (it.type === 'shield') {
ctx.save(); ctx.translate(it.x, it.y); ctx.rotate(it.rotation * 0.3);
ctx.shadowBlur = 15; ctx.shadowColor = '#00aaff';
ctx.drawImage(sprites.shield, -sprites.shield.width/2, -sprites.shield.height/2); ctx.restore();
} else if (it.type === 'weapon') {
ctx.save(); ctx.translate(it.x, it.y);
ctx.shadowBlur = 15; ctx.shadowColor = '#00aaff';
ctx.drawImage(sprites.weapon, -sprites.weapon.width/2, -sprites.weapon.height/2); ctx.restore();
}
}
for (let i = 0; i < bullets.length; i++) {
const b = bullets[i];
ctx.shadowBlur = 15; ctx.shadowColor = '#00aaff';
ctx.drawImage(sprites.bullet, b.x - sprites.bullet.width/2, b.y - sprites.bullet.height/2);
}
ctx.shadowBlur = 0;
for (let i = 0; i < bossProjectiles.length; i++) {
const p = bossProjectiles[i];
ctx.drawImage(sprites.projectile, p.x - sprites.projectile.width/2, p.y - sprites.projectile.height/2);
}
if (boss) drawBoss();
for (let i = 0; i < particles.length; i++) {
const p = particles[i]; ctx.globalAlpha = p.life / p.maxLife; ctx.fillStyle = p.color;
ctx.fillRect(p.x - p.size/2, p.y - p.size/2, p.size, p.size);
}
ctx.globalAlpha = 1;
drawPlayer();
ctx.restore();
ctx.save();
ctx.globalAlpha = 0.15;
ctx.font = 'bold 10px Segoe UI';
ctx.fillStyle = '#aaaaff';
ctx.textAlign = 'right';
ctx.textBaseline = 'bottom';
ctx.fillText('ELAKOMEN VPN', W - 15, H - 10);
ctx.restore();
drawUI();
if (state === 'over') drawGameOver();
if (state === 'win') drawWin();
}
function drawBoss() {
const auraR = boss.r * (2 + Math.sin(boss.pulse) * 0.2);
const auraGrad = ctx.createRadialGradient(boss.x, boss.y, boss.r*0.5, boss.x, boss.y, auraR);
auraGrad.addColorStop(0, 'rgba(170,0,255,0.5)'); auraGrad.addColorStop(0.5, 'rgba(170,0,255,0.2)'); auraGrad.addColorStop(1, 'transparent');
ctx.fillStyle = auraGrad; ctx.beginPath(); ctx.arc(boss.x, boss.y, auraR, 0, Math.PI*2); ctx.fill();
ctx.save(); ctx.translate(boss.x, boss.y); ctx.rotate(boss.phase * 0.2);
ctx.shadowBlur = 25; ctx.shadowColor = '#aa00ff';
ctx.drawImage(sprites.boss, -sprites.boss.width/2, -sprites.boss.height/2); ctx.restore();
const dx = player.x - boss.x, dy = player.y - boss.y;
const angle = Math.atan2(dy, dx);
const dist = Math.min(boss.r * 0.15, Math.sqrt(dx*dx + dy*dy) * 0.05);
const irisX = boss.x + Math.cos(angle) * dist, irisY = boss.y + Math.sin(angle) * dist;
const irisGrad = ctx.createRadialGradient(irisX, irisY, 1, irisX, irisY, boss.r * 0.3);
irisGrad.addColorStop(0, '#ff4444'); irisGrad.addColorStop(0.6, '#aa0000'); irisGrad.addColorStop(1, '#330000');
ctx.beginPath(); ctx.arc(irisX, irisY, boss.r * 0.3, 0, Math.PI*2); ctx.fillStyle = irisGrad; ctx.fill();
ctx.beginPath(); ctx.arc(irisX, irisY, boss.r * 0.12, 0, Math.PI*2); ctx.fillStyle = '#000'; ctx.fill();
ctx.beginPath(); ctx.arc(irisX - boss.r*0.08, irisY - boss.r*0.08, boss.r*0.06, 0, Math.PI*2); ctx.fillStyle = 'rgba(255,255,255,0.9)'; ctx.fill();
const hpW = 130, hpX = boss.x - hpW/2, hpY = boss.y - boss.r - 30;
ctx.fillStyle = 'rgba(0,0,0,0.8)'; ctx.fillRect(hpX - 2, hpY - 2, hpW + 4, 14);
const hpRatio = boss.hp / boss.maxHp;
ctx.fillStyle = hpRatio > 0.5 ? '#ff3355' : hpRatio > 0.25 ? '#ff8833' : '#ffcc00';
ctx.fillRect(hpX, hpY, hpW * hpRatio, 10);
ctx.strokeStyle = '#fff'; ctx.lineWidth = 1; ctx.strokeRect(hpX, hpY, hpW, 10);
ctx.font = 'bold 11px Segoe UI'; ctx.textAlign = 'center'; ctx.fillStyle = '#fff';
ctx.fillText('BOSS ' + boss.hp + '/' + boss.maxHp, boss.x, hpY + 9);
}
function drawPlayer() {
if (state !== 'play' && state !== 'win') return;
for (let i = 0; i < player.trail.length; i++) {
const t = player.trail[i]; const alpha = (t.life / 12) * 0.4;
ctx.beginPath(); ctx.arc(t.x, t.y, player.r * (t.life/12), 0, Math.PI*2);
ctx.fillStyle = `rgba(100,100,255,${alpha})`; ctx.fill();
}
if (player.shield > 0) {
const shieldR = player.r + 12 + Math.sin(time*0.2)*2;
ctx.beginPath(); ctx.arc(player.x, player.y, shieldR, 0, Math.PI*2);
ctx.strokeStyle = `rgba(51,204,255,${0.6 + Math.sin(time*0.25)*0.3})`;
ctx.lineWidth = 2; ctx.stroke();
for (let i = 0; i < 4; i++) {
const a = (Math.PI*2/4) * i + time*0.05;
ctx.beginPath(); ctx.arc(player.x + Math.cos(a)*shieldR, player.y + Math.sin(a)*shieldR, 2, 0, Math.PI*2);
ctx.fillStyle = '#33ccff'; ctx.fill();
}
}
const sprite = player.boost > 0 ? sprites.playerBoost : sprites.player;
ctx.save();
ctx.shadowBlur = 20; ctx.shadowColor = player.boost > 0 ? '#33ff88' : '#4a4aff';
if (player.invuln > 0 && Math.floor(player.invuln/5) % 2 === 0) ctx.globalAlpha = 0.3;
ctx.drawImage(sprite, player.x - sprite.width/2, player.y - sprite.height/2);
ctx.restore();
}
function drawUI() {
ctx.save();
ctx.textAlign = 'left'; ctx.textBaseline = 'top';
ctx.fillStyle = 'rgba(10,10,30,0.7)';
ctx.beginPath(); ctx.roundRect(10, 10, 200, 120, 10); ctx.fill();
ctx.strokeStyle = '#4a4aff'; ctx.lineWidth = 1; ctx.stroke();
ctx.font = 'bold 18px Segoe UI'; ctx.fillStyle = '#aaaaff'; ctx.fillText('Очки: ' + score, 20, 20);
ctx.font = 'bold 22px Segoe UI'; ctx.fillStyle = '#ffcc00'; ctx.fillText('🎯 ' + score + ' / 50', 20, 45);
for (let i = 0; i < 3; i++) {
ctx.font = '20px serif'; ctx.globalAlpha = i < hp ? 1 : 0.2;
ctx.fillText('❤️', 20 + i*26, 75);
}
ctx.globalAlpha = 1;
let yStatus = 105;
if (player.boost > 0) { ctx.fillStyle = 'rgba(51,255,136,0.9)'; ctx.font = 'bold 13px Segoe UI'; ctx.fillText('⚡ ' + Math.ceil(player.boost/60) + 'с', 20, yStatus); yStatus += 18; }
if (player.shield > 0) { ctx.fillStyle = 'rgba(51,204,255,0.9)'; ctx.font = 'bold 13px Segoe UI'; ctx.fillText('🛡 АКТИВЕН', 20, yStatus); yStatus += 18; }
if (player.ammo > 0) { ctx.fillStyle = 'rgba(0,170,255,0.9)'; ctx.font = 'bold 13px Segoe UI'; ctx.fillText('🔫 ПАТРОНЫ: ' + player.ammo, 20, yStatus); }
if (boss) {
ctx.fillStyle = '#00ffff'; ctx.font = 'bold 14px Segoe UI'; ctx.textAlign = 'center';
ctx.fillText('🔵 УБЕЙ БОССА!', W/2, H - 25);
}
ctx.textAlign = 'right'; ctx.font = '26px serif';
ctx.fillStyle = 'rgba(10,10,30,0.7)';
ctx.beginPath(); ctx.roundRect(W - 55, 10, 45, 45, 10); ctx.fill();
ctx.strokeStyle = '#4a4aff'; ctx.lineWidth = 1; ctx.stroke();
ctx.fillStyle = '#fff'; ctx.textBaseline = 'middle'; ctx.textAlign = 'center';
ctx.fillText(soundEnabled ? '🔊' : '🔇', W - 32, 33);
ctx.restore();
}
function drawButton(text, x, y, w, h, color = '#ffcc00') {
ctx.save();
ctx.fillStyle = 'rgba(0,0,0,0.5)'; ctx.fillRect(x - w/2 + 3, y - h/2 + 3, w, h);
ctx.fillStyle = color; ctx.fillRect(x - w/2, y - h/2, w, h);
ctx.strokeStyle = '#ffffff'; ctx.lineWidth = 2; ctx.strokeRect(x - w/2, y - h/2, w, h);
ctx.fillStyle = '#1a1a3a'; ctx.font = 'bold 22px Segoe UI';
ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.fillText(text, x, y + 2);
ctx.restore();
}
function drawIntro() {
ctx.save(); ctx.textAlign = 'center';
ctx.font = 'bold 54px Segoe UI';
ctx.fillStyle = '#ffffff';
ctx.shadowBlur = 40; ctx.shadowColor = '#0055ff';
ctx.fillText('ELAKOMEN', W/2, H/2 - 120);
ctx.font = 'bold 64px Segoe UI';
ctx.fillStyle = '#4a4aff';
ctx.shadowBlur = 50; ctx.shadowColor = '#4a4aff';
ctx.fillText('VPN', W/2, H/2 - 60);
ctx.shadowBlur = 0;
drawButton('▶ ИГРАТЬ', W/2, H/2 + 130, 240, 70, '#00ffff');
ctx.font = 'bold 14px Segoe UI'; ctx.fillStyle = '#aaaaff';
ctx.fillText('Нажми для запуска звука', W/2, H/2 + 220);
ctx.restore();
}
function drawRules() {
ctx.save(); ctx.textAlign = 'center';
ctx.font = 'bold 32px Segoe UI';
ctx.fillStyle = '#00ffff';
ctx.shadowBlur = 20; ctx.shadowColor = '#00ffff';
ctx.fillText('ПРАВИЛА', W/2, 80);
ctx.shadowBlur = 0;
ctx.font = '16px Segoe UI';
ctx.fillStyle = '#ddddff';
// Исправлен интервал (34px вместо 28), чтобы текст не накладывался
const rulesText = [
'🎯 Цель: набрать 50 очков',
'💣 Избегай мин',
'⭐ Собирай звезды — +2 очка',
'⚡ Буст ускоряет',
'🛡️ Щит защищает',
'🔫 Оружие — стреляй — +1 очко',
'⚠️ На 20 очках прилетит БОСС',
'🔒 Очки блокируются, пока он жив!',
'🔵 Собирай сферы — урон боссу',
'💥 Щит при ударе = взрыв'
];
let startY = 140;
for (let i = 0; i < rulesText.length; i++) {
ctx.fillText(rulesText[i], W/2, startY + i * 34);
}
ctx.font = 'bold 18px Segoe UI';
ctx.fillStyle = '#ffaa00';
ctx.shadowBlur = 15; ctx.shadowColor = '#ffaa00';
ctx.fillText('🆘 ПОДДЕРЖКА', W/2, H - 180);
ctx.shadowBlur = 0;
ctx.font = '16px Segoe UI';
ctx.fillStyle = '#ffffff';
ctx.fillText('@elakomen в Telegram', W/2, H - 150);
ctx.font = '14px Segoe UI';
ctx.fillStyle = '#ff6666';
ctx.fillText('Встаёт в поддержке ТОЛЬКО ЗА ИГРЫ!', W/2, H - 120);
drawButton('▶ В БОЙ', W/2, H - 70, 240, 60, '#ff3366');
ctx.restore();
}
function drawGameOver() {
ctx.save();
ctx.fillStyle = 'rgba(5,5,15,0.92)'; ctx.fillRect(0, 0, W, H);
ctx.textAlign = 'center';
ctx.font = 'bold 42px Segoe UI'; ctx.fillStyle = '#ff3355';
ctx.shadowBlur = 25; ctx.shadowColor = '#ff3355'; ctx.fillText('ВЫ ПАЛИ', W/2, H/2 - 90);
ctx.shadowBlur = 0;
ctx.font = 'bold 24px Segoe UI'; ctx.fillStyle = '#ffcc00'; ctx.fillText('🎯 Очки: ' + score, W/2, H/2 - 30);
ctx.font = '20px Segoe UI'; ctx.fillStyle = '#aaaaff'; ctx.fillText('До победы оставалось: ' + Math.max(0, 50 - score), W/2, H/2 + 10);
ctx.font = 'bold 14px Segoe UI'; ctx.fillStyle = '#00ffff';
ctx.fillText('⚡ ELAKOMEN VPN ⚡', W/2, H/2 + 55);
drawButton('ЕЩЁ РАЗ', W/2, H/2 + 130, 240, 60);
ctx.restore();
}
function drawWin() {
ctx.save();
ctx.fillStyle = 'rgba(5,5,15,0.92)'; ctx.fillRect(0, 0, W, H);
for (let i = 0; i < promoParticles.length; i++) {
const p = promoParticles[i];
ctx.globalAlpha = p.life / p.maxLife;
ctx.fillStyle = p.color;
ctx.beginPath();
ctx.arc(p.x, p.y, 3, 0, Math.PI * 2);
ctx.fill();
}
ctx.globalAlpha = 1;
ctx.textAlign = 'center';
ctx.font = 'bold 46px Segoe UI'; ctx.fillStyle = '#ffcc00';
ctx.shadowBlur = 30; ctx.shadowColor = '#ffaa00'; ctx.fillText('🏆 ПОБЕДА! 🏆', W/2, H/2 - 130);
ctx.shadowBlur = 0;
ctx.font = 'bold 22px Segoe UI'; ctx.fillStyle = '#33ff88';
ctx.fillText('50 очков набрано!', W/2, H/2 - 80);
ctx.font = '18px Segoe UI'; ctx.fillStyle = '#aaaaff';
ctx.fillText('Очки: ' + score, W/2, H/2 - 50);
if (currentPromo) {
const promoY = H/2 + 55;
const promoW = 240;
const promoH = 50;
ctx.fillStyle = 'rgba(30, 30, 80, 0.9)';
ctx.beginPath();
ctx.roundRect(W/2 - promoW/2, promoY - promoH/2, promoW, promoH, 10);
ctx.fill();
ctx.strokeStyle = promoRevealed ? '#00ff88' : '#ffcc00';
ctx.lineWidth = 2;
ctx.stroke();
if (!promoRevealed) {
ctx.save();
ctx.font = 'bold 26px Segoe UI';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.filter = 'blur(8px)';
ctx.fillStyle = '#ffcc00';
ctx.fillText(currentPromo.code, W/2, promoY);
ctx.filter = 'none';
ctx.restore();
ctx.font = 'bold 13px Segoe UI';
ctx.fillStyle = '#ffcc00';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText('👆 НАЖМИ, ЧТОБЫ ОТКРЫТЬ', W/2, promoY + 35);
} else {
ctx.font = 'bold 26px Segoe UI';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillStyle = '#00ff88';
ctx.shadowBlur = 15;
ctx.shadowColor = '#00ff88';
ctx.fillText(currentPromo.code, W/2, promoY);
ctx.shadowBlur = 0;
ctx.font = 'bold 12px Segoe UI';
ctx.fillStyle = '#ffcc00';
ctx.fillText('СКИДКА ' + currentPromo.discount, W/2, promoY + 22);
const copyBtnY = H/2 + 105;
ctx.fillStyle = copyFeedback > 0 ? 'rgba(0,255,136,0.3)' : 'rgba(0,255,136,0.15)';
ctx.beginPath();
ctx.roundRect(W/2 - 80, copyBtnY - 18, 160, 36, 8);
ctx.fill();
ctx.strokeStyle = '#00ff88';
ctx.lineWidth = 1;
ctx.stroke();
ctx.font = 'bold 14px Segoe UI';
ctx.fillStyle = '#00ff88';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(copyFeedback > 0 ? '✅ СКОПИРОВАНО!' : '📋 СКОПИРОВАТЬ', W/2, copyBtnY);
}
}
ctx.font = '13px Segoe UI';
ctx.fillStyle = '#aaaaff';
ctx.textAlign = 'center';
ctx.fillText('Активируй в боте: @elakomen_VPN_bot', W/2, H/2 + 155);
drawButton('СНОВА В БОЙ', W/2, H/2 + 215, 240, 60);
ctx.restore();
}
function loop(now) {
requestAnimationFrame(loop);
const elapsed = now - lastTime;
if (elapsed < fpsInterval) return;
lastTime = now - (elapsed % fpsInterval);
update();
draw();
}
initSprites();
reset();
state = 'intro';
requestAnimationFrame(loop);
</script>
</body>
</html>Game Source: VPN Ball — Elakomen Edition
Creator: SolarPenguin64
Libraries: none
Complexity: complex (1200 lines, 48.8 KB)
The full source code is displayed above on this page.
Remix Instructions
To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: vpn-ball-elakomen-edition-solarpenguin64" to link back to the original. Then publish at arcadelab.ai/publish.