User prompt
Please fix the bug: 'ReferenceError: Can't find variable: Obstacle' in or related to this line: 'var obstacle = game.addChild(new Obstacle('cloud'));' Line Number: 399
User prompt
obstacles other than clouds should spawn randomly and independently of each other. spawns should be rare relative to clouds. birds spawn in a parallel line from the right or left side of the screen. stars spawn diagonally. lightning follows a vertical path. wind chimes suddenly appear and disappear. obstacles should not spawn opposite direct of game flow. they should spawn on the everywhere of screen. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
obstacles other than clouds should spawn randomly and independently of each other. spawns should be rare relative to clouds. birds spawn in a parallel line from the right or left side of the screen. stars spawn diagonally. lightning follows a vertical path. wind chimes suddenly appear and disappear. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
every 500 meters the game can get faster or harder. remove the score, just make it distance. make the life icons hearts, not the usual heart, not the one on the card. and make the text the previous size. remove the empty unused space at the top, the space above the score.
User prompt
make the game fullscreen, no unused space. make life icons as hearts.
User prompt
write score in the empty space above the scoreboard. write distance. and let the character have 3 lives, put 3 lives, 3 lives come by default, as the character crosses the obstacle, the life goes away. for these lives, also have a life power up in the game, the probability of spawning is 0.05%. when you get that life, add a new life, maximum life 5.
User prompt
obstacles should keep spawning as long as the character moves, we should keep seeing obstacles as we move downwards.
User prompt
more obstacles. remove the line on upper of the scoreboard. camera track character
User prompt
wind should lead him and more birds more stars more lightning, all of them are obstacles ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
clouds make him stop and game should be an infinite fall game
User prompt
obstacles spawn more
User prompt
give character motion of wind matched with umbrella ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Umbrella Fall
Initial prompt
Design a simple 2D mobile game called **“Umbrella Fall”**. Concept: - The player controls a character gently descending from the sky with an open umbrella. - The goal is to avoid obstacles and reach a soft landing. - The game ends if the player hits a hazard or veers off screen. Gameplay Features: - The character constantly falls downward. - The player can swipe or tilt left/right to steer the descent. - Wind currents occasionally push the character off balance. - Obstacles: birds flying across, lightning bolts, and floating air pockets (they destabilize the umbrella). - Bonus items: falling stars or wind chimes can be collected for extra score. Visual Style: - Sky-themed aesthetic: soft clouds, sunset gradients, falling petals. - Umbrella can have unlockable colors or patterns (optional). - Soothing ambient sound or rain sound can enhance mood. Controls: - Swipe left/right or use accelerometer (device tilt) - No jump or action buttons needed. Requirements: - Simple, responsive controls for mobile - Gentle pacing with increasing difficulty over time - One-touch or tilt-only gameplay - Minimal, relaxing visual design
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 4 + 3;
self.direction = Math.random() > 0.5 ? 1 : -1;
self.x = self.direction > 0 ? -100 : 2148; // Start from left or right edge
self.update = function () {
self.x += self.speed * self.direction;
graphics.rotation += 0.1;
// Slight vertical bobbing
graphics.y = Math.sin(LK.ticks * 0.08) * 15;
};
return self;
});
var Cloud = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
graphics.alpha = 0.6;
self.speed = Math.random() * 0.5 + 0.2;
self.update = function () {
// Clouds are now stationary - no horizontal movement
};
return self;
});
var Collectible = Container.expand(function (type) {
var self = Container.call(this);
self.type = type;
var graphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
if (self.type === 'star') {
graphics.rotation += 0.15;
graphics.scaleX = 1 + Math.sin(LK.ticks * 0.1) * 0.3;
graphics.scaleY = 1 + Math.sin(LK.ticks * 0.1) * 0.3;
} else if (self.type === 'windChime') {
graphics.x = Math.sin(LK.ticks * 0.08) * 10;
}
};
return self;
});
var LifePowerUp = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
graphics.rotation += 0.1;
graphics.scaleX = 1 + Math.sin(LK.ticks * 0.12) * 0.2;
graphics.scaleY = 1 + Math.sin(LK.ticks * 0.12) * 0.2;
};
return self;
});
var Lightning = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('lightning', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 3 + 2;
// Lightning flicker effect
tween(graphics, {
alpha: 0.3
}, {
duration: 100,
easing: tween.easeInOut
});
LK.setTimeout(function () {
tween(graphics, {
alpha: 1
}, {
duration: 50
});
}, 100);
self.update = function () {
self.y += self.speed;
// Lightning sway
graphics.x = Math.sin(LK.ticks * 0.12) * 10;
};
return self;
});
var Obstacle = Container.expand(function (type) {
var self = Container.call(this);
self.type = type;
var graphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
if (type === 'bird') {
self.speed = Math.random() * 3 + 2;
self.direction = Math.random() > 0.5 ? 1 : -1;
// Add swooping animation to birds
tween(graphics, {
scaleY: 1.2
}, {
duration: 800,
easing: tween.easeInOut
});
} else if (type === 'airPocket') {
graphics.alpha = 0.3;
} else if (type === 'lightning') {
// Lightning flicker effect
tween(graphics, {
alpha: 0.3
}, {
duration: 100,
easing: tween.easeInOut
});
LK.setTimeout(function () {
tween(graphics, {
alpha: 1
}, {
duration: 50
});
}, 100);
} else if (type === 'star') {
// Stars now spin menacingly as obstacles
graphics.tint = 0xff6666; // Red tint to show they're dangerous
}
self.update = function () {
if (self.type === 'bird') {
self.x += self.speed * self.direction;
graphics.rotation += 0.15;
// Bird swooping motion
graphics.y = Math.sin(LK.ticks * 0.08) * 20;
} else if (self.type === 'airPocket') {
graphics.alpha = 0.3 + Math.sin(LK.ticks * 0.1) * 0.2;
} else if (self.type === 'lightning') {
// Lightning sway
graphics.x = Math.sin(LK.ticks * 0.12) * 15;
} else if (self.type === 'star') {
// Dangerous spinning stars
graphics.rotation += 0.2;
graphics.scaleX = 1 + Math.sin(LK.ticks * 0.15) * 0.4;
graphics.scaleY = 1 + Math.sin(LK.ticks * 0.15) * 0.4;
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var umbrella = self.attachAsset('umbrella', {
anchorX: 0.5,
anchorY: 0.5,
y: -40
});
var character = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5,
y: 20
});
self.fallSpeed = 3;
self.horizontalSpeed = 0;
self.windEffect = 0;
self.maxHorizontalSpeed = 8;
self.update = function () {
self.y += self.fallSpeed;
// Apply horizontal movement with wind effect
self.x += self.horizontalSpeed + self.windEffect;
// Enhanced umbrella wind animation
var baseRotation = Math.sin(LK.ticks * 0.05) * 0.1;
var windRotation = self.windEffect * 0.02;
var horizontalRotation = self.horizontalSpeed * 0.05;
umbrella.rotation = baseRotation + windRotation + horizontalRotation;
// Wind-affected umbrella bobbing
umbrella.y = -40 + Math.sin(LK.ticks * 0.08) * 3 + Math.abs(self.windEffect) * 0.5;
// Character sway matching umbrella movement
character.rotation = umbrella.rotation * 0.3;
character.x = Math.sin(LK.ticks * 0.06) * 2 + self.windEffect * 0.1;
// Keep player on screen horizontally
if (self.x < 70) {
self.x = 70;
self.horizontalSpeed = 0;
}
if (self.x > 2048 - 70) {
self.x = 2048 - 70;
self.horizontalSpeed = 0;
}
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
graphics.tint = 0xff6666;
self.speedX = (Math.random() - 0.5) * 3;
self.speedY = Math.random() * 2 + 1;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
graphics.rotation += 0.2;
graphics.scaleX = 1 + Math.sin(LK.ticks * 0.15) * 0.3;
graphics.scaleY = 1 + Math.sin(LK.ticks * 0.15) * 0.3;
};
return self;
});
var WindChime = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('windChime', {
anchorX: 0.5,
anchorY: 0.5
});
self.visible = true;
self.flickerTimer = 0;
self.update = function () {
self.flickerTimer++;
// Sudden appear/disappear effect
if (self.flickerTimer % 60 === 0) {
self.visible = !self.visible;
graphics.alpha = self.visible ? 1 : 0;
}
// Gentle swaying when visible
if (self.visible) {
graphics.x = Math.sin(LK.ticks * 0.08) * 8;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
// Gradient sky effect
game.setBackgroundColor(0x87ceeb);
// Game variables
var player;
var obstacles = [];
var collectibles = [];
var clouds = [];
var lifePowerUps = [];
var windTimer = 0;
var spawnTimer = 0;
var difficultyTimer = 0;
var distanceFallen = 0;
var gameSpeed = 1;
var cameraY = 0;
var targetCameraY = 0;
var playerLives = 3;
var maxLives = 5;
// UI Elements
var distanceTxt = new Text2('Distance: 0m', {
size: 100,
fill: 0xFFFFFF
});
distanceTxt.anchor.set(0.5, 0);
distanceTxt.y = 50;
LK.gui.top.addChild(distanceTxt);
// Lives display
var livesContainer = new Container();
var lifeHearts = [];
for (var h = 0; h < maxLives; h++) {
var heart = LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
heart.x = h * 60 - 120;
heart.y = 0;
heart.scaleX = 1.2;
heart.scaleY = 1.5;
livesContainer.addChild(heart);
lifeHearts.push(heart);
}
livesContainer.y = 150;
LK.gui.top.addChild(livesContainer);
// Update lives display function
function updateLivesDisplay() {
for (var i = 0; i < lifeHearts.length; i++) {
if (i < playerLives) {
lifeHearts[i].alpha = 1;
} else {
lifeHearts[i].alpha = 0.3;
}
}
}
updateLivesDisplay();
// Initialize player
player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 600;
// Create initial clouds
for (var i = 0; i < 8; i++) {
var cloud = game.addChild(new Cloud());
cloud.x = Math.random() * 2048;
cloud.y = Math.random() * 2732;
clouds.push(cloud);
}
// Touch controls
var isDragging = false;
var lastTouchX = 0;
game.down = function (x, y, obj) {
isDragging = true;
lastTouchX = x;
};
game.move = function (x, y, obj) {
if (isDragging) {
var deltaX = x - lastTouchX;
player.horizontalSpeed = Math.max(-player.maxHorizontalSpeed, Math.min(player.maxHorizontalSpeed, deltaX * 0.3));
lastTouchX = x;
}
};
game.up = function (x, y, obj) {
isDragging = false;
// Gradually reduce horizontal speed when not dragging
tween(player, {
horizontalSpeed: 0
}, {
duration: 500,
easing: tween.easeOut
});
};
// Main game loop
game.update = function () {
// Update distance fallen
distanceFallen += player.fallSpeed;
distanceTxt.setText('Distance: ' + Math.floor(distanceFallen / 10) + 'm');
// Camera tracking - follow player with smooth movement
targetCameraY = player.y - 1366; // Keep player in center vertically
var cameraDiff = targetCameraY - cameraY;
cameraY += cameraDiff * 0.08; // Smooth camera movement
game.y = -cameraY;
// Increase difficulty every 500 meters
var currentDistance = Math.floor(distanceFallen / 10);
var difficultyLevel = Math.floor(currentDistance / 500);
if (difficultyLevel > 0) {
gameSpeed = 1 + difficultyLevel * 0.3;
player.fallSpeed = Math.min(8, 3 + difficultyLevel * 0.5);
}
// Enhanced wind effect that actively guides the player
windTimer++;
if (windTimer % 150 === 0) {
// Every 2.5 seconds - more frequent wind
var windStrength = (Math.random() - 0.5) * 8 * gameSpeed; // Stronger wind
// Visual wind burst effect on umbrella
var umbrella = player.children[0]; // Get umbrella reference
tween(umbrella, {
scaleX: 1.3 + Math.abs(windStrength) * 0.15,
scaleY: 0.8 - Math.abs(windStrength) * 0.1,
rotation: umbrella.rotation + windStrength * 0.1
}, {
duration: 150,
easing: tween.easeOut
});
// Return umbrella to normal size
LK.setTimeout(function () {
tween(umbrella, {
scaleX: 1,
scaleY: 1
}, {
duration: 600,
easing: tween.easeOut
});
}, 150);
tween(player, {
windEffect: windStrength
}, {
duration: 150
});
LK.setTimeout(function () {
tween(player, {
windEffect: windStrength * 0.3
}, {
duration: 800,
easing: tween.easeOut
});
}, 600);
// Complete wind fade after longer period
LK.setTimeout(function () {
tween(player, {
windEffect: 0
}, {
duration: 400,
easing: tween.easeOut
});
}, 1400);
}
// Spawn clouds continuously based on player movement
spawnTimer++;
var cloudSpawnRate = Math.max(3, 10 - Math.floor(gameSpeed * 2));
if (spawnTimer % cloudSpawnRate === 0) {
// Calculate spawn position relative to player's current position
var spawnX = Math.random() * (2048 - 200) + 100;
var spawnY = player.y - 800 - Math.random() * 400; // Spawn ahead of player
// Check for life power-up spawn first (0.05% chance)
if (Math.random() < 0.0005) {
var lifePowerUp = game.addChild(new LifePowerUp());
lifePowerUp.x = spawnX;
lifePowerUp.y = spawnY;
lifePowerUps.push(lifePowerUp);
}
// Spawn cloud obstacles
else if (Math.random() < 0.85) {
var obstacle = game.addChild(new Obstacle('cloud'));
obstacle.x = spawnX;
obstacle.y = spawnY;
obstacles.push(obstacle);
} else {
// Collectible wind chimes
var collectible = game.addChild(new Collectible('windChime'));
collectible.x = spawnX;
collectible.y = spawnY;
collectibles.push(collectible);
}
}
// Independent bird spawning (rare, parallel lines)
if (Math.random() < 0.001 * gameSpeed) {
var bird = game.addChild(new Bird());
bird.y = player.y - Math.random() * 600 - 200;
obstacles.push(bird);
}
// Independent star spawning (rare, diagonal movement)
if (Math.random() < 0.0008 * gameSpeed) {
var star = game.addChild(new Star());
star.x = Math.random() * 2048;
star.y = player.y - Math.random() * 500 - 300;
obstacles.push(star);
}
// Independent lightning spawning (rare, vertical path)
if (Math.random() < 0.0006 * gameSpeed) {
var lightning = game.addChild(new Lightning());
lightning.x = Math.random() * (2048 - 100) + 50;
lightning.y = player.y - Math.random() * 700 - 400;
obstacles.push(lightning);
}
// Independent wind chime spawning (rare, appear/disappear)
if (Math.random() < 0.0004 * gameSpeed) {
var windChime = game.addChild(new WindChime());
windChime.x = Math.random() * (2048 - 100) + 50;
windChime.y = player.y - Math.random() * 600 - 200;
obstacles.push(windChime);
}
// Update and check obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
if (obstacle.lastY === undefined) obstacle.lastY = obstacle.y;
if (obstacle.lastIntersecting === undefined) obstacle.lastIntersecting = false;
// Remove obstacles that are too far behind the player
if (obstacle.lastY < player.y + 1000 && obstacle.y >= player.y + 1000) {
obstacle.destroy();
obstacles.splice(i, 1);
continue;
}
// Check collision with player
var currentIntersecting = obstacle.intersects(player);
if (!obstacle.lastIntersecting && currentIntersecting) {
playerLives--;
updateLivesDisplay();
LK.getSound('hit').play();
LK.effects.flashScreen(0xff0000, 500);
// Remove the obstacle that was hit
obstacle.destroy();
obstacles.splice(i, 1);
// Check if game over
if (playerLives <= 0) {
LK.showGameOver();
return;
}
continue;
}
obstacle.lastY = obstacle.y;
obstacle.lastIntersecting = currentIntersecting;
}
// Update and check collectibles
for (var j = collectibles.length - 1; j >= 0; j--) {
var collectible = collectibles[j];
if (collectible.lastY === undefined) collectible.lastY = collectible.y;
if (collectible.lastIntersecting === undefined) collectible.lastIntersecting = false;
// Remove collectibles that are too far behind the player
if (collectible.lastY < player.y + 1000 && collectible.y >= player.y + 1000) {
collectible.destroy();
collectibles.splice(j, 1);
continue;
}
// Check collection
var currentIntersecting = collectible.intersects(player);
if (!collectible.lastIntersecting && currentIntersecting) {
LK.getSound('collect').play();
// Visual effect
tween(collectible, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
collectible.destroy();
}
});
collectibles.splice(j, 1);
continue;
}
collectible.lastY = collectible.y;
collectible.lastIntersecting = currentIntersecting;
}
// Update and check life power-ups
for (var l = lifePowerUps.length - 1; l >= 0; l--) {
var lifePowerUp = lifePowerUps[l];
if (lifePowerUp.lastY === undefined) lifePowerUp.lastY = lifePowerUp.y;
if (lifePowerUp.lastIntersecting === undefined) lifePowerUp.lastIntersecting = false;
// Remove life power-ups that are too far behind the player
if (lifePowerUp.lastY < player.y + 1000 && lifePowerUp.y >= player.y + 1000) {
lifePowerUp.destroy();
lifePowerUps.splice(l, 1);
continue;
}
// Check collection
var currentIntersecting = lifePowerUp.intersects(player);
if (!lifePowerUp.lastIntersecting && currentIntersecting) {
if (playerLives < maxLives) {
playerLives++;
updateLivesDisplay();
LK.getSound('collect').play();
// Visual effect
tween(lifePowerUp, {
scaleX: 3,
scaleY: 3,
alpha: 0
}, {
duration: 500,
onFinish: function onFinish() {
lifePowerUp.destroy();
}
});
lifePowerUps.splice(l, 1);
continue;
}
}
lifePowerUp.lastY = lifePowerUp.y;
lifePowerUp.lastIntersecting = currentIntersecting;
}
// Check collision with clouds
for (var k = 0; k < clouds.length; k++) {
var cloud = clouds[k];
if (cloud.lastIntersecting === undefined) cloud.lastIntersecting = false;
var currentIntersecting = cloud.intersects(player);
if (!cloud.lastIntersecting && currentIntersecting) {
playerLives--;
updateLivesDisplay();
LK.getSound('hit').play();
LK.effects.flashScreen(0xffffff, 500);
// Check if game over
if (playerLives <= 0) {
LK.showGameOver();
return;
}
}
cloud.lastIntersecting = currentIntersecting;
}
// Remove game over condition for falling off screen - infinite fall game
// Game only ends when hitting obstacles or clouds
};
// Start ambient music
LK.playMusic('ambient'); ===================================================================
--- original.js
+++ change.js
@@ -5,8 +5,25 @@
/****
* Classes
****/
+var Bird = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('bird', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = Math.random() * 4 + 3;
+ self.direction = Math.random() > 0.5 ? 1 : -1;
+ self.x = self.direction > 0 ? -100 : 2148; // Start from left or right edge
+ self.update = function () {
+ self.x += self.speed * self.direction;
+ graphics.rotation += 0.1;
+ // Slight vertical bobbing
+ graphics.y = Math.sin(LK.ticks * 0.08) * 15;
+ };
+ return self;
+});
var Cloud = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('cloud', {
anchorX: 0.5,
@@ -49,8 +66,36 @@
graphics.scaleY = 1 + Math.sin(LK.ticks * 0.12) * 0.2;
};
return self;
});
+var Lightning = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('lightning', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = Math.random() * 3 + 2;
+ // Lightning flicker effect
+ tween(graphics, {
+ alpha: 0.3
+ }, {
+ duration: 100,
+ easing: tween.easeInOut
+ });
+ LK.setTimeout(function () {
+ tween(graphics, {
+ alpha: 1
+ }, {
+ duration: 50
+ });
+ }, 100);
+ self.update = function () {
+ self.y += self.speed;
+ // Lightning sway
+ graphics.x = Math.sin(LK.ticks * 0.12) * 10;
+ };
+ return self;
+});
var Obstacle = Container.expand(function (type) {
var self = Container.call(this);
self.type = type;
var graphics = self.attachAsset(type, {
@@ -149,8 +194,48 @@
}
};
return self;
});
+var Star = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('star', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ graphics.tint = 0xff6666;
+ self.speedX = (Math.random() - 0.5) * 3;
+ self.speedY = Math.random() * 2 + 1;
+ self.update = function () {
+ self.x += self.speedX;
+ self.y += self.speedY;
+ graphics.rotation += 0.2;
+ graphics.scaleX = 1 + Math.sin(LK.ticks * 0.15) * 0.3;
+ graphics.scaleY = 1 + Math.sin(LK.ticks * 0.15) * 0.3;
+ };
+ return self;
+});
+var WindChime = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('windChime', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.visible = true;
+ self.flickerTimer = 0;
+ self.update = function () {
+ self.flickerTimer++;
+ // Sudden appear/disappear effect
+ if (self.flickerTimer % 60 === 0) {
+ self.visible = !self.visible;
+ graphics.alpha = self.visible ? 1 : 0;
+ }
+ // Gentle swaying when visible
+ if (self.visible) {
+ graphics.x = Math.sin(LK.ticks * 0.08) * 8;
+ }
+ };
+ return self;
+});
/****
* Initialize Game
****/
@@ -313,12 +398,12 @@
easing: tween.easeOut
});
}, 1400);
}
- // Spawn obstacles continuously based on player movement
+ // Spawn clouds continuously based on player movement
spawnTimer++;
- var spawnRate = Math.max(2, 8 - Math.floor(gameSpeed * 2)); // More frequent spawning
- if (spawnTimer % spawnRate === 0) {
+ var cloudSpawnRate = Math.max(3, 10 - Math.floor(gameSpeed * 2));
+ if (spawnTimer % cloudSpawnRate === 0) {
// Calculate spawn position relative to player's current position
var spawnX = Math.random() * (2048 - 200) + 100;
var spawnY = player.y - 800 - Math.random() * 400; // Spawn ahead of player
// Check for life power-up spawn first (0.05% chance)
@@ -327,49 +412,49 @@
lifePowerUp.x = spawnX;
lifePowerUp.y = spawnY;
lifePowerUps.push(lifePowerUp);
}
- // Higher obstacle spawn rate - now 98% obstacles
- else if (Math.random() < 0.98) {
- // More birds, lightning, and stars as obstacles with weighted distribution
- var obstacleTypes = ['bird', 'bird', 'bird', 'lightning', 'lightning', 'star', 'star', 'airPocket'];
- var obstacleType = obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)];
- var obstacle = game.addChild(new Obstacle(obstacleType));
+ // Spawn cloud obstacles
+ else if (Math.random() < 0.85) {
+ var obstacle = game.addChild(new Obstacle('cloud'));
obstacle.x = spawnX;
obstacle.y = spawnY;
obstacles.push(obstacle);
- // Spawn additional obstacles more frequently - lowered threshold
- if (gameSpeed > 1.2 && Math.random() < 0.8) {
- var secondObstacleType = obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)];
- var secondObstacle = game.addChild(new Obstacle(secondObstacleType));
- secondObstacle.x = Math.random() * (2048 - 200) + 100;
- secondObstacle.y = spawnY - Math.random() * 150 - 50;
- obstacles.push(secondObstacle);
- }
- // At higher difficulty, spawn even more obstacles - lowered threshold and increased chance
- if (gameSpeed > 2 && Math.random() < 0.5) {
- var thirdObstacleType = obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)];
- var thirdObstacle = game.addChild(new Obstacle(thirdObstacleType));
- thirdObstacle.x = Math.random() * (2048 - 200) + 100;
- thirdObstacle.y = spawnY - Math.random() * 200 - 100;
- obstacles.push(thirdObstacle);
- }
- // Spawn fourth obstacle at very high difficulty
- if (gameSpeed > 4 && Math.random() < 0.4) {
- var fourthObstacleType = obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)];
- var fourthObstacle = game.addChild(new Obstacle(fourthObstacleType));
- fourthObstacle.x = Math.random() * (2048 - 200) + 100;
- fourthObstacle.y = spawnY - Math.random() * 300 - 150;
- obstacles.push(fourthObstacle);
- }
} else {
- // 2% chance for collectible (only wind chimes now)
+ // Collectible wind chimes
var collectible = game.addChild(new Collectible('windChime'));
collectible.x = spawnX;
collectible.y = spawnY;
collectibles.push(collectible);
}
}
+ // Independent bird spawning (rare, parallel lines)
+ if (Math.random() < 0.001 * gameSpeed) {
+ var bird = game.addChild(new Bird());
+ bird.y = player.y - Math.random() * 600 - 200;
+ obstacles.push(bird);
+ }
+ // Independent star spawning (rare, diagonal movement)
+ if (Math.random() < 0.0008 * gameSpeed) {
+ var star = game.addChild(new Star());
+ star.x = Math.random() * 2048;
+ star.y = player.y - Math.random() * 500 - 300;
+ obstacles.push(star);
+ }
+ // Independent lightning spawning (rare, vertical path)
+ if (Math.random() < 0.0006 * gameSpeed) {
+ var lightning = game.addChild(new Lightning());
+ lightning.x = Math.random() * (2048 - 100) + 50;
+ lightning.y = player.y - Math.random() * 700 - 400;
+ obstacles.push(lightning);
+ }
+ // Independent wind chime spawning (rare, appear/disappear)
+ if (Math.random() < 0.0004 * gameSpeed) {
+ var windChime = game.addChild(new WindChime());
+ windChime.x = Math.random() * (2048 - 100) + 50;
+ windChime.y = player.y - Math.random() * 600 - 200;
+ obstacles.push(windChime);
+ }
// Update and check obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
if (obstacle.lastY === undefined) obstacle.lastY = obstacle.y;