User prompt
Make title screen and all UI 3x bigger and make it so the death message does pop up ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make a logo that I can customize and the death messages don’t show up when I lose
User prompt
Make the death screen be able to say about 100 different and funny death messages such as “you died, oh wait, noooooo :(“
User prompt
Add a pause screen with the option of going back to the main menu
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'LK.effects.flashObject(turret, 0xffffff, 200);' Line Number: 1023
User prompt
Fix everything related to bullet amount
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'var velocity = turret.getShootVelocity();' Line Number: 986
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'bullet.x = turret.x;' Line Number: 976
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'shotsTxt.setText('Shots: ' + shotsRemaining);' Line Number: 968
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'shotsTxt.setText('Shots: ' + shotsRemaining);' Line Number: 965
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'shotsTxt.setText('Shots: ' + shotsRemaining);' Line Number: 965
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'shotsTxt.setText('Shots: ' + shotsRemaining);' Line Number: 963
User prompt
Make baby mod literally impossible to lose and another difficulty called impossible mode where it is impossible to win do whatever in impossible. Also in baby if you lose make it say “aww you lost, that’s cute” and make it give you another life. Also add death screens and a title screen with a logo.
User prompt
Create baby mode which make the targets 5x larger and adds a bunch of powerups. Also code in a bunch of powerups and a lucky block that if you shoot it could give you a random one ↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'var power = Math.min(turret.maxPower, dragDistance / 50);' Line Number: 608
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'turret.updateRotation(angle);' Line Number: 588
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'var dx = x - turret.x;' Line Number: 557
User prompt
Please fix the bug: 'storage.getItem is not a function. (In 'storage.getItem('bulletBounce_difficulty')', 'storage.getItem' is undefined)' in or related to this line: 'var savedDifficulty = storage.getItem('bulletBounce_difficulty');' Line Number: 565 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Difficulty selection
User prompt
Make levels random and make the ball bigger
User prompt
Replace the ball with https://upit.com/#
Code edit (1 edits merged)
Please save this source code
User prompt
Bullet Bounce
Initial prompt
Gun. Do whatever you want with that.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var AimLine = Container.expand(function () { var self = Container.call(this); var line = self.attachAsset('aimLine', { anchorX: 0.5, anchorY: 0 }); self.update = function (angle, length) { line.rotation = angle; line.height = length; }; return self; }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5, rotation: 0 }); self.speedX = 0; self.speedY = 0; self.bounces = 0; self.isExplosive = false; // Special effect for explosive bullets if (typeof activePowerUps !== 'undefined' && activePowerUps.explosive) { bulletGraphics.tint = 0xFF0000; } // Set max bounces based on game difficulty if (typeof gameDifficulty !== 'undefined') { switch (gameDifficulty) { case "easy": self.maxBounces = 10; // More bounces for easy mode break; case "normal": self.maxBounces = 8; break; case "hard": self.maxBounces = 5; // Fewer bounces for hard mode break; default: self.maxBounces = 8; } } else { self.maxBounces = 8; // Default value } self.isActive = true; self.update = function () { if (!self.isActive) { return; } // Check for impossible mode - make bullets behave erratically if (typeof isImpossibleMode !== 'undefined' && isImpossibleMode) { // In impossible mode, bullets randomly change direction if (Math.random() < 0.05) { self.speedX = self.speedX * (0.8 + Math.random() * 0.4); self.speedY = self.speedY * (0.8 + Math.random() * 0.4); // Occasionally make a sharp turn if (Math.random() < 0.1) { self.speedX *= -1; } } } // Apply velocity self.x += self.speedX; self.y += self.speedY; // Apply a small rotation for visual effect bulletGraphics.rotation += 0.05; // Check for wall collisions if (self.x < 30 || self.x > 2018) { self.speedX *= -0.9; // Lose some energy on bounce if (self.x < 30) { self.x = 30; } if (self.x > 2018) { self.x = 2018; } self.bounces++; LK.getSound('bounce').play(); } if (self.y < 30 || self.y > 2702) { self.speedY *= -0.9; // Lose some energy on bounce if (self.y < 30) { self.y = 30; } if (self.y > 2702) { self.y = 2702; } self.bounces++; LK.getSound('bounce').play(); } // Check if bullet should be removed if (self.bounces >= self.maxBounces || Math.abs(self.speedX) < 0.5 && Math.abs(self.speedY) < 0.5) { self.isActive = false; } }; return self; }); var DeathScreen = Container.expand(function () { var self = Container.call(this); var background = self.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, width: 1000, height: 700, tint: 0x000000, alpha: 0.8 }); var messageText = new Text2("GAME OVER", { size: 100, fill: 0xFF0000 }); messageText.anchor.set(0.5, 0.5); messageText.y = -100; self.addChild(messageText); var babyMessage = new Text2("Aww you lost, that's cute!", { size: 50, fill: 0xFF55FF }); babyMessage.anchor.set(0.5, 0.5); babyMessage.y = 0; babyMessage.visible = false; // Only shown in baby mode self.addChild(babyMessage); var restartButton = new Container(); var buttonBg = restartButton.attachAsset('powerMeter', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 100, tint: 0x22cc22 }); var buttonText = new Text2("RETRY", { size: 60, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); restartButton.addChild(buttonText); restartButton.y = 150; self.addChild(restartButton); // Add button interaction restartButton.down = function () { if (isBabyMode) { // In baby mode, give an extra life instead of game over self.visible = false; shotsRemaining += 1; if (shotsTxt && typeof shotsTxt !== 'undefined') { shotsTxt.setText('Shots: ' + shotsRemaining); } // Spawn a few powerups to help for (var i = 0; i < 2; i++) { createPowerUp(turret.x + 100 + i * 100, turret.y - 100 - i * 50); } } else { LK.showGameOver(); } }; self.showMessage = function (isBaby) { babyMessage.visible = isBaby; self.visible = true; // Animate death screen appearance self.alpha = 0; tween(self, { alpha: 1 }, { duration: 500, easing: tween.easeOut }); }; return self; }); var Difficulty = Container.expand(function () { var self = Container.call(this); // Button base size and spacing var buttonWidth = 300; var buttonHeight = 100; var spacing = 30; // Create title var titleText = new Text2('SELECT DIFFICULTY', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.y = -200; self.addChild(titleText); // Create difficulty buttons var easyButton = createButton('EASY', -buttonWidth - spacing, -100, 0x44AA44); var normalButton = createButton('NORMAL', buttonWidth + spacing, -100, 0x4477AA); var hardButton = createButton('HARD', -buttonWidth - spacing, 50, 0xAA4444); var babyButton = createButton('BABY', buttonWidth + spacing, 50, 0xFF55FF); var impossibleButton = createButton('IMPOSSIBLE', 0, 200, 0x000000); self.addChild(easyButton); self.addChild(normalButton); self.addChild(hardButton); self.addChild(babyButton); self.addChild(impossibleButton); function createButton(text, xPos, yPos, color) { var button = new Container(); // Button background var bg = button.attachAsset('powerMeter', { anchorX: 0.5, anchorY: 0.5, width: buttonWidth, height: buttonHeight, tint: color }); // Button text var txt = new Text2(text, { size: 50, fill: 0xFFFFFF }); txt.anchor.set(0.5, 0.5); button.addChild(txt); // Position button button.x = xPos; button.y = yPos; // Add interaction button.down = function () { selectDifficulty(text.toLowerCase()); }; return button; } function selectDifficulty(level) { // Set difficulty and hide selector gameDifficulty = level; self.visible = false; // Set mode flags isBabyMode = level === "baby"; isImpossibleMode = level === "impossible"; // Save selected difficulty storage.bulletBounce_difficulty = level; // Start the game with selected difficulty initGame(); } return self; }); var LuckyBlock = Container.expand(function () { var self = Container.call(this); var blockGraphics = self.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, width: 80, height: 80, tint: 0xFFD700 // Gold color }); // Question mark text var questionMark = new Text2("?", { size: 50, fill: 0x000000 }); questionMark.anchor.set(0.5, 0.5); self.addChild(questionMark); self.isHit = false; // Add visual effect - rotating self.update = function () { questionMark.rotation = Math.sin(LK.ticks * 0.05) * 0.2; blockGraphics.rotation = Math.sin(LK.ticks * 0.03) * 0.1; }; self.hit = function () { if (self.isHit) { return; } self.isHit = true; LK.effects.flashObject(self, 0xffffff, 300); // Animation for breaking tween(blockGraphics, { alpha: 0, scaleX: 1.5, scaleY: 1.5 }, { duration: 500, easing: tween.easeOut }); tween(questionMark, { alpha: 0, scaleX: 0.2, scaleY: 0.2 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { // Spawn random powerup spawnRandomPowerUp(self.x, self.y); self.visible = false; } }); }; return self; }); var PowerMeter = Container.expand(function () { var self = Container.call(this); var meterBg = self.attachAsset('powerMeter', { anchorX: 0, anchorY: 0.5, tint: 0x444444 }); var meterFill = self.attachAsset('powerMeter', { anchorX: 0, anchorY: 0.5, scaleX: 0.5 }); self.setPower = function (power, maxPower) { meterFill.scaleX = power / maxPower; }; return self; }); var PowerUp = Container.expand(function () { var self = Container.call(this); self.type = ""; self.isCollected = false; // Define powerup sizes and colors var types = { "multishot": { color: 0xff5500, text: "3x" }, "bigball": { color: 0x00aaff, text: "BIG" }, "slowmotion": { color: 0xaa00ff, text: "SLOW" }, "extralife": { color: 0xff0055, text: "LIFE" }, "explosive": { color: 0xff0000, text: "BOOM" } }; // Background circle var bg = self.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, width: 60, height: 60 }); // Text label var label = new Text2("", { size: 25, fill: 0xFFFFFF }); label.anchor.set(0.5, 0.5); self.addChild(label); self.setType = function (powerupType) { self.type = powerupType; bg.tint = types[powerupType].color; label.setText(types[powerupType].text); // Add visual effect - pulsing self.update = function () { var pulse = Math.sin(LK.ticks * 0.05) * 0.1 + 1; bg.scale.set(pulse, pulse); }; }; self.collect = function () { if (self.isCollected) { return; } self.isCollected = true; LK.effects.flashObject(self, 0xffffff, 300); // Animation for collection tween(self, { alpha: 0, scaleX: 0.2, scaleY: 0.2 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { self.visible = false; } }); // Apply powerup effect based on type applyPowerUpEffect(self.type); }; self.down = function () { // Allow clicking on powerups too (mobile friendly) self.collect(); }; return self; }); var Target = Container.expand(function () { var self = Container.call(this); var targetGraphics = self.attachAsset('target', { anchorX: 0.5, anchorY: 0.5 }); // Make targets 5x larger in baby mode if (typeof isBabyMode !== 'undefined' && isBabyMode) { targetGraphics.scale.set(5, 5); } self.isHit = false; self.hit = function () { if (self.isHit) { return; } self.isHit = true; LK.getSound('targetHit').play(); LK.effects.flashObject(self, 0xffffff, 300); tween(targetGraphics, { alpha: 0, scaleX: 0.2, scaleY: 0.2 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { targetGraphics.visible = false; } }); // Increment score LK.setScore(LK.getScore() + 100); }; return self; }); var TitleScreen = Container.expand(function () { var self = Container.call(this); // Create logo using a shape as background var logoBackground = self.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, width: 500, height: 300, tint: 0x3355ff }); // Logo text var titleText = new Text2("BULLET\nBOUNCE", { size: 100, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); self.addChild(titleText); // Start button var startButton = new Container(); var buttonBg = startButton.attachAsset('powerMeter', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 100, tint: 0x22cc22 }); var buttonText = new Text2("PLAY", { size: 70, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); startButton.addChild(buttonText); startButton.y = 250; self.addChild(startButton); // Add button interaction startButton.down = function () { self.visible = false; difficultySelector.visible = true; }; // Animation for title tween(titleText, { scaleX: 1.1, scaleY: 1.1 }, { duration: 1000, easing: tween.easeInOut, loop: true, yoyo: true }); return self; }); var Turret = Container.expand(function () { var self = Container.call(this); var base = self.attachAsset('turret', { anchorX: 0.5, anchorY: 0.5 }); var barrel = self.attachAsset('turretBarrel', { anchorX: 0, anchorY: 0.5, x: 0, y: 0 }); self.angle = 0; self.power = 10; self.maxPower = 20; self.isDragging = false; self.updateRotation = function (angle) { self.angle = angle; barrel.rotation = angle; }; self.setPower = function (power) { self.power = Math.max(5, Math.min(self.maxPower, power)); }; self.getShootVelocity = function () { return { x: Math.cos(self.angle) * self.power, y: Math.sin(self.angle) * self.power }; }; return self; }); var Wall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x222222 }); /**** * Game Code ****/ // Game variables var turret; var bullets = []; var targets = []; var walls = []; var powerups = []; var luckyBlocks = []; var powerMeter; var aimLine; var isDragging = false; var dragStartX, dragStartY; var currentLevel = 1; var shotsRemaining = 5; var totalTargets = 0; var targetsHit = 0; var difficultySelector; var titleScreen; var deathScreen; var gameDifficulty = "normal"; // Default difficulty var isBabyMode = false; var isImpossibleMode = false; var activePowerUps = { multishot: false, bigball: false, slowmotion: false, explosive: false }; var powerUpTimers = {}; // Function to apply powerup effects function applyPowerUpEffect(type) { switch (type) { case "multishot": activePowerUps.multishot = true; powerUpTimers.multishot = LK.setTimeout(function () { activePowerUps.multishot = false; }, 15000); // 15 seconds break; case "bigball": activePowerUps.bigball = true; powerUpTimers.bigball = LK.setTimeout(function () { activePowerUps.bigball = false; }, 20000); // 20 seconds break; case "slowmotion": activePowerUps.slowmotion = true; powerUpTimers.slowmotion = LK.setTimeout(function () { activePowerUps.slowmotion = false; }, 10000); // 10 seconds break; case "extralife": shotsRemaining += 3; shotsTxt.setText('Shots: ' + shotsRemaining); break; case "explosive": activePowerUps.explosive = true; powerUpTimers.explosive = LK.setTimeout(function () { activePowerUps.explosive = false; }, 12000); // 12 seconds break; } } // Function to create a random powerup function createPowerUp(x, y, type) { var powerup = new PowerUp(); powerup.x = x; powerup.y = y; powerup.setType(type || getRandomPowerUpType()); game.addChild(powerup); powerups.push(powerup); return powerup; } // Function to create a lucky block function createLuckyBlock(x, y) { var luckyBlock = new LuckyBlock(); luckyBlock.x = x; luckyBlock.y = y; game.addChild(luckyBlock); luckyBlocks.push(luckyBlock); return luckyBlock; } // Function to get random powerup type function getRandomPowerUpType() { var types = ["multishot", "bigball", "slowmotion", "extralife", "explosive"]; return types[Math.floor(Math.random() * types.length)]; } // Function to spawn random powerup at position function spawnRandomPowerUp(x, y) { createPowerUp(x, y); } // UI elements var shotsTxt; var levelTxt; function initGame() { // Check if game is starting fresh or resuming from difficulty selection if (!difficultySelector || !difficultySelector.visible) { // Create death screen first (initialized but hidden) if (!deathScreen) { deathScreen = new DeathScreen(); deathScreen.x = 2048 / 2; deathScreen.y = 2732 / 2; deathScreen.visible = false; game.addChild(deathScreen); } // Create turret turret = new Turret(); turret.x = 100; turret.y = 2732 - 100; game.addChild(turret); // Create aim line aimLine = new AimLine(); aimLine.x = turret.x; aimLine.y = turret.y; game.addChild(aimLine); // Create power meter powerMeter = new PowerMeter(); powerMeter.x = 50; powerMeter.y = 2732 - 200; game.addChild(powerMeter); powerMeter.setPower(turret.power, turret.maxPower); // Setup UI shotsTxt = new Text2('Shots: ' + shotsRemaining, { size: 50, fill: 0xFFFFFF }); shotsTxt.anchor.set(0, 0); LK.gui.topRight.addChild(shotsTxt); levelTxt = new Text2('Level: ' + currentLevel, { size: 50, fill: 0xFFFFFF }); levelTxt.anchor.set(0, 0); LK.gui.top.addChild(levelTxt); // Score text var scoreTxt = new Text2('Score: 0', { size: 50, fill: 0xFFFFFF }); scoreTxt.anchor.set(1, 0); LK.gui.topRight.addChild(scoreTxt); // Update score display LK.setInterval(function () { scoreTxt.setText('Score: ' + LK.getScore()); }, 100); // Load level with current difficulty loadLevel(currentLevel); // Play background music LK.playMusic('gameMusic'); } } function loadLevel(level) { // Clear any existing level elements clearLevel(); // Update level display levelTxt.setText('Level: ' + level); // Update shots based on difficulty switch (gameDifficulty) { case "baby": shotsRemaining = 50 + level; // Way more shots in baby mode break; case "easy": shotsRemaining = 5 + level; break; case "normal": shotsRemaining = 3 + level; break; case "hard": shotsRemaining = 2 + Math.floor(level / 2); break; case "impossible": shotsRemaining = 1; // Just one shot in impossible mode break; default: shotsRemaining = 3 + level; } // Add null check before updating shotsTxt if (shotsTxt && typeof shotsTxt !== 'undefined') { shotsTxt.setText('Shots: ' + shotsRemaining); } // Clear powerups and lucky blocks for (var i = powerups.length - 1; i >= 0; i--) { game.removeChild(powerups[i]); powerups.splice(i, 1); } for (var i = luckyBlocks.length - 1; i >= 0; i--) { game.removeChild(luckyBlocks[i]); luckyBlocks.splice(i, 1); } // Reset active powerups for (var key in activePowerUps) { activePowerUps[key] = false; } for (var key in powerUpTimers) { LK.clearTimeout(powerUpTimers[key]); } // Apply baby mode permanent powerups if (isBabyMode) { // In baby mode, always have these powerups active activePowerUps.multishot = true; activePowerUps.bigball = true; // Add a bunch of powerups right at the beginning for (var i = 0; i < 5; i++) { createPowerUp(300 + i * 200, 300 + i * 100); } } // Different level layouts switch (level) { case 1: // Basic level with random targets var targetCount = isBabyMode ? 3 : isImpossibleMode ? 15 : 3; for (var i = 0; i < targetCount; i++) { var targetX = 500 + Math.random() * 1000; var targetY = 300 + Math.random() * 800; // In impossible mode, place targets in very difficult positions if (isImpossibleMode) { // Place some targets behind walls, at extreme edges, etc. targetX = i % 3 === 0 ? 50 + Math.random() * 100 : 1900 + Math.random() * 100; targetY = i % 2 === 0 ? 50 + Math.random() * 100 : 2500 + Math.random() * 100; } createTarget(targetX, targetY); } // Add random walls if (isImpossibleMode) { // Create many walls in impossible mode for (var i = 0; i < 10; i++) { createWall(100 + i * 200, 400, Math.PI / 2); // Horizontal barrier } // Create a protective wall around the targets createWall(1800, 100, 0); createWall(1800, 400, 0); createWall(1800, 700, 0); } else if (!isBabyMode) { createWall(500 + Math.random() * 200, 500 + Math.random() * 200, Math.random() * Math.PI / 2); createWall(1300 + Math.random() * 200, 900 + Math.random() * 200, Math.random() * Math.PI / 2); } break; case 2: // More complex level with random targets var targetCount = isBabyMode ? 4 : isImpossibleMode ? 20 : 5; for (var i = 0; i < targetCount; i++) { var targetX = 400 + Math.random() * 1200; var targetY = 400 + Math.random() * 1100; // In impossible mode, place targets in very difficult positions if (isImpossibleMode) { targetX = i % 3 === 0 ? 50 + Math.random() * 100 : 1900 + Math.random() * 100; targetY = i % 4 === 0 ? 50 + Math.random() * 100 : 2500 + Math.random() * 100; } createTarget(targetX, targetY); } // Add random walls if (isImpossibleMode) { // Create a complex maze in impossible mode for (var i = 0; i < 15; i++) { createWall(300 + i * 100, 400, 0); createWall(300 + i * 100, 1000, 0); } } else if (!isBabyMode) { createWall(400 + Math.random() * 100, 800 + Math.random() * 100, Math.random() * Math.PI / 4); createWall(1500 + Math.random() * 100, 800 + Math.random() * 100, Math.random() * Math.PI / 4); createWall(900 + Math.random() * 200, 300 + Math.random() * 100, Math.PI / 2 + Math.random() * 0.3); createWall(900 + Math.random() * 200, 1400 + Math.random() * 100, Math.PI / 2 + Math.random() * 0.3); } break; case 3: // Advanced level with random elements var targetCount = isBabyMode ? 5 : isImpossibleMode ? 25 : 7; for (var i = 0; i < targetCount; i++) { // Create targets in different quadrants of the screen if (isImpossibleMode) { // In impossible mode, place targets in extremely difficult positions var quadrant = i % 4; var xOffset = quadrant === 0 || quadrant === 2 ? 50 : 1900; var yOffset = quadrant === 0 || quadrant === 1 ? 50 : 2500; createTarget(xOffset + Math.random() * 50, yOffset + Math.random() * 50); } else { if (i < 2) { createTarget(300 + Math.random() * 400, 300 + Math.random() * 400); } else if (i < 4) { createTarget(1300 + Math.random() * 400, 300 + Math.random() * 400); } else if (i < 6) { createTarget(300 + Math.random() * 400, 1100 + Math.random() * 400); } else { createTarget(1300 + Math.random() * 400, 1100 + Math.random() * 400); } } } // Add walls if (isImpossibleMode) { // Create a complex defensive wall system in impossible mode for (var i = 0; i < 20; i++) { // Create a circular defensive wall var angle = i / 20 * Math.PI * 2; var radius = 800; var centerX = 1024; var centerY = 1366; var wallX = centerX + Math.cos(angle) * radius; var wallY = centerY + Math.sin(angle) * radius; createWall(wallX, wallY, angle); } } else if (!isBabyMode) { createWall(600 + Math.random() * 100, 600 + Math.random() * 100, Math.random() * 0.2); createWall(1300 + Math.random() * 100, 600 + Math.random() * 100, Math.random() * 0.2); createWall(600 + Math.random() * 100, 1200 + Math.random() * 100, Math.random() * 0.2); createWall(1300 + Math.random() * 100, 1200 + Math.random() * 100, Math.random() * 0.2); createWall(1000 + Math.random() * 100, 600 + Math.random() * 100, Math.PI / 2 + Math.random() * 0.2); createWall(1000 + Math.random() * 100, 1200 + Math.random() * 100, Math.PI / 2 + Math.random() * 0.2); } break; default: // For levels beyond 3, create a fully random level with more targets and walls // Adjust difficulty based on selected mode var difficultyMultiplier; switch (gameDifficulty) { case "baby": difficultyMultiplier = 0.3; // Much fewer targets and walls for baby mode break; case "easy": difficultyMultiplier = 0.7; // Fewer targets and walls break; case "normal": difficultyMultiplier = 1.0; // Normal difficulty break; case "hard": difficultyMultiplier = 1.5; // More targets and walls break; case "impossible": difficultyMultiplier = 3.0; // Way more targets and walls for impossible mode break; default: difficultyMultiplier = 1.0; } // Generate random number of targets based on level and difficulty var numTargets = Math.max(2, Math.floor((3 + Math.random() * level * 2) * difficultyMultiplier)); for (var i = 0; i < numTargets; i++) { var targetX = 300 + Math.random() * 1400; var targetY = 300 + Math.random() * 1500; // In impossible mode, position targets in very difficult places if (isImpossibleMode) { if (i % 3 === 0) { // Place targets at extreme edges targetX = Math.random() < 0.5 ? 50 + Math.random() * 50 : 1948 - Math.random() * 50; targetY = Math.random() < 0.5 ? 50 + Math.random() * 50 : 2682 - Math.random() * 50; } } createTarget(targetX, targetY); } // Generate random number of walls based on level and difficulty if (isImpossibleMode) { // Create complex wall patterns for impossible mode var wallCount = 20 + Math.floor(level * 2); for (var i = 0; i < wallCount; i++) { // Create walls that make targets very hard to hit var wallX = 300 + Math.random() * 1400; var wallY = 300 + Math.random() * 1500; var wallRotation = Math.random() * Math.PI; // Some walls positioned strategically to block shots if (i % 5 === 0) { wallX = 200; wallY = 400 + i / 5 * 300; wallRotation = 0; } createWall(wallX, wallY, wallRotation); } } else if (!isBabyMode) { var numWalls = Math.max(2, Math.floor(Math.random() * level * 1.5 * difficultyMultiplier)); for (var i = 0; i < numWalls; i++) { createWall(300 + Math.random() * 1400, 300 + Math.random() * 1500, Math.random() * Math.PI); } } // Add powerups - tons more in baby mode var numPowerups = isBabyMode ? 10 + Math.floor(level) : isImpossibleMode ? 0 : 1 + Math.floor(level / 3); for (var i = 0; i < numPowerups; i++) { createPowerUp(300 + Math.random() * 1400, 300 + Math.random() * 1500); } // Add lucky blocks - more in baby mode, none in impossible var numLuckyBlocks = isBabyMode ? 5 + Math.floor(level / 2) : isImpossibleMode ? 0 : 1 + Math.floor(level / 4); for (var i = 0; i < numLuckyBlocks; i++) { createLuckyBlock(300 + Math.random() * 1400, 300 + Math.random() * 1500); } break; } // Track targets for win condition totalTargets = targets.length; targetsHit = 0; } function clearLevel() { // Remove all bullets for (var i = bullets.length - 1; i >= 0; i--) { game.removeChild(bullets[i]); bullets.splice(i, 1); } // Remove all targets for (var i = targets.length - 1; i >= 0; i--) { game.removeChild(targets[i]); targets.splice(i, 1); } // Remove all walls for (var i = walls.length - 1; i >= 0; i--) { game.removeChild(walls[i]); walls.splice(i, 1); } } function createTarget(x, y) { var target = new Target(); target.x = x; target.y = y; game.addChild(target); targets.push(target); return target; } function createWall(x, y, rotation) { var wall = new Wall(); wall.x = x; wall.y = y; wall.rotation = rotation; game.addChild(wall); walls.push(wall); return wall; } function fireBullet() { if (shotsRemaining <= 0) { return; } // Decrease shots remaining shotsRemaining--; if (shotsTxt && typeof shotsTxt !== 'undefined') { shotsTxt.setText('Shots: ' + shotsRemaining); } // Determine how many bullets to fire based on powerups var bulletCount = activePowerUps.multishot ? 3 : 1; for (var i = 0; i < bulletCount; i++) { // Create new bullet var bullet = new Bullet(); // Add null check to ensure turret exists before accessing its properties if (turret) { bullet.x = turret.x; bullet.y = turret.y; } else { // Set default position if turret doesn't exist bullet.x = 100; bullet.y = 2732 - 100; } // Get velocity from turret angle and power var velocity = turret.getShootVelocity(); // If multishot, spread the bullets if (activePowerUps.multishot && bulletCount > 1) { var spreadAngle = (i - 1) * 0.2; // -0.2, 0, 0.2 radians spread var newAngle = Math.atan2(velocity.y, velocity.x) + spreadAngle; var speed = Math.sqrt(velocity.x * velocity.x + velocity.y * velocity.y); bullet.speedX = Math.cos(newAngle) * speed; bullet.speedY = Math.sin(newAngle) * speed; } else { bullet.speedX = velocity.x; bullet.speedY = velocity.y; } // Apply slowmotion powerup if (activePowerUps.slowmotion) { bullet.speedX *= 0.6; bullet.speedY *= 0.6; } // Apply big ball powerup if (activePowerUps.bigball) { bullet.scale.set(2.5, 2.5); } // Apply explosive powerup if needed if (activePowerUps.explosive) { bullet.isExplosive = true; } // Add to game game.addChild(bullet); bullets.push(bullet); } // Play sound LK.getSound('shoot').play(); // Flash turret LK.effects.flashObject(turret, 0xffffff, 200); } function checkCollisions() { // Check all active bullets for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; if (!bullet.isActive) { // Remove inactive bullets game.removeChild(bullet); bullets.splice(i, 1); continue; } // Check for wall collisions for (var j = 0; j < walls.length; j++) { var wall = walls[j]; if (bullet.intersects(wall)) { // Calculate bounce direction based on wall angle var wallAngle = wall.rotation; var normalAngle = wallAngle + Math.PI / 2; // Reflect velocity based on wall normal var speed = Math.sqrt(bullet.speedX * bullet.speedX + bullet.speedY * bullet.speedY); var bulletAngle = Math.atan2(bullet.speedY, bullet.speedX); var reflectionAngle = 2 * normalAngle - bulletAngle; bullet.speedX = Math.cos(reflectionAngle) * speed * 0.8; // Lose some energy bullet.speedY = Math.sin(reflectionAngle) * speed * 0.8; // Move bullet slightly away from wall to prevent multiple collisions bullet.x += bullet.speedX; bullet.y += bullet.speedY; bullet.bounces++; LK.getSound('bounce').play(); } } // Check for target collisions for (var j = 0; j < targets.length; j++) { var target = targets[j]; if (!target.isHit && bullet.intersects(target)) { target.hit(); targetsHit++; // If explosive bullet, create explosion effect if (bullet.isExplosive) { // Hit nearby targets within radius var explosionRadius = 250; for (var k = 0; k < targets.length; k++) { if (j !== k && !targets[k].isHit) { var dx = targets[k].x - target.x; var dy = targets[k].y - target.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < explosionRadius) { targets[k].hit(); targetsHit++; } } } // Visual explosion effect LK.effects.flashScreen(0xFF5500, 200); } // Check if level complete if (targetsHit >= totalTargets) { levelComplete(); } } } // Check for lucky block collisions for (var j = luckyBlocks.length - 1; j >= 0; j--) { var luckyBlock = luckyBlocks[j]; if (!luckyBlock.isHit && bullet.intersects(luckyBlock)) { luckyBlock.hit(); luckyBlocks.splice(j, 1); } } // Check for powerup collisions for (var j = powerups.length - 1; j >= 0; j--) { var powerup = powerups[j]; if (!powerup.isCollected && bullet.intersects(powerup)) { powerup.collect(); powerups.splice(j, 1); } } } } function levelComplete() { LK.setTimeout(function () { // Advance to next level currentLevel++; loadLevel(currentLevel); }, 1000); } function checkGameOver() { // Game over conditions if (shotsRemaining <= 0 && bullets.length === 0) { // Check if any targets left var anyTargetsLeft = false; for (var i = 0; i < targets.length; i++) { if (!targets[i].isHit) { anyTargetsLeft = true; break; } } if (anyTargetsLeft) { // Player has lost LK.setTimeout(function () { if (isBabyMode) { // In baby mode, show custom death screen instead of game over deathScreen.showMessage(true); } else { LK.showGameOver(); } }, 1000); } } } function calculateAimAngle(x, y) { // Calculate angle from turret to mouse/touch point // Check if turret exists before accessing its properties if (!turret) { return 0; // Return default angle if turret doesn't exist yet } var dx = x - turret.x; var dy = y - turret.y; return Math.atan2(dy, dx); } function updateAimLine() { if (turret && aimLine) { aimLine.update(turret.angle, 200); } } // Load previously selected difficulty if available var savedDifficulty = storage.bulletBounce_difficulty; if (savedDifficulty) { gameDifficulty = savedDifficulty; } // Create title screen titleScreen = new TitleScreen(); titleScreen.x = 2048 / 2; titleScreen.y = 2732 / 2; game.addChild(titleScreen); // Create difficulty selector (initially hidden) difficultySelector = new Difficulty(); difficultySelector.x = 2048 / 2; difficultySelector.y = 2732 / 2; difficultySelector.visible = false; game.addChild(difficultySelector); // If we just want to start the game directly with saved difficulty, uncomment this: // titleScreen.visible = false; // difficultySelector.visible = false; // initGame(); // Event handlers game.down = function (x, y, obj) { isDragging = true; dragStartX = x; dragStartY = y; // Set initial angle var angle = calculateAimAngle(x, y); if (turret) { // Add null check to ensure turret exists turret.updateRotation(angle); } updateAimLine(); }; game.move = function (x, y, obj) { if (isDragging) { // Update turret angle var angle = calculateAimAngle(x, y); if (turret) { // Add null check to ensure turret exists turret.updateRotation(angle); } // Calculate power based on drag distance var dx = x - dragStartX; var dy = y - dragStartY; var dragDistance = Math.sqrt(dx * dx + dy * dy); if (turret) { var power = Math.min(turret.maxPower, dragDistance / 50); turret.setPower(power); // Update power meter powerMeter.setPower(turret.power, turret.maxPower); } // Update aim line updateAimLine(); } }; game.up = function (x, y, obj) { if (isDragging) { isDragging = false; fireBullet(); } }; // Game update loop game.update = function () { // Update all bullets for (var i = 0; i < bullets.length; i++) { bullets[i].update(); } // Check for collisions checkCollisions(); // Check for game over checkGameOver(); };
===================================================================
--- original.js
+++ change.js
@@ -955,10 +955,17 @@
var bulletCount = activePowerUps.multishot ? 3 : 1;
for (var i = 0; i < bulletCount; i++) {
// Create new bullet
var bullet = new Bullet();
- bullet.x = turret.x;
- bullet.y = turret.y;
+ // Add null check to ensure turret exists before accessing its properties
+ if (turret) {
+ bullet.x = turret.x;
+ bullet.y = turret.y;
+ } else {
+ // Set default position if turret doesn't exist
+ bullet.x = 100;
+ bullet.y = 2732 - 100;
+ }
// Get velocity from turret angle and power
var velocity = turret.getShootVelocity();
// If multishot, spread the bullets
if (activePowerUps.multishot && bulletCount > 1) {
A ball with fire launching to the left with white painted text that says “BULLET BOUNCE!” At an angle on the ball. Single Game Texture. In-Game asset. 2d. No background. High contrast. No shadows
Metal bar. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Yellow bar. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows