|
|
@@ -201,13 +201,13 @@ class Game {
|
|
|
}
|
|
|
|
|
|
startGame() {
|
|
|
- // Create player (scaled for 800x600 canvas)
|
|
|
- this.player = new Player(360, 500, this.processedSpriteSheet);
|
|
|
+ // Create player
|
|
|
+ this.player = new Player(72, 88, this.processedSpriteSheet);
|
|
|
|
|
|
// Crear elementos de fondo usando los nuevos métodos
|
|
|
- // Piso (scaled and extended for wider canvas) - moved down to fill bottom space
|
|
|
- for (let i = 0; i < 26; i++) {
|
|
|
- this.addFloorTile(i * 32, 568); // Moved from 520 to 568 (600-32=568)
|
|
|
+ // Piso
|
|
|
+ for (let i = 0; i < 10; i++) {
|
|
|
+ this.addFloorTile(i * 32, 208);
|
|
|
}
|
|
|
|
|
|
// Inicializar sistema de nubes
|
|
|
@@ -216,21 +216,21 @@ class Game {
|
|
|
// Inicializar sistema de objetos de fondo
|
|
|
this.backgroundObjectSystem.init(this.processedSpriteSheet, this.backgroundLayers.mid);
|
|
|
|
|
|
- // Macarons (scaled positions) - adjusted Y position
|
|
|
- this.addSprite(25, 518, 70, 52, { x: 137, y: 104, w: 35, h: 26 });
|
|
|
- this.addSprite(105, 518, 70, 52, { x: 173, y: 104, w: 35, h: 26 });
|
|
|
- this.addSprite(185, 518, 70, 52, { x: 137, y: 131, w: 35, h: 26 });
|
|
|
- this.addSprite(265, 518, 70, 52, { x: 173, y: 131, w: 35, h: 26 });
|
|
|
+ // Macarons
|
|
|
+ this.addSprite(10, 183, 35, 26, { x: 137, y: 104, w: 35, h: 26 });
|
|
|
+ this.addSprite(42, 183, 35, 26, { x: 173, y: 104, w: 35, h: 26 });
|
|
|
+ this.addSprite(74, 183, 35, 26, { x: 137, y: 131, w: 35, h: 26 });
|
|
|
+ this.addSprite(106, 183, 35, 26, { x: 173, y: 131, w: 35, h: 26 });
|
|
|
|
|
|
- // Candybar (scaled) - adjusted to ground level
|
|
|
- this.addSprite(500, 410, 96, 158, { x: 179, y: 438, w: 48, h: 79 });
|
|
|
+ // Candybar
|
|
|
+ this.addSprite(200, 130, 48, 79, { x: 179, y: 438, w: 48, h: 79 });
|
|
|
|
|
|
- // Cake (scaled) - adjusted to ground level
|
|
|
- this.addSprite(650, 418, 200, 150, { x: 461, y: 414, w: 100, h: 75 });
|
|
|
+ // Cake
|
|
|
+ this.addSprite(260, 134, 100, 75, { x: 461, y: 414, w: 100, h: 75 });
|
|
|
|
|
|
- // Cat (scaled) - adjusted Y position
|
|
|
- this.addSprite(463, 528, 40, 46, { x: 235, y: 87, w: 20, h: 23 });
|
|
|
- this.addSprite(500, 528, 40, 46, { x: 389, y: 87, w: 16, h: 23 });
|
|
|
+ // Cat
|
|
|
+ this.addSprite(185, 187, 20, 23, { x: 235, y: 87, w: 20, h: 23 });
|
|
|
+ this.addSprite(200, 187, 20, 23, { x: 389, y: 87, w: 16, h: 23 });
|
|
|
|
|
|
this.gameLoop();
|
|
|
}
|
|
|
@@ -251,6 +251,12 @@ class Game {
|
|
|
// Actualizar sistema de letras
|
|
|
if (!this.backgroundMusic.paused) {
|
|
|
this.lyricsSystem.update(this.backgroundMusic.currentTime);
|
|
|
+
|
|
|
+ // Verificar si la canción ha terminado y detenerla
|
|
|
+ if (this.lyricsSystem.isGameOver && !this.backgroundMusic.paused) {
|
|
|
+ this.backgroundMusic.pause();
|
|
|
+ this.gameState = 'gameOver';
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -369,13 +375,12 @@ class Game {
|
|
|
this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
|
|
|
|
this.ctx.fillStyle = 'white';
|
|
|
- this.ctx.font = '20px Courier New';
|
|
|
+ this.ctx.font = '10px Courier New';
|
|
|
this.ctx.textAlign = 'center';
|
|
|
- this.ctx.fillText('Click to start music', 400, 300);
|
|
|
- this.ctx.fillText('AD or ← → to move', 400, 325);
|
|
|
- this.ctx.fillText('L - Show/Hide lyrics', 400, 350);
|
|
|
- this.ctx.fillText('R - Restart game', 400, 375);
|
|
|
- // this.ctx.fillText('Ctrl+G - Simular fin de canción', 160, 160);
|
|
|
+ this.ctx.fillText('Click to start music', 160, 100);
|
|
|
+ this.ctx.fillText('WASD or ↑↓←→ to move', 160, 115);
|
|
|
+ this.ctx.fillText('L - Show/Hide lyrics', 160, 130);
|
|
|
+ this.ctx.fillText('R - Restart game', 160, 145);
|
|
|
}
|
|
|
|
|
|
// Dibujar pantalla de fin de juego
|
|
|
@@ -416,16 +421,16 @@ class Game {
|
|
|
|
|
|
// Texto de fin de juego
|
|
|
this.ctx.fillStyle = 'white';
|
|
|
- this.ctx.font = '40px Courier New';
|
|
|
+ this.ctx.font = '20px Courier New';
|
|
|
this.ctx.textAlign = 'center';
|
|
|
|
|
|
- this.ctx.fillText('Song finished!', 400, 250);
|
|
|
- this.ctx.fillText('Want to play again?', 400, 300);
|
|
|
+ this.ctx.fillText('Song finished!', 160, 100);
|
|
|
+ this.ctx.fillText('Want to play again?', 160, 125);
|
|
|
|
|
|
// Botones
|
|
|
- this.ctx.font = '24px Courier New';
|
|
|
- this.ctx.fillText('Press R to restart', 400, 375);
|
|
|
- this.ctx.fillText('or reload the page', 400, 412);
|
|
|
+ this.ctx.font = '12px Courier New';
|
|
|
+ this.ctx.fillText('Press R to restart', 160, 175);
|
|
|
+ this.ctx.fillText('or reload the page', 160, 190);
|
|
|
}
|
|
|
|
|
|
restartGame() {
|
|
|
@@ -457,26 +462,26 @@ class Game {
|
|
|
}
|
|
|
|
|
|
recreateBackgroundElements() {
|
|
|
- // Piso (scaled and extended for wider canvas) - moved down to fill bottom space
|
|
|
- for (let i = 0; i < 26; i++) {
|
|
|
- this.addFloorTile(i * 32, 568); // Moved from 520 to 568 (600-32=568)
|
|
|
+ // Piso - adjusted for 320x240 canvas
|
|
|
+ for (let i = 0; i < 10; i++) {
|
|
|
+ this.addFloorTile(i * 32, 208); // 240-32=208
|
|
|
}
|
|
|
|
|
|
- // Macarons (scaled positions) - adjusted Y position
|
|
|
- this.addSprite(25, 518, 70, 52, { x: 137, y: 104, w: 35, h: 26 });
|
|
|
- this.addSprite(105, 518, 70, 52, { x: 173, y: 104, w: 35, h: 26 });
|
|
|
- this.addSprite(185, 518, 70, 52, { x: 137, y: 131, w: 35, h: 26 });
|
|
|
- this.addSprite(265, 518, 70, 52, { x: 173, y: 131, w: 35, h: 26 });
|
|
|
+ // Macarons - original positions
|
|
|
+ this.addSprite(10, 183, 35, 26, { x: 137, y: 104, w: 35, h: 26 });
|
|
|
+ this.addSprite(42, 183, 35, 26, { x: 173, y: 104, w: 35, h: 26 });
|
|
|
+ this.addSprite(74, 183, 35, 26, { x: 137, y: 131, w: 35, h: 26 });
|
|
|
+ this.addSprite(106, 183, 35, 26, { x: 173, y: 131, w: 35, h: 26 });
|
|
|
|
|
|
- // Candybar (scaled) - adjusted to ground level
|
|
|
- this.addSprite(500, 410, 96, 158, { x: 179, y: 438, w: 48, h: 79 });
|
|
|
+ // Candybar - original size and position
|
|
|
+ this.addSprite(200, 130, 48, 79, { x: 179, y: 438, w: 48, h: 79 });
|
|
|
|
|
|
- // Cake (scaled) - adjusted to ground level
|
|
|
- this.addSprite(650, 418, 200, 150, { x: 461, y: 414, w: 100, h: 75 });
|
|
|
+ // Cake - original size and position
|
|
|
+ this.addSprite(260, 134, 100, 75, { x: 461, y: 414, w: 100, h: 75 });
|
|
|
|
|
|
- // Cat (scaled) - adjusted Y position
|
|
|
- this.addSprite(463, 528, 40, 46, { x: 235, y: 87, w: 20, h: 23 });
|
|
|
- this.addSprite(500, 528, 40, 46, { x: 389, y: 87, w: 16, h: 23 });
|
|
|
+ // Cat - original positions
|
|
|
+ this.addSprite(185, 187, 20, 23, { x: 235, y: 87, w: 20, h: 23 });
|
|
|
+ this.addSprite(200, 187, 20, 23, { x: 389, y: 87, w: 16, h: 23 });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -488,16 +493,16 @@ class CloudSystem {
|
|
|
this.cloudLayer = null;
|
|
|
this.frameCount = 0;
|
|
|
|
|
|
- // Configuración simplificada (scaled for 800x600 canvas)
|
|
|
+ // Configuración para canvas 320x240
|
|
|
this.config = {
|
|
|
- spawnRate: 0.1, // Probabilidad de spawn por frame (aumentada)
|
|
|
- maxClouds: 3, // Máximo número de nubes en pantalla (aumentado)
|
|
|
- speedRange: { min: 0.25, max: 0.375 }, // Velocidad de movimiento (scaled)
|
|
|
- yRange: { min: 2, max: 300 }, // Rango de altura (scaled)
|
|
|
+ spawnRate: 0.1, // Probabilidad de spawn por frame
|
|
|
+ maxClouds: 2, // Máximo número de nubes en pantalla
|
|
|
+ speedRange: { min: 0.125, max: 0.1875 }, // Velocidad de movimiento (original)
|
|
|
+ yRange: { min: 1, max: 150 }, // Rango de altura (original)
|
|
|
spriteCoords: { x: 231, y: 112, w: 287, h: 148 },
|
|
|
- size: { w: 574, h: 296 }, // Scaled cloud size
|
|
|
- minSpacing: 250, // Espaciado mínimo entre nubes (scaled)
|
|
|
- minTimeBetweenSpawns: 60 // Frames mínimos entre apariciones (reducido)
|
|
|
+ size: { w: 287, h: 148 }, // Tamaño original de nube
|
|
|
+ minSpacing: 125, // Espaciado mínimo entre nubes (original)
|
|
|
+ minTimeBetweenSpawns: 60 // Frames mínimos entre apariciones
|
|
|
};
|
|
|
|
|
|
this.lastSpawnTime = 0;
|
|
|
@@ -653,16 +658,16 @@ class BackgroundObjectSystem {
|
|
|
this.objectLayer = null;
|
|
|
this.frameCount = 0;
|
|
|
|
|
|
- // Configuración para objetos de fondo (scaled for 800x600 canvas)
|
|
|
+ // Configuración para objetos de fondo (320x240 canvas)
|
|
|
this.config = {
|
|
|
- spawnRate: 0.15, // Probabilidad de spawn por frame (reducida para mejor control)
|
|
|
- maxObjects: 300, // Máximo número de objetos en pantalla
|
|
|
- speedRange: { min: 0.125, max: 0.25 }, // Velocidad de movimiento (scaled)
|
|
|
- yRange: { min: 25, max: 450 }, // Rango de altura (scaled)
|
|
|
- minSpacing: 300, // Espaciado mínimo entre grupos (aumentado)
|
|
|
- minTimeBetweenSpawns: 120, // Frames mínimos entre apariciones (aumentado)
|
|
|
- groupSize: { min: 8, max: 15 }, // Tamaño del grupo de objetos (reducido)
|
|
|
- groupSpacing: { min: 15, max: 80 } // Espaciado entre objetos en el grupo
|
|
|
+ spawnRate: 0.15, // Probabilidad de spawn por frame
|
|
|
+ maxObjects: 150, // Máximo número de objetos en pantalla (reducido)
|
|
|
+ speedRange: { min: 0.0625, max: 0.125 }, // Velocidad de movimiento (original)
|
|
|
+ yRange: { min: 12, max: 225 }, // Rango de altura (original)
|
|
|
+ minSpacing: 150, // Espaciado mínimo entre grupos (original)
|
|
|
+ minTimeBetweenSpawns: 120, // Frames mínimos entre apariciones
|
|
|
+ groupSize: { min: 4, max: 8 }, // Tamaño del grupo de objetos (original)
|
|
|
+ groupSpacing: { min: 8, max: 40 } // Espaciado entre objetos en el grupo (original)
|
|
|
};
|
|
|
|
|
|
this.lastSpawnTime = 0;
|
|
|
@@ -799,14 +804,13 @@ class BackgroundObjectSystem {
|
|
|
// Aplicar dispersión vertical aleatoria
|
|
|
const yOffset = (Math.random() - 0.5) * 40; // ±20 píxeles
|
|
|
|
|
|
- // Scale the background objects (2x scale factor)
|
|
|
- const scaleFactor = 2;
|
|
|
+ // Use original size for background objects
|
|
|
const object = {
|
|
|
type: 'backgroundObject',
|
|
|
x: currentX,
|
|
|
y: y + yOffset,
|
|
|
- w: spriteVariant.w * scaleFactor,
|
|
|
- h: spriteVariant.h * scaleFactor,
|
|
|
+ w: spriteVariant.w,
|
|
|
+ h: spriteVariant.h,
|
|
|
spriteCoords: spriteVariant,
|
|
|
moveSpeed: speed,
|
|
|
rotation: rotation,
|
|
|
@@ -815,11 +819,11 @@ class BackgroundObjectSystem {
|
|
|
|
|
|
this.objectLayer.push(object);
|
|
|
|
|
|
- // Calcular siguiente posición con espaciado aleatorio (adjusted for scaled objects)
|
|
|
+ // Calcular siguiente posición con espaciado aleatorio
|
|
|
const spacing = Math.random() *
|
|
|
(this.config.groupSpacing.max - this.config.groupSpacing.min) +
|
|
|
this.config.groupSpacing.min;
|
|
|
- currentX += (spriteVariant.w * scaleFactor) + spacing;
|
|
|
+ currentX += spriteVariant.w + spacing;
|
|
|
}
|
|
|
}
|
|
|
|