User prompt
Make it so if I get 10 gadgets the Batmobile gets replaced with the purple Batmobile and I throw a baterang in each row instead of just the one I am in.
User prompt
Make it so if you kill a villain, a gadget spawns in its place
User prompt
Show the high score text at the top of the screen large
User prompt
Show the high score text
User prompt
Make a high score
User prompt
Update high score when colliding with villains ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make it spawn more enemies and obstacles
User prompt
Make it so the slow speed gain is faster
User prompt
Make it so the game slowly speeds up ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the “roadpiece” show again
User prompt
Size down the baterang a lot
User prompt
Make the baterang Easier to shoot
User prompt
Make it easier to use the baterang
User prompt
Make the hit bad the activate the baterang much larger
User prompt
Make the “roadpiece” not move
User prompt
Make the road piece spawn more frequently
User prompt
Make the road move vertically
User prompt
Remove road pieces update from updateGameElements function
User prompt
Make the road piece vertical
User prompt
Delete the building peice
User prompt
Delete the score and gadget counter
User prompt
Delete your previous score and gadgets when you die
User prompt
Hide your previous score when you play again
User prompt
Make it so your previous score and gadgets do not show when you retry
User prompt
Fix the high score so that it shows on screen ↪💡 Consider importing and using the following plugins: @upit/storage.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { highScore: 0 }); /**** * Classes ****/ var Batarang = Container.expand(function () { var self = Container.call(this); var batarangGraphics = self.attachAsset('batarang', { anchorX: 0.5, anchorY: 0.5, width: 80, // Make batarang hit box smaller height: 40 // Make batarang hit box smaller }); self.active = true; self.speed = -40; // Negative speed to move upward (doubled for faster shots) self.update = function () { self.y += self.speed; batarangGraphics.rotation += 0.2; // Remove if off screen if (self.y < -50) { //{o} // Check if it's off the top of the screen self.active = false; } }; return self; }); var Batmobile = Container.expand(function () { var self = Container.call(this); var batmobileGraphics = self.attachAsset('batmobile', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.jumpHeight = 0; self.isJumping = false; self.lane = 1; // 0 = left, 1 = center, 2 = right self.lanePositions = [600, 1024, 1448]; // x positions for the three lanes self.groundY = 2300; // ground position self.jumping = false; self.invincible = false; self.jump = function () { if (!self.jumping) { self.jumping = true; // Jump up tween(self, { y: self.groundY - 300 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { // Fall back down tween(self, { y: self.groundY }, { duration: 500, easing: tween.easeIn, onFinish: function onFinish() { self.jumping = false; } }); } }); } }; self.moveLeft = function () { if (self.lane > 0) { self.lane--; tween(self, { x: self.lanePositions[self.lane] }, { duration: 200, easing: tween.easeOut }); } }; self.moveRight = function () { if (self.lane < 2) { self.lane++; tween(self, { x: self.lanePositions[self.lane] }, { duration: 200, easing: tween.easeOut }); } }; self.makeInvincible = function (duration) { self.invincible = true; // Flash effect var flashCount = 0; var flashInterval = LK.setInterval(function () { batmobileGraphics.alpha = batmobileGraphics.alpha === 1 ? 0.3 : 1; flashCount++; if (flashCount >= 10) { LK.clearInterval(flashInterval); batmobileGraphics.alpha = 1; self.invincible = false; } }, duration / 10); }; self.shootBatarang = function () { var batarang = new Batarang(); batarang.x = self.x; batarang.y = self.y - 50; // Position in front of the Batmobile game.addChild(batarang); activeBatarangs.push(batarang); LK.getSound('batarangThrow').play(); }; return self; }); var Gadget = Container.expand(function () { var self = Container.call(this); var gadgetGraphics = self.attachAsset('gadget', { anchorX: 0.5, anchorY: 0.5 }); self.type = 'gadget'; self.active = true; // Add some floating animation tween(gadgetGraphics, { y: 10 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(gadgetGraphics, { y: -10 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { if (self.active) { self.update(); // Restart animation } } }); } }); self.update = function () { self.y += game.gameSpeed; // Remove if off screen if (self.y > 2732 + 50) { self.active = false; } // Spin the gadget gadgetGraphics.rotation += 0.05; }; return self; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5, scaleX: Math.random() * 0.5 + 0.8, // Random sizing for variety scaleY: Math.random() * 0.5 + 0.8 // Random sizing for variety }); self.type = 'obstacle'; self.active = true; self.speed = Math.random() * 2 + 1; // Random speed modifier self.update = function () { self.y += game.gameSpeed * self.speed; // Remove if off screen if (self.y > 2732 + 100) { self.active = false; } // Add slight horizontal movement for some obstacles if (Math.random() < 0.01) { self.x += Math.sin(LK.ticks * 0.1) * 2; } }; return self; }); var Road = Container.expand(function () { var self = Container.call(this); var roadGraphics = self.attachAsset('roadPiece', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Road moves with game speed self.y += game.gameSpeed; // Loop road if it goes off screen if (self.y > 2732 + 150) { self.y = -150; } }; return self; }); var Villain = Container.expand(function () { var self = Container.call(this); var villainGraphics = self.attachAsset('villain', { anchorX: 0.5, anchorY: 0.5, scaleX: Math.random() * 0.4 + 0.8, // Random scaling for variety scaleY: Math.random() * 0.4 + 0.8 // Random scaling for variety }); self.type = 'villain'; self.active = true; self.health = Math.floor(Math.random() * 2) + 1; // Some villains take 2 hits self.movementPattern = Math.floor(Math.random() * 3); // 0: straight, 1: zigzag, 2: sine wave self.originalX = 0; // Store original X for wave patterns self.tick = 0; // Internal tick counter for movement self.speedModifier = Math.random() * 0.5 + 0.8; // Random speed modifier self.update = function () { self.tick++; self.y += game.gameSpeed * self.speedModifier; // Apply movement pattern if (self.movementPattern === 1) { // Zigzag if (self.tick % 60 < 30) { self.x += Math.sin(self.tick * 0.1) * 3; } else { self.x -= Math.sin(self.tick * 0.1) * 3; } } else if (self.movementPattern === 2) { // Sine wave if (self.tick === 1) self.originalX = self.x; self.x = self.originalX + Math.sin(self.tick * 0.05) * 100; } // Remove if off screen if (self.y > 2732 + 150) { self.active = false; } }; self.hit = function () { self.health--; if (self.health <= 0) { self.active = false; LK.setScore(LK.getScore() + 100); LK.effects.flashObject(self, 0xff0000, 300); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Game configuration // Assets are automatically created and loaded during gameplay or via static code analysis // Initialize assets used in this game. Scale them according to what is needed for the game. var gameSpeed = 10; var spawnRate = 60; // Lower = more frequent spawns var difficultyTimer = 0; var difficultyInterval = 600; // Increase difficulty every 600 ticks (about 10 seconds) var gameOver = false; var canShoot = true; var shootCooldown = 15; // Cooldown in frames (reduced to make shooting easier) var currentCooldown = 0; var gadgetCount = 0; // Game elements var batmobile; var obstacles = []; var villains = []; var gadgets = []; var activeBatarangs = []; var roadPieces = []; var lanePositions = [600, 1024, 1448]; // x positions for the three lanes // UI Elements var scoreTxt; var gadgetTxt; var highScoreTxt; // Initialize the game function initGame() { // Reset variables gameSpeed = 10; game.gameSpeed = gameSpeed; // Add gameSpeed to game object for tweening gameOver = false; obstacles = []; villains = []; gadgets = []; activeBatarangs = []; difficultyTimer = 0; gadgetCount = 0; // Reset UI texts if (gadgetTxt) { gadgetTxt.setText('GADGETS: 0'); } // Reset score display if (scoreTxt) { scoreTxt.setText('SCORE: 0'); } // Set background color to dark blue (night sky) game.setBackgroundColor(0x111133); // Play background music LK.playMusic('batmanTheme', { fade: { start: 0, end: 0.7, duration: 1000 } }); // Create the road createRoad(); // Create the Batmobile batmobile = new Batmobile(); batmobile.x = lanePositions[1]; // Start in center lane batmobile.y = 2300; // Position near bottom of screen game.addChild(batmobile); // Create UI createUI(); // Reset score LK.setScore(0); } function createRoad() { // Create several road pieces to form a continuous road for (var i = 0; i < 3; i++) { var road = new Road(); road.x = 1024; // Center of screen horizontally road.y = i * 300 + 1366 - 300; // Positioned vertically, starting from above middle of screen game.addChild(road); roadPieces.push(road); } } function createUI() { // Remove existing UI elements if they exist if (scoreTxt) { LK.gui.removeChild(scoreTxt); } if (gadgetTxt) { LK.gui.removeChild(gadgetTxt); } if (highScoreTxt) { LK.gui.topRight.removeChild(highScoreTxt); } // High score only highScoreTxt = new Text2('HIGH SCORE: ' + storage.highScore, { size: 70, fill: 0xFFFFFF }); highScoreTxt.anchor.set(1, 0); highScoreTxt.x = 1900; highScoreTxt.y = 50; LK.gui.topRight.addChild(highScoreTxt); // Create speed display speedTxt = new Text2('SPEED: ' + gameSpeed, { size: 70, fill: 0xFFFFFF }); speedTxt.anchor.set(0, 0); speedTxt.x = 150; speedTxt.y = 50; LK.gui.topLeft.addChild(speedTxt); } function spawnObstacle() { var lane = Math.floor(Math.random() * 3); // Random lane var obstacle = new Obstacle(); obstacle.x = lanePositions[lane]; obstacle.y = -100; // Start just off-screen at the top game.addChild(obstacle); obstacles.push(obstacle); // Chance to spawn multiple obstacles in different lanes if (game.gameSpeed > 15 && Math.random() < 0.3) { var secondLane = (lane + 1 + Math.floor(Math.random() * 2)) % 3; // Ensure different lane var obstacle2 = new Obstacle(); obstacle2.y = -100 - Math.random() * 200; // Slightly different vertical position obstacle2.x = lanePositions[secondLane]; game.addChild(obstacle2); obstacles.push(obstacle2); } } function spawnVillain() { var lane = Math.floor(Math.random() * 3); // Random lane var villain = new Villain(); villain.x = lanePositions[lane]; villain.y = -100; // Start just off-screen at the top game.addChild(villain); villains.push(villain); // Chance to spawn multiple villains when game speed increases if (game.gameSpeed > 15 && Math.random() < 0.4) { // Add a second villain in a different lane var secondLane = (lane + 1 + Math.floor(Math.random() * 2)) % 3; var villain2 = new Villain(); villain2.x = lanePositions[secondLane]; villain2.y = -250; // Slightly offset vertically game.addChild(villain2); villains.push(villain2); // At higher speeds, sometimes add a third villain if (game.gameSpeed > 20 && Math.random() < 0.3) { var thirdLane = 3 - lane - secondLane; // The remaining lane var villain3 = new Villain(); villain3.x = lanePositions[thirdLane]; villain3.y = -400; game.addChild(villain3); villains.push(villain3); } } } function spawnGadget() { var lane = Math.floor(Math.random() * 3); // Random lane var gadget = new Gadget(); gadget.x = lanePositions[lane]; gadget.y = -100; // Start just off-screen at the top game.addChild(gadget); gadgets.push(gadget); } function checkCollisions() { // Check Batmobile collision with obstacles for (var i = obstacles.length - 1; i >= 0; i--) { var obstacle = obstacles[i]; if (obstacle.active && batmobile.intersects(obstacle) && !batmobile.invincible) { // Collision with obstacle LK.getSound('crash').play(); LK.effects.flashScreen(0xff0000, 500); // Update high score if needed if (LK.getScore() > storage.highScore) { storage.highScore = LK.getScore(); highScoreTxt.setText('HIGH SCORE: ' + storage.highScore); } LK.showGameOver(); gameOver = true; return; } } // Check Batmobile collision with villains for (var i = villains.length - 1; i >= 0; i--) { var villain = villains[i]; if (villain.active && batmobile.intersects(villain) && !batmobile.invincible) { // Collision with villain LK.getSound('crash').play(); LK.effects.flashScreen(0xff0000, 500); // Update high score if needed if (LK.getScore() > storage.highScore) { storage.highScore = LK.getScore(); highScoreTxt.setText('HIGH SCORE: ' + storage.highScore); } LK.showGameOver(); gameOver = true; return; } } // Check Batmobile collection of gadgets for (var i = gadgets.length - 1; i >= 0; i--) { var gadget = gadgets[i]; if (gadget.active && batmobile.intersects(gadget)) { // Collect gadget gadget.active = false; LK.getSound('collect').play(); LK.setScore(LK.getScore() + 50); gadgetCount++; // Removed gadget text update // Flash gadget LK.effects.flashObject(gadget, 0xffff00, 300); gadgets.splice(i, 1); gadget.destroy(); } } // Check Batarang collision with villains for (var i = activeBatarangs.length - 1; i >= 0; i--) { var batarang = activeBatarangs[i]; if (batarang.active) { for (var j = villains.length - 1; j >= 0; j--) { var villain = villains[j]; if (villain.active && batarang.intersects(villain)) { // Hit villain with batarang villain.hit(); batarang.active = false; activeBatarangs.splice(i, 1); batarang.destroy(); if (!villain.active) { villains.splice(j, 1); villain.destroy(); } break; } } } } } function updateGameElements() { // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { var obstacle = obstacles[i]; obstacle.update(); if (!obstacle.active) { obstacles.splice(i, 1); obstacle.destroy(); } } // Update villains for (var i = villains.length - 1; i >= 0; i--) { var villain = villains[i]; villain.update(); if (!villain.active) { villains.splice(i, 1); villain.destroy(); } } // Update gadgets for (var i = gadgets.length - 1; i >= 0; i--) { var gadget = gadgets[i]; gadget.update(); if (!gadget.active) { gadgets.splice(i, 1); gadget.destroy(); } } // Update batarangs for (var i = activeBatarangs.length - 1; i >= 0; i--) { var batarang = activeBatarangs[i]; batarang.update(); if (!batarang.active) { activeBatarangs.splice(i, 1); batarang.destroy(); } } } function increaseDifficulty() { difficultyTimer++; if (difficultyTimer >= difficultyInterval) { difficultyTimer = 0; // Increase game speed gradually using tween tween(game, { gameSpeed: gameSpeed + 3.0 // Double the speed increase from 1.5 to 3.0 }, { duration: 2000, // Reduce duration from 3000ms to 2000ms easing: tween.easeOut }); // Make spawns more frequent if (spawnRate > 20) { // Lower minimum spawn rate to 20 for more frequent spawns spawnRate -= 6; // More aggressive spawn rate decrease } // At each difficulty increase, spawn a wave of enemies if (game.gameSpeed > 15) { // Spawn a wave of obstacles and villains LK.setTimeout(function () { // Spawn 2-3 obstacles var obstacleCount = Math.floor(Math.random() * 2) + 2; for (var i = 0; i < obstacleCount; i++) { spawnObstacle(); } // Spawn 1-2 villains var villainCount = Math.floor(Math.random() * 2) + 1; for (var i = 0; i < villainCount; i++) { spawnVillain(); } }, 1000); // Delay the wave slightly } // Flash screen to indicate difficulty increase LK.effects.flashScreen(0x0000ff, 300); } } function updateUI() { // Update speed display if (speedTxt) { speedTxt.setText('SPEED: ' + Math.floor(game.gameSpeed)); } } function handleShoot() { if (currentCooldown > 0) { currentCooldown--; } else { canShoot = true; } } // Initialize the game when it starts initGame(); // Game update loop game.update = function () { if (gameOver) return; // Sync gameSpeed variable with game.gameSpeed property gameSpeed = game.gameSpeed; // Update UI updateUI(); // Handle shooting cooldown handleShoot(); // Update all game elements updateGameElements(); // Check for collisions checkCollisions(); // Increase difficulty over time increaseDifficulty(); // Randomly spawn obstacles, villains, and gadgets if (LK.ticks % spawnRate === 0) { // Adjust spawn probabilities based on game speed var obstacleChance = game.gameSpeed > 20 ? 0.6 : 0.7; // Fewer obstacles at high speed var villainChance = game.gameSpeed > 20 ? 0.3 : 0.2; // More villains at high speed // 60-70% chance for obstacle, 20-30% chance for villain, 10% chance for gadget var rand = Math.random(); if (rand < obstacleChance) { spawnObstacle(); // Sometimes spawn both obstacle and villain at higher speeds if (game.gameSpeed > 25 && Math.random() < 0.2) { spawnVillain(); } } else if (rand < obstacleChance + villainChance) { spawnVillain(); } else { spawnGadget(); } } // Add additional spawn check for higher game speeds if (game.gameSpeed > 15 && LK.ticks % (spawnRate * 2) === spawnRate) { // Add extra spawns at medium intervals if (Math.random() < 0.6) { spawnObstacle(); } else { spawnVillain(); } } }; // Handle touch inputs game.down = function (x, y, obj) { if (gameOver) return; // Determine which action to take based on touch position if (y < 1366) { // Upper half of screen - shoot batarangs (no longer requires gadgets) if (canShoot) { batmobile.shootBatarang(); canShoot = false; currentCooldown = shootCooldown; } } else { // Lower half of screen - movement if (x < 1024) { batmobile.moveLeft(); } else { batmobile.moveRight(); } } }; // Handle swipe up for jump var startY = 0; game.move = function (x, y, obj) { if (gameOver) return; if (obj && obj.event) { if (obj.event.type === "touchstart") { startY = y; } else if (obj.event.type === "touchmove") { var deltaY = startY - y; if (deltaY > 100) { // If swiped up more than 100px batmobile.jump(); startY = y; // Reset to prevent multiple jumps } } } };
===================================================================
--- original.js
+++ change.js
@@ -157,18 +157,26 @@
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ scaleX: Math.random() * 0.5 + 0.8,
+ // Random sizing for variety
+ scaleY: Math.random() * 0.5 + 0.8 // Random sizing for variety
});
self.type = 'obstacle';
self.active = true;
+ self.speed = Math.random() * 2 + 1; // Random speed modifier
self.update = function () {
- self.y += game.gameSpeed;
+ self.y += game.gameSpeed * self.speed;
// Remove if off screen
if (self.y > 2732 + 100) {
self.active = false;
}
+ // Add slight horizontal movement for some obstacles
+ if (Math.random() < 0.01) {
+ self.x += Math.sin(LK.ticks * 0.1) * 2;
+ }
};
return self;
});
var Road = Container.expand(function () {
@@ -190,15 +198,36 @@
var Villain = Container.expand(function () {
var self = Container.call(this);
var villainGraphics = self.attachAsset('villain', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ scaleX: Math.random() * 0.4 + 0.8,
+ // Random scaling for variety
+ scaleY: Math.random() * 0.4 + 0.8 // Random scaling for variety
});
self.type = 'villain';
self.active = true;
- self.health = 1;
+ self.health = Math.floor(Math.random() * 2) + 1; // Some villains take 2 hits
+ self.movementPattern = Math.floor(Math.random() * 3); // 0: straight, 1: zigzag, 2: sine wave
+ self.originalX = 0; // Store original X for wave patterns
+ self.tick = 0; // Internal tick counter for movement
+ self.speedModifier = Math.random() * 0.5 + 0.8; // Random speed modifier
self.update = function () {
- self.y += game.gameSpeed;
+ self.tick++;
+ self.y += game.gameSpeed * self.speedModifier;
+ // Apply movement pattern
+ if (self.movementPattern === 1) {
+ // Zigzag
+ if (self.tick % 60 < 30) {
+ self.x += Math.sin(self.tick * 0.1) * 3;
+ } else {
+ self.x -= Math.sin(self.tick * 0.1) * 3;
+ }
+ } else if (self.movementPattern === 2) {
+ // Sine wave
+ if (self.tick === 1) self.originalX = self.x;
+ self.x = self.originalX + Math.sin(self.tick * 0.05) * 100;
+ }
// Remove if off screen
if (self.y > 2732 + 150) {
self.active = false;
}
@@ -336,16 +365,44 @@
obstacle.x = lanePositions[lane];
obstacle.y = -100; // Start just off-screen at the top
game.addChild(obstacle);
obstacles.push(obstacle);
+ // Chance to spawn multiple obstacles in different lanes
+ if (game.gameSpeed > 15 && Math.random() < 0.3) {
+ var secondLane = (lane + 1 + Math.floor(Math.random() * 2)) % 3; // Ensure different lane
+ var obstacle2 = new Obstacle();
+ obstacle2.y = -100 - Math.random() * 200; // Slightly different vertical position
+ obstacle2.x = lanePositions[secondLane];
+ game.addChild(obstacle2);
+ obstacles.push(obstacle2);
+ }
}
function spawnVillain() {
var lane = Math.floor(Math.random() * 3); // Random lane
var villain = new Villain();
villain.x = lanePositions[lane];
villain.y = -100; // Start just off-screen at the top
game.addChild(villain);
villains.push(villain);
+ // Chance to spawn multiple villains when game speed increases
+ if (game.gameSpeed > 15 && Math.random() < 0.4) {
+ // Add a second villain in a different lane
+ var secondLane = (lane + 1 + Math.floor(Math.random() * 2)) % 3;
+ var villain2 = new Villain();
+ villain2.x = lanePositions[secondLane];
+ villain2.y = -250; // Slightly offset vertically
+ game.addChild(villain2);
+ villains.push(villain2);
+ // At higher speeds, sometimes add a third villain
+ if (game.gameSpeed > 20 && Math.random() < 0.3) {
+ var thirdLane = 3 - lane - secondLane; // The remaining lane
+ var villain3 = new Villain();
+ villain3.x = lanePositions[thirdLane];
+ villain3.y = -400;
+ game.addChild(villain3);
+ villains.push(villain3);
+ }
+ }
}
function spawnGadget() {
var lane = Math.floor(Math.random() * 3); // Random lane
var gadget = new Gadget();
@@ -477,11 +534,28 @@
// Reduce duration from 3000ms to 2000ms
easing: tween.easeOut
});
// Make spawns more frequent
- if (spawnRate > 30) {
- spawnRate -= 5; // Decrease spawn rate more aggressively
+ if (spawnRate > 20) {
+ // Lower minimum spawn rate to 20 for more frequent spawns
+ spawnRate -= 6; // More aggressive spawn rate decrease
}
+ // At each difficulty increase, spawn a wave of enemies
+ if (game.gameSpeed > 15) {
+ // Spawn a wave of obstacles and villains
+ LK.setTimeout(function () {
+ // Spawn 2-3 obstacles
+ var obstacleCount = Math.floor(Math.random() * 2) + 2;
+ for (var i = 0; i < obstacleCount; i++) {
+ spawnObstacle();
+ }
+ // Spawn 1-2 villains
+ var villainCount = Math.floor(Math.random() * 2) + 1;
+ for (var i = 0; i < villainCount; i++) {
+ spawnVillain();
+ }
+ }, 1000); // Delay the wave slightly
+ }
// Flash screen to indicate difficulty increase
LK.effects.flashScreen(0x0000ff, 300);
}
}
@@ -516,18 +590,34 @@
// Increase difficulty over time
increaseDifficulty();
// Randomly spawn obstacles, villains, and gadgets
if (LK.ticks % spawnRate === 0) {
- // 70% chance for obstacle, 20% chance for villain, 10% chance for gadget
+ // Adjust spawn probabilities based on game speed
+ var obstacleChance = game.gameSpeed > 20 ? 0.6 : 0.7; // Fewer obstacles at high speed
+ var villainChance = game.gameSpeed > 20 ? 0.3 : 0.2; // More villains at high speed
+ // 60-70% chance for obstacle, 20-30% chance for villain, 10% chance for gadget
var rand = Math.random();
- if (rand < 0.7) {
+ if (rand < obstacleChance) {
spawnObstacle();
- } else if (rand < 0.9) {
+ // Sometimes spawn both obstacle and villain at higher speeds
+ if (game.gameSpeed > 25 && Math.random() < 0.2) {
+ spawnVillain();
+ }
+ } else if (rand < obstacleChance + villainChance) {
spawnVillain();
} else {
spawnGadget();
}
}
+ // Add additional spawn check for higher game speeds
+ if (game.gameSpeed > 15 && LK.ticks % (spawnRate * 2) === spawnRate) {
+ // Add extra spawns at medium intervals
+ if (Math.random() < 0.6) {
+ spawnObstacle();
+ } else {
+ spawnVillain();
+ }
+ }
};
// Handle touch inputs
game.down = function (x, y, obj) {
if (gameOver) return;