Files
NeonPlaformer/js/levels.js

690 lines
32 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* ═══════════════════════════════════════════════════════════════
GAME LEVELS - Level definitions for multi-level platformer
═══════════════════════════════════════════════════════════════ */
const LEVELS = [
// ═══════════════════════════════════════════════════════════════
// LEVEL 1 - Tutorial
// ═══════════════════════════════════════════════════════════════
{
name: "НАЧАЛО",
playerStart: { x: 60, y: 420 },
platforms: [
// Ground
{ x: 0, y: 510, width: 900, height: 40, color: '#2a2a4a', isGround: true },
// Wall
{ x: 0, y: 0, width: 30, height: 550, color: '#1a1a3a', isGround: true },
// Platform
{ x: 870, y: 0, width: 30, height: 550, color: '#1a1a3a', },
// Platform
{ x: 150, y: 420, width: 120, height: 20, color: '#4a3a6a', },
// Platform
{ x: 320, y: 340, width: 100, height: 20, color: '#4a3a6a', },
// Platform
{ x: 480, y: 260, width: 120, height: 20, color: '#4a3a6a', },
// Platform
{ x: 280, y: 180, width: 100, height: 20, color: '#4a3a6a', },
// Platform
{ x: 550, y: 120, width: 150, height: 20, color: '#4a3a6a', },
// Platform
{ x: 100, y: 280, width: 80, height: 20, color: '#4a3a6a', },
],
movingPlatforms: [
{ x: 200, y: 300, width: 70, height: 18, color: '#6a5aaa', startX: 180, endX: 280, speed: 1.5, direction: 1, moveType: 'horizontal' },
],
coins: [
{ x: 200, y: 380 },
{ x: 360, y: 300 },
{ x: 530, y: 220 },
{ x: 320, y: 140 },
{ x: 620, y: 80 },
{ x: 140, y: 240 },
],
spikes: [
{ x: 400, y: 488, width: 30, height: 20 },
{ x: 600, y: 488, width: 30, height: 20 },
],
patrolEnemies: [
],
powerUps: [
],
checkpoints: [
{ x: 50, y: 470 },
],
flag: { x: 680, y: 60 },
portal: null
},
// ═══════════════════════════════════════════════════════════════
// LEVEL 2 - Moving Platforms
// ═══════════════════════════════════════════════════════════════
{
name: "НЕБО",
playerStart: { x: 60, y: 420 },
platforms: [
{ x: 0, y: 510, width: 200, height: 40, color: '#2a2a4a' },
{ x: 0, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 870, y: 0, width: 30, height: 550, color: '#1a1a3a' },
// Islands
{ x: 80, y: 380, width: 80, height: 20, color: '#4a3a6a' },
{ x: 300, y: 320, width: 80, height: 20, color: '#4a3a6a' },
{ x: 550, y: 250, width: 80, height: 20, color: '#4a3a6a' },
{ x: 750, y: 350, width: 100, height: 20, color: '#4a3a6a' },
{ x: 700, y: 150, width: 100, height: 20, color: '#4a3a6a' }
],
movingPlatforms: [
{ x: 220, y: 380, width: 70, height: 18, color: '#6a5aaa', startX: 200, endX: 320, speed: 2, direction: 1, moveType: 'horizontal' },
{ x: 420, y: 300, width: 70, height: 18, color: '#6a5aaa', startX: 400, endX: 520, speed: 1.8, direction: 1, moveType: 'horizontal' },
{ x: 650, y: 250, width: 60, height: 18, color: '#6a5aaa', startX: 620, endX: 720, speed: 2.2, direction: 1, moveType: 'horizontal' },
{ x: 450, y: 150, width: 70, height: 18, color: '#6a5aaa', startX: 400, endY: 150, endX: 600, speed: 2, direction: 1, moveType: 'horizontal' }
],
coins: [
{ x: 110, y: 340 },
{ x: 330, y: 280 },
{ x: 580, y: 210 },
{ x: 790, y: 310 },
{ x: 740, y: 110 },
{ x: 500, y: 110 }
],
spikes: [
{ x: 280, y: 488, width: 100, height: 22 },
{ x: 500, y: 488, width: 80, height: 22 }
],
patrolEnemies: [
{ x: 700, y: 320, patrolRange: 80, speed: 1.5 }
],
powerUps: [
{ x: 340, y: 100, type: 'doubleJump' }
],
checkpoints: [
{ x: 50, y: 470 },
{ x: 450, y: 270 }
],
flag: { x: 780, y: 110 },
portal: null
},
// ═══════════════════════════════════════════════════════════════
// LEVEL 3 - Enemies & Power-ups
// ═══════════════════════════════════════════════════════════════
{
name: "ОПАСНОСТЬ",
playerStart: { x: 60, y: 420 },
platforms: [
{ x: 0, y: 510, width: 250, height: 40, color: '#2a2a4a' },
{ x: 0, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 870, y: 0, width: 30, height: 550, color: '#1a1a3a' },
// Platforms with enemies
{ x: 100, y: 400, width: 100, height: 20, color: '#4a3a6a' },
{ x: 280, y: 350, width: 120, height: 20, color: '#4a3a6a' },
{ x: 500, y: 280, width: 100, height: 20, color: '#4a3a6a' },
{ x: 300, y: 200, width: 100, height: 20, color: '#4a3a6a' },
{ x: 550, y: 150, width: 120, height: 20, color: '#4a3a6a' },
{ x: 750, y: 250, width: 100, height: 20, color: '#4a3a6a' },
{ x: 700, y: 400, width: 150, height: 20, color: '#4a3a6a' }
],
movingPlatforms: [
{ x: 450, y: 180, width: 70, height: 18, color: '#6a5aaa', startX: 420, endX: 540, speed: 2.5, direction: 1, moveType: 'horizontal' }
],
coins: [
{ x: 140, y: 360 },
{ x: 330, y: 310 },
{ x: 540, y: 240 },
{ x: 340, y: 160 },
{ x: 600, y: 110 },
{ x: 790, y: 210 },
{ x: 770, y: 360 }
],
spikes: [
{ x: 350, y: 328, width: 40, height: 22 },
{ x: 600, y: 488, width: 60, height: 22 }
],
patrolEnemies: [
{ x: 300, y: 170, patrolRange: 80, speed: 2 },
{ x: 560, y: 120, patrolRange: 90, speed: 1.8 },
{ x: 720, y: 370, patrolRange: 100, speed: 2.2 }
],
powerUps: [
{ x: 560, y: 110, type: 'speedBoost' },
{ x: 780, y: 370, type: 'invincibility' }
],
checkpoints: [
{ x: 50, y: 470 },
{ x: 330, y: 170 }
],
flag: { x: 820, y: 60 },
portal: { x: 800, y: 60 }
},
// ═══════════════════════════════════════════════════════════════
// LEVEL 4 - Vertical Challenge
// ═══════════════════════════════════════════════════════════════
{
name: "ВЕРШИНА",
playerStart: { x: 60, y: 450 },
platforms: [
{ x: 0, y: 510, width: 250, height: 40, color: '#2a2a4a' },
{ x: 0, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 870, y: 0, width: 30, height: 550, color: '#1a1a3a' },
// Vertical climbing
{ x: 180, y: 420, width: 80, height: 18, color: '#4a3a6a' },
{ x: 80, y: 350, width: 80, height: 18, color: '#4a3a6a' },
{ x: 250, y: 320, width: 80, height: 18, color: '#4a3a6a' },
{ x: 450, y: 380, width: 80, height: 18, color: '#4a3a6a' },
{ x: 350, y: 280, width: 80, height: 18, color: '#4a3a6a' },
{ x: 550, y: 220, width: 80, height: 18, color: '#4a3a6a' },
{ x: 700, y: 280, width: 80, height: 18, color: '#4a3a6a' },
{ x: 600, y: 150, width: 100, height: 18, color: '#4a3a6a' },
{ x: 400, y: 100, width: 100, height: 18, color: '#4a3a6a' },
{ x: 700, y: 80, width: 100, height: 18, color: '#4a3a6a' }
],
movingPlatforms: [
{ x: 120, y: 280, width: 60, height: 18, color: '#6a5aaa', startX: 100, endX: 200, speed: 2, direction: 1, moveType: 'horizontal' },
{ x: 450, y: 120, width: 60, height: 18, color: '#6a5aaa', startX: 430, endX: 530, speed: 1.5, direction: 1, moveType: 'horizontal' }
],
coins: [
{ x: 210, y: 420 },
{ x: 110, y: 340 },
{ x: 280, y: 280 },
{ x: 480, y: 340 },
{ x: 380, y: 240 },
{ x: 580, y: 180 },
{ x: 730, y: 240 },
{ x: 640, y: 110 },
{ x: 440, y: 60 },
{ x: 740, y: 40 }
],
spikes: [
{ x: 300, y: 488, width: 60, height: 22 },
{ x: 500, y: 488, width: 80, height: 22 }
],
patrolEnemies: [
{ x: 370, y: 70, patrolRange: 70, speed: 2.5 }
],
powerUps: [
{ x: 420, y: 250, type: 'doubleJump' },
{ x: 600, y: 50, type: 'speedBoost' }
],
checkpoints: [
{ x: 50, y: 490 },
{ x: 350, y: 80 }
],
flag: { x: 770, y: 40 },
portal: null
},
// ═══════════════════════════════════════════════════════════════
// LEVEL 5 - Final Boss Stage
// ═══════════════════════════════════════════════════════════════
{
name: "ФИНАЛ",
playerStart: { x: 60, y: 450 },
platforms: [
{ x: 0, y: 510, width: 200, height: 40, color: '#2a2a4a' },
{ x: 0, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 870, y: 0, width: 30, height: 550, color: '#1a1a3a' },
// Gauntlet
{ x: 150, y: 440, width: 60, height: 18, color: '#4a3a6a' },
{ x: 280, y: 400, width: 60, height: 18, color: '#4a3a6a' },
{ x: 400, y: 360, width: 60, height: 18, color: '#4a3a6a' },
{ x: 520, y: 320, width: 60, height: 18, color: '#4a3a6a' },
{ x: 650, y: 280, width: 60, height: 18, color: '#4a3a6a' },
{ x: 750, y: 350, width: 100, height: 18, color: '#4a3a6a' },
{ x: 700, y: 200, width: 80, height: 18, color: '#4a3a6a' },
{ x: 500, y: 150, width: 80, height: 18, color: '#4a3a6a' },
{ x: 300, y: 120, width: 100, height: 18, color: '#4a3a6a' },
{ x: 100, y: 180, width: 100, height: 18, color: '#4a3a6a' },
{ x: 750, y: 80, width: 100, height: 18, color: '#4a3a6a' }
],
movingPlatforms: [
{ x: 230, y: 350, width: 50, height: 18, color: '#6a5aaa', startX: 220, endX: 300, speed: 3, direction: 1, moveType: 'horizontal' },
{ x: 580, y: 250, width: 50, height: 18, color: '#6a5aaa', startX: 560, endX: 660, speed: 2.5, direction: 1, moveType: 'horizontal' },
{ x: 400, y: 80, width: 60, height: 18, color: '#6a5aaa', startX: 380, endX: 480, speed: 2, direction: 1, moveType: 'horizontal' }
],
coins: [
{ x: 170, y: 400 },
{ x: 300, y: 360 },
{ x: 420, y: 320 },
{ x: 540, y: 280 },
{ x: 670, y: 240 },
{ x: 780, y: 310 },
{ x: 730, y: 160 },
{ x: 530, y: 110 },
{ x: 340, y: 80 },
{ x: 140, y: 140 },
{ x: 790, y: 40 }
],
spikes: [
{ x: 250, y: 488, width: 80, height: 22 },
{ x: 450, y: 488, width: 80, height: 22 },
{ x: 650, y: 488, width: 80, height: 22 }
],
patrolEnemies: [
{ x: 170, y: 150, patrolRange: 60, speed: 2 },
{ x: 320, y: 90, patrolRange: 70, speed: 2.5 },
{ x: 510, y: 120, patrolRange: 60, speed: 3 },
{ x: 760, y: 50, patrolRange: 60, speed: 2 }
],
powerUps: [
{ x: 730, y: 320, type: 'doubleJump' },
{ x: 510, y: 80, type: 'speedBoost' },
{ x: 130, y: 140, type: 'invincibility' }
],
checkpoints: [
{ x: 50, y: 470 },
{ x: 730, y: 50 }
],
flag: { x: 800, y: 40 },
portal: { x: 780, y: 40 }
},
// ═══════════════════════════════════════════════════════════════
// LEVEL 6 - The Gauntlet
// ═══════════════════════════════════════════════════════════════
{
name: "ИСПЫТАНИЕ",
playerStart: { x: 60, y: 450 },
platforms: [
{ x: 0, y: 510, width: 150, height: 40, color: '#2a2a4a' },
{ x: 0, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 870, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 180, y: 450, width: 60, height: 18, color: '#4a3a6a' },
{ x: 300, y: 400, width: 60, height: 18, color: '#4a3a6a' },
{ x: 420, y: 350, width: 60, height: 18, color: '#4a3a6a' },
{ x: 540, y: 300, width: 60, height: 18, color: '#4a3a6a' },
{ x: 660, y: 250, width: 60, height: 18, color: '#4a3a6a' },
{ x: 750, y: 350, width: 100, height: 18, color: '#4a3a6a' },
{ x: 600, y: 150, width: 80, height: 18, color: '#4a3a6a' },
{ x: 400, y: 100, width: 80, height: 18, color: '#4a3a6a' },
{ x: 200, y: 150, width: 80, height: 18, color: '#4a3a6a' },
{ x: 50, y: 220, width: 80, height: 18, color: '#4a3a6a' }
],
movingPlatforms: [
{ x: 250, y: 320, width: 50, height: 18, color: '#6a5aaa', startX: 230, endX: 310, speed: 2.5, direction: 1, moveType: 'horizontal' },
{ x: 480, y: 220, width: 50, height: 18, color: '#6a5aaa', startX: 460, endX: 540, speed: 2.2, direction: 1, moveType: 'horizontal' }
],
coins: [
{ x: 200, y: 410 }, { x: 320, y: 360 }, { x: 440, y: 310 },
{ x: 560, y: 260 }, { x: 680, y: 210 }, { x: 790, y: 310 },
{ x: 630, y: 110 }, { x: 430, y: 60 }, { x: 230, y: 110 },
{ x: 80, y: 180 }
],
spikes: [
{ x: 200, y: 488, width: 80, height: 22 }, { x: 400, y: 488, width: 80, height: 22 },
{ x: 600, y: 488, width: 80, height: 22 }
],
patrolEnemies: [
{ x: 380, y: 70, patrolRange: 60, speed: 3 }
],
powerUps: [
{ x: 750, y: 310, type: 'speedBoost' }
],
checkpoints: [
{ x: 50, y: 470 }, { x: 400, y: 70 }
],
flag: { x: 80, y: 180 },
portal: null
},
// ═══════════════════════════════════════════════════════════════
// LEVEL 7 - Speed Run
// ═══════════════════════════════════════════════════════════════
{
name: "ГОНКА",
playerStart: { x: 60, y: 420 },
platforms: [
{ x: 0, y: 510, width: 300, height: 40, color: '#2a2a4a' },
{ x: 0, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 870, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 350, y: 450, width: 80, height: 18, color: '#4a3a6a' },
{ x: 500, y: 380, width: 80, height: 18, color: '#4a3a6a' },
{ x: 650, y: 310, width: 80, height: 18, color: '#4a3a6a' },
{ x: 750, y: 400, width: 100, height: 18, color: '#4a3a6a' },
{ x: 700, y: 200, width: 80, height: 18, color: '#4a3a6a' },
{ x: 500, y: 150, width: 80, height: 18, color: '#4a3a6a' },
{ x: 300, y: 120, width: 80, height: 18, color: '#4a3a6a' },
{ x: 100, y: 180, width: 80, height: 18, color: '#4a3a6a' }
],
movingPlatforms: [
{ x: 200, y: 350, width: 60, height: 18, color: '#6a5aaa', startX: 180, endX: 280, speed: 3.5, direction: 1, moveType: 'horizontal' },
{ x: 400, y: 250, width: 60, height: 18, color: '#6a5aaa', startX: 380, endX: 480, speed: 3, direction: 1, moveType: 'horizontal' },
{ x: 600, y: 100, width: 60, height: 18, color: '#6a5aaa', startX: 580, endX: 680, speed: 2.5, direction: 1, moveType: 'horizontal' }
],
coins: [
{ x: 380, y: 410 }, { x: 530, y: 340 }, { x: 680, y: 270 },
{ x: 790, y: 360 }, { x: 730, y: 160 }, { x: 530, y: 110 },
{ x: 330, y: 80 }, { x: 130, y: 140 }
],
spikes: [
{ x: 300, y: 488, width: 60, height: 22 }, { x: 500, y: 488, width: 60, height: 22 }
],
patrolEnemies: [
{ x: 500, y: 120, patrolRange: 60, speed: 3.5 },
{ x: 300, y: 90, patrolRange: 60, speed: 3 }
],
powerUps: [
{ x: 330, y: 80, type: 'doubleJump' },
{ x: 130, y: 140, type: 'speedBoost' }
],
checkpoints: [
{ x: 50, y: 470 }, { x: 500, y: 120 }
],
flag: { x: 130, y: 140 },
portal: null
},
// ═══════════════════════════════════════════════════════════════
// LEVEL 8 - The Tower
// ═══════════════════════════════════════════════════════════════
{
name: "БАШНЯ",
playerStart: { x: 60, y: 480 },
platforms: [
{ x: 0, y: 530, width: 120, height: 20, color: '#2a2a4a' },
{ x: 0, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 870, y: 0, width: 30, height: 550, color: '#1a1a3a' },
// Tower ascending
{ x: 150, y: 470, width: 60, height: 16, color: '#4a3a6a' },
{ x: 80, y: 400, width: 60, height: 16, color: '#4a3a6a' },
{ x: 180, y: 340, width: 60, height: 16, color: '#4a3a6a' },
{ x: 100, y: 280, width: 60, height: 16, color: '#4a3a6a' },
{ x: 200, y: 220, width: 60, height: 16, color: '#4a3a6a' },
{ x: 350, y: 300, width: 60, height: 16, color: '#4a3a6a' },
{ x: 500, y: 250, width: 60, height: 16, color: '#4a3a6a' },
{ x: 650, y: 200, width: 60, height: 16, color: '#4a3a6a' },
{ x: 750, y: 280, width: 80, height: 16, color: '#4a3a6a' },
{ x: 700, y: 150, width: 80, height: 16, color: '#4a3a6a' },
{ x: 550, y: 80, width: 80, height: 16, color: '#4a3a6a' },
{ x: 350, y: 60, width: 100, height: 16, color: '#4a3a6a' }
],
movingPlatforms: [
{ x: 280, y: 250, width: 50, height: 16, color: '#6a5aaa', startX: 260, endX: 340, speed: 2, direction: 1, moveType: 'horizontal' },
{ x: 450, y: 160, width: 50, height: 16, color: '#6a5aaa', startX: 430, endX: 510, speed: 1.8, direction: 1, moveType: 'horizontal' }
],
coins: [
{ x: 170, y: 430 }, { x: 100, y: 360 }, { x: 200, y: 300 },
{ x: 120, y: 240 }, { x: 220, y: 180 }, { x: 370, y: 260 },
{ x: 520, y: 210 }, { x: 670, y: 160 }, { x: 780, y: 240 },
{ x: 730, y: 110 }, { x: 580, y: 40 }, { x: 380, y: 20 }
],
spikes: [
{ x: 150, y: 508, width: 40, height: 22 }, { x: 300, y: 508, width: 50, height: 22 },
{ x: 500, y: 508, width: 50, height: 22 }, { x: 700, y: 508, width: 50, height: 22 }
],
patrolEnemies: [
{ x: 340, y: 30, patrolRange: 80, speed: 2 }
],
powerUps: [
{ x: 580, y: 40, type: 'doubleJump' }
],
checkpoints: [
{ x: 30, y: 490 }, { x: 350, y: 30 }
],
flag: { x: 380, y: 20 },
portal: null
},
// ═══════════════════════════════════════════════════════════════
// LEVEL 9 - Chaos
// ═══════════════════════════════════════════════════════════════
{
name: "ХАОС",
playerStart: { x: 60, y: 400 },
platforms: [
{ x: 0, y: 510, width: 200, height: 40, color: '#2a2a4a' },
{ x: 0, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 870, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 100, y: 420, width: 50, height: 16, color: '#4a3a6a' },
{ x: 200, y: 380, width: 50, height: 16, color: '#4a3a6a' },
{ x: 300, y: 340, width: 50, height: 16, color: '#4a3a6a' },
{ x: 400, y: 300, width: 50, height: 16, color: '#4a3a6a' },
{ x: 500, y: 260, width: 50, height: 16, color: '#4a3a6a' },
{ x: 600, y: 220, width: 50, height: 16, color: '#4a3a6a' },
{ x: 700, y: 280, width: 50, height: 16, color: '#4a3a6a' },
{ x: 780, y: 350, width: 70, height: 16, color: '#4a3a6a' },
{ x: 750, y: 180, width: 80, height: 16, color: '#4a3a6a' },
{ x: 600, y: 120, width: 80, height: 16, color: '#4a3a6a' },
{ x: 400, y: 100, width: 80, height: 16, color: '#4a3a6a' },
{ x: 200, y: 150, width: 80, height: 16, color: '#4a3a6a' },
{ x: 50, y: 220, width: 80, height: 16, color: '#4a3a6a' }
],
movingPlatforms: [
{ x: 250, y: 300, width: 40, height: 16, color: '#6a5aaa', startX: 230, endX: 290, speed: 3, direction: 1, moveType: 'horizontal' },
{ x: 450, y: 200, width: 40, height: 16, color: '#6a5aaa', startX: 430, endX: 510, speed: 2.5, direction: 1, moveType: 'horizontal' },
{ x: 650, y: 150, width: 40, height: 16, color: '#6a5aaa', startX: 630, endX: 710, speed: 2, direction: 1, moveType: 'horizontal' }
],
coins: [
{ x: 115, y: 380 }, { x: 215, y: 340 }, { x: 315, y: 300 },
{ x: 415, y: 260 }, { x: 515, y: 220 }, { x: 615, y: 180 },
{ x: 730, y: 240 }, { x: 810, y: 310 }, { x: 780, y: 140 },
{ x: 630, y: 80 }, { x: 430, y: 60 }, { x: 230, y: 110 },
{ x: 80, y: 180 }
],
spikes: [
{ x: 220, y: 488, width: 60, height: 22 }, { x: 400, y: 488, width: 60, height: 22 },
{ x: 580, y: 488, width: 60, height: 22 }, { x: 760, y: 488, width: 60, height: 22 }
],
patrolEnemies: [
{ x: 200, y: 120, patrolRange: 60, speed: 3.5 },
{ x: 400, y: 70, patrolRange: 60, speed: 3 },
{ x: 600, y: 90, patrolRange: 60, speed: 3.5 }
],
powerUps: [
{ x: 80, y: 180, type: 'invincibility' },
{ x: 630, y: 80, type: 'doubleJump' }
],
checkpoints: [
{ x: 30, y: 470 }, { x: 200, y: 120 }, { x: 80, y: 180 }
],
flag: { x: 80, y: 180 },
portal: null
},
// ═══════════════════════════════════════════════════════════════
// LEVEL 10 - Final Challenge
// ═══════════════════════════════════════════════════════════════
{
name: "ФИНАЛ",
playerStart: { x: 60, y: 450 },
platforms: [
{ x: 0, y: 510, width: 180, height: 40, color: '#2a2a4a' },
{ x: 0, y: 0, width: 30, height: 550, color: '#1a1a3a' },
{ x: 870, y: 0, width: 30, height: 550, color: '#1a1a3a' },
// Challenging platforms
{ x: 200, y: 460, width: 50, height: 16, color: '#4a3a6a' },
{ x: 100, y: 390, width: 50, height: 16, color: '#4a3a6a' },
{ x: 220, y: 330, width: 50, height: 16, color: '#4a3a6a' },
{ x: 120, y: 270, width: 50, height: 16, color: '#4a3a6a' },
{ x: 250, y: 220, width: 50, height: 16, color: '#4a3a6a' },
{ x: 400, y: 280, width: 50, height: 16, color: '#4a3a6a' },
{ x: 550, y: 220, width: 50, height: 16, color: '#4a3a6a' },
{ x: 700, y: 280, width: 50, height: 16, color: '#4a3a6a' },
{ x: 800, y: 200, width: 60, height: 16, color: '#4a3a6a' },
{ x: 700, y: 120, width: 60, height: 16, color: '#4a3a6a' },
{ x: 500, y: 80, width: 80, height: 16, color: '#4a3a6a' },
{ x: 300, y: 60, width: 80, height: 16, color: '#4a3a6a' },
{ x: 100, y: 100, width: 80, height: 16, color: '#4a3a6a' }
],
movingPlatforms: [
{ x: 170, y: 320, width: 40, height: 16, color: '#6a5aaa', startX: 150, endX: 210, speed: 2.5, direction: 1, moveType: 'horizontal' },
{ x: 350, y: 180, width: 40, height: 16, color: '#6a5aaa', startX: 330, endX: 410, speed: 3, direction: 1, moveType: 'horizontal' },
{ x: 600, y: 160, width: 40, height: 16, color: '#6a5aaa', startX: 580, endX: 660, speed: 2, direction: 1, moveType: 'horizontal' },
{ x: 400, y: 150, width: 40, height: 16, color: '#6a5aaa', startX: 380, endX: 460, speed: 2.2, direction: 1, moveType: 'horizontal' }
],
coins: [
{ x: 215, y: 420 }, { x: 115, y: 350 }, { x: 235, y: 290 },
{ x: 135, y: 230 }, { x: 265, y: 180 }, { x: 415, y: 240 },
{ x: 565, y: 180 }, { x: 715, y: 240 }, { x: 825, y: 160 },
{ x: 725, y: 80 }, { x: 530, y: 40 }, { x: 330, y: 20 },
{ x: 130, y: 60 }
],
spikes: [
{ x: 220, y: 488, width: 50, height: 22 }, { x: 400, y: 488, width: 50, height: 22 },
{ x: 580, y: 488, width: 50, height: 22 }, { x: 760, y: 488, width: 50, height: 22 }
],
patrolEnemies: [
{ x: 300, y: 30, patrolRange: 70, speed: 4 },
{ x: 500, y: 50, patrolRange: 70, speed: 3.5 }
],
powerUps: [
{ x: 130, y: 60, type: 'doubleJump' },
{ x: 530, y: 40, type: 'speedBoost' },
{ x: 825, y: 160, type: 'invincibility' }
],
checkpoints: [
{ x: 30, y: 470 }, { x: 300, y: 30 }, { x: 130, y: 60 }
],
flag: { x: 130, y: 60 },
portal: null
}
];
// ═══════════════════════════════════════════════════════════════
// LEVEL MANAGER
// ═══════════════════════════════════════════════════════════════
class LevelManager {
constructor() {
this.currentLevel = 0;
this.maxLevel = LEVELS.length;
this.platforms = [];
this.movingPlatforms = [];
this.coins = [];
this.spikes = [];
this.patrolEnemies = [];
this.powerUps = [];
this.checkpoints = [];
this.flag = null;
this.portal = null;
}
loadLevel(levelIndex) {
if (levelIndex >= this.maxLevel) {
return false; // Game complete
}
this.currentLevel = levelIndex;
const level = LEVELS[levelIndex];
// Create platforms
this.platforms = level.platforms.map(p => new Platform(p.x, p.y, p.width, p.height, p.color, false, p.isMoving));
// Create moving platforms
this.movingPlatforms = level.movingPlatforms.map(mp =>
new Platform(mp.x, mp.y, mp.width, mp.height, mp.color, true, {
startX: mp.startX,
endX: mp.endX,
startY: mp.startY || mp.y,
endY: mp.endY || mp.y,
speed: mp.speed,
moveType: mp.moveType
})
);
// Create coins
this.coins = level.coins.map(c => new Coin(c.x, c.y));
// Create spikes
this.spikes = level.spikes.map(s => new Spike(s.x, s.y, s.width, s.height));
// Create patrol enemies
this.patrolEnemies = level.patrolEnemies.map(e =>
new PatrolEnemy(e.x, e.y, e.patrolRange, e.speed)
);
// Create power-ups
this.powerUps = level.powerUps.map(p => new PowerUp(p.x, p.y, p.type));
// Create checkpoints
this.checkpoints = level.checkpoints.map(c => new Checkpoint(c.x, c.y));
// Create flag
this.flag = new Flag(level.flag.x, level.flag.y);
// Create portal
if (level.portal) {
this.portal = new Portal(level.portal.x, level.portal.y);
} else {
this.portal = null;
}
return true;
}
update() {
// Update moving platforms
for (const mp of this.movingPlatforms) {
mp.update();
}
// Update coins
for (const coin of this.coins) {
coin.update(frameCount);
}
// Update patrol enemies
for (const enemy of this.patrolEnemies) {
enemy.update();
}
// Update power-ups
for (const powerUp of this.powerUps) {
powerUp.update(frameCount);
}
}
draw(ctx, frameCount) {
// Draw platforms
for (const platform of this.platforms) {
platform.draw(ctx, frameCount);
}
// Draw moving platforms
for (const mp of this.movingPlatforms) {
mp.draw(ctx, frameCount);
}
// Draw checkpoints
for (const checkpoint of this.checkpoints) {
checkpoint.draw(ctx, frameCount);
}
// Draw coins
for (const coin of this.coins) {
coin.draw(ctx, frameCount);
}
// Draw spikes
for (const spike of this.spikes) {
spike.draw(ctx);
}
// Draw patrol enemies
for (const enemy of this.patrolEnemies) {
enemy.draw(ctx, frameCount);
}
// Draw power-ups
for (const powerUp of this.powerUps) {
powerUp.draw(ctx, frameCount);
}
// Draw portal
if (this.portal) {
this.portal.draw(ctx, frameCount);
}
// Draw flag
if (this.flag) {
this.flag.draw(ctx, frameCount);
}
}
getAllPlatforms() {
return [...this.platforms, ...this.movingPlatforms];
}
reset() {
this.currentLevel = 0;
}
}