User prompt
Add a loadin screen
User prompt
Ler the bird fly in the direction determined by the trajectory
User prompt
When a level completed level complete music one time playing
User prompt
When in the level level sound is started
User prompt
When next level started level complete music is stop
User prompt
When on the menu, menu music is start
User prompt
When started the game menü music is started, when tapping the level selector music is not start or not stop and when tapping the play button menü music is stop
User prompt
Level complete music is one time
User prompt
When a level completed start a level complete music
User prompt
When started this game menü music is start not when Level selector
User prompt
In menu, menu music is start, in levels menu music is stop
User prompt
Add angry birds menu music on menu
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var guiPos = LK.gui.topRight.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 889
User prompt
Add back to menu bittin on levels
User prompt
Add angry birds logo on menü
User prompt
Add a menu background
User prompt
Add a level selecter
User prompt
Add a menü
User prompt
Add a angry birds menü music
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = 0; self.velocityY = 0; self.launched = false; self.gravity = 0.3; self.bounce = 0.3; self.update = function () { if (self.launched) { self.velocityY += self.gravity; self.x += self.velocityX; self.y += self.velocityY; // Ground collision if (self.y > 2600) { self.y = 2600; self.velocityY *= -self.bounce; self.velocityX *= 0.8; if (Math.abs(self.velocityY) < 2) { self.velocityY = 0; } } // Side boundaries if (self.x < 0 || self.x > 2048) { self.velocityX *= -self.bounce; } } }; self.launch = function (velX, velY) { self.launched = true; self.velocityX = velX; self.velocityY = velY; LK.getSound('launch').play(); }; return self; }); var Block = Container.expand(function (type) { var self = Container.call(this); var assetName = type + 'Block'; var blockGraphics = self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); self.type = type; self.health = type === 'wood' ? 50 : type === 'stone' ? 100 : 30; // ice is weakest self.destroyed = false; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0 && !self.destroyed) { self.destroyed = true; LK.effects.flashObject(self, 0xff0000, 200); LK.getSound('hit').play(); LK.setScore(LK.getScore() + 10); scoreText.setText(LK.getScore()); } }; return self; }); var BlueBird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('blueBird', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = 0; self.velocityY = 0; self.launched = false; self.gravity = 0.3; self.bounce = 0.3; self.update = function () { if (self.launched) { self.velocityY += self.gravity; self.x += self.velocityX; self.y += self.velocityY; // Ground collision if (self.y > 2600) { self.y = 2600; self.velocityY *= -self.bounce; self.velocityX *= 0.8; if (Math.abs(self.velocityY) < 2) { self.velocityY = 0; } } // Side boundaries if (self.x < 0 || self.x > 2048) { self.velocityX *= -self.bounce; } } }; self.launch = function (velX, velY) { self.launched = true; self.velocityX = velX; self.velocityY = velY; LK.getSound('launch').play(); }; self.hasSplit = false; // Track if bird has already split self.down = function (x, y, obj) { if (self.launched && !self.hasSplit) { self.hasSplit = true; // Prevent multiple splits // Create two additional blue birds - one above and one below var blueBirdAbove = game.addChild(new BlueBird()); blueBirdAbove.x = self.x; blueBirdAbove.y = self.y - 50; blueBirdAbove.launched = true; blueBirdAbove.velocityX = self.velocityX * 0.8; blueBirdAbove.velocityY = self.velocityY - 3; blueBirdAbove.hasSplit = true; // Prevent these copies from splitting birds.push(blueBirdAbove); var blueBirdBelow = game.addChild(new BlueBird()); blueBirdBelow.x = self.x; blueBirdBelow.y = self.y + 50; blueBirdBelow.launched = true; blueBirdBelow.velocityX = self.velocityX * 0.8; blueBirdBelow.velocityY = self.velocityY + 3; blueBirdBelow.hasSplit = true; // Prevent these copies from splitting birds.push(blueBirdBelow); } }; return self; }); var KingPig = Container.expand(function () { var self = Container.call(this); var kingPigGraphics = self.attachAsset('kingPig', { anchorX: 0.5, anchorY: 0.5 }); self.health = 300; self.destroyed = false; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0 && !self.destroyed) { self.destroyed = true; LK.effects.flashObject(self, 0xffff00, 500); LK.getSound('destroy').play(); LK.setScore(LK.getScore() + 500); scoreText.setText(LK.getScore()); } }; return self; }); var LevelSelector = Container.expand(function () { var self = Container.call(this); // Create level selector background with sky image var skyBg = self.attachAsset('skyBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 }); // Create level selector background overlay var selectorBg = self.attachAsset('ground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, alpha: 0.3 }); // Create title text var titleText = new Text2('SELECT LEVEL', { size: 100, fill: 0xFF4444 }); titleText.anchor.set(0.5, 0.5); titleText.x = 1024; titleText.y = 600; self.addChild(titleText); // Create level buttons in a grid var levelButtons = []; var buttonSpacing = 200; var startX = 400; var startY = 900; for (var i = 1; i <= 10; i++) { var buttonX = startX + (i - 1) % 5 * buttonSpacing; var buttonY = startY + Math.floor((i - 1) / 5) * 150; // Create button background var buttonBg = self.attachAsset('woodBlock', { anchorX: 0.5, anchorY: 0.5, x: buttonX, y: buttonY, scaleX: 1.5, scaleY: 1.5 }); // Create button text var buttonText = new Text2(i.toString(), { size: 60, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); buttonText.x = buttonX; buttonText.y = buttonY; self.addChild(buttonText); levelButtons.push({ level: i, x: buttonX, y: buttonY, width: 180, height: 54 }); } // Create back button var backButtonBg = self.attachAsset('stoneBlock', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 2200, scaleX: 2, scaleY: 1.5 }); var backButtonText = new Text2('BACK', { size: 60, fill: 0xFFFFFF }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 1024; backButtonText.y = 2200; self.addChild(backButtonText); // Handle button clicks self.down = function (x, y, obj) { // Check level buttons for (var i = 0; i < levelButtons.length; i++) { var button = levelButtons[i]; if (x >= button.x - button.width / 2 && x <= button.x + button.width / 2 && y >= button.y - button.height / 2 && y <= button.y + button.height / 2) { // Start selected level level = button.level; levelText.setText('Level: ' + level); birdsRemaining = 8; birdsText.setText('Birds: ' + birdsRemaining); // Stop menu music when starting game LK.stopMusic(); self.destroy(); gameStarted = true; initializeLevel(); createNewBird(); return; } } // Check back button if (x >= 1024 - 120 && x <= 1024 + 120 && y >= 2200 - 27 && y <= 2200 + 27) { // Go back to main menu self.destroy(); menu = game.addChild(new Menu()); } }; return self; }); var Menu = Container.expand(function () { var self = Container.call(this); // Start menu music when Menu is created LK.playMusic('menuMusic'); // Create menu background with sky image var skyBg = self.attachAsset('skyBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 }); // Create menu background overlay var menuBg = self.attachAsset('ground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, alpha: 0.3 }); // Create Angry Birds logo var logoImage = self.attachAsset('angryBirdsLogo', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 600 }); // Create play button background var playButtonBg = self.attachAsset('woodBlock', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1100, scaleX: 3, scaleY: 2 }); // Create play button text var playButtonText = new Text2('PLAY', { size: 80, fill: 0xFFFFFF }); playButtonText.anchor.set(0.5, 0.5); playButtonText.x = 1024; playButtonText.y = 1100; self.addChild(playButtonText); // Create level select button background var levelSelectButtonBg = self.attachAsset('stoneBlock', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1300, scaleX: 3, scaleY: 2 }); // Create level select button text var levelSelectButtonText = new Text2('SELECT LEVEL', { size: 60, fill: 0xFFFFFF }); levelSelectButtonText.anchor.set(0.5, 0.5); levelSelectButtonText.x = 1024; levelSelectButtonText.y = 1300; self.addChild(levelSelectButtonText); // Handle button clicks self.down = function (x, y, obj) { // Check play button (start level 1) if (x >= 1024 - 180 && x <= 1024 + 180 && y >= 1100 - 36 && y <= 1100 + 36) { // Start the game at level 1 level = 1; levelText.setText('Level: ' + level); // Stop menu music when starting game LK.stopMusic(); self.destroy(); gameStarted = true; initializeLevel(); createNewBird(); return; } // Check level select button if (x >= 1024 - 180 && x <= 1024 + 180 && y >= 1300 - 36 && y <= 1300 + 36) { // Show level selector self.destroy(); var levelSelector = game.addChild(new LevelSelector()); } }; return self; }); var Pig = Container.expand(function () { var self = Container.call(this); var pigGraphics = self.attachAsset('pig', { anchorX: 0.5, anchorY: 0.5 }); self.health = 100; self.destroyed = false; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0 && !self.destroyed) { self.destroyed = true; LK.effects.flashObject(self, 0xffff00, 300); LK.getSound('destroy').play(); LK.setScore(LK.getScore() + 100); scoreText.setText(LK.getScore()); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ // Game variables var birds = []; var pigs = []; var blocks = []; var currentBird = null; var slingshot = null; var isDragging = false; var trajectoryDots = []; var slingshotX = 200; var slingshotY = 2400; var birdsRemaining = 8; var level = 1; var gameStarted = false; var menu = null; // UI Elements var scoreText = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); var birdsText = new Text2('Birds: 8', { size: 50, fill: 0xFFFFFF }); birdsText.anchor.set(0, 0); birdsText.x = 100; birdsText.y = 100; LK.gui.topLeft.addChild(birdsText); var levelText = new Text2('Level: 1', { size: 50, fill: 0xFFFFFF }); levelText.anchor.set(1, 0); levelText.x = -100; levelText.y = 100; LK.gui.topRight.addChild(levelText); // Create ground var ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 1, x: 0, y: 2732 })); // Create clouds for background atmosphere var cloud1 = game.addChild(LK.getAsset('cloud', { anchorX: 0.5, anchorY: 0.5, x: 300, y: 400, alpha: 0.8 })); var cloud2 = game.addChild(LK.getAsset('cloud', { anchorX: 0.5, anchorY: 0.5, x: 800, y: 300, alpha: 0.7 })); var cloud3 = game.addChild(LK.getAsset('cloud', { anchorX: 0.5, anchorY: 0.5, x: 1400, y: 450, alpha: 0.6 })); var cloud4 = game.addChild(LK.getAsset('cloud', { anchorX: 0.5, anchorY: 0.5, x: 1800, y: 350, alpha: 0.8 })); // Create slingshot slingshot = game.addChild(LK.getAsset('slingshot', { anchorX: 0.5, anchorY: 1, x: slingshotX, y: slingshotY })); // Create level structures function createLevel1() { // Create pigs var pig1 = game.addChild(new Pig()); pig1.x = 1400; pig1.y = 2300; pigs.push(pig1); var pig2 = game.addChild(new Pig()); pig2.x = 1600; pig2.y = 2200; pigs.push(pig2); // Additional pigs var pig3 = game.addChild(new Pig()); pig3.x = 1250; pig3.y = 2300; pigs.push(pig3); var pig4 = game.addChild(new Pig()); pig4.x = 1400; pig4.y = 2100; pigs.push(pig4); var pig5 = game.addChild(new Pig()); pig5.x = 1750; pig5.y = 2200; pigs.push(pig5); // Create structure var block1 = game.addChild(new Block('wood')); block1.x = 1300; block1.y = 2350; blocks.push(block1); var block2 = game.addChild(new Block('wood')); block2.x = 1500; block2.y = 2350; blocks.push(block2); var block3 = game.addChild(new Block('stone')); block3.x = 1400; block3.y = 2250; blocks.push(block3); var block4 = game.addChild(new Block('ice')); block4.x = 1600; block4.y = 2300; blocks.push(block4); // Additional foundation blocks var block5 = game.addChild(new Block('wood')); block5.x = 1200; block5.y = 2350; blocks.push(block5); var block6 = game.addChild(new Block('wood')); block6.x = 1700; block6.y = 2350; blocks.push(block6); // Upper level blocks var block7 = game.addChild(new Block('ice')); block7.x = 1350; block7.y = 2200; blocks.push(block7); var block8 = game.addChild(new Block('ice')); block8.x = 1450; block8.y = 2200; blocks.push(block8); // Top blocks var block9 = game.addChild(new Block('stone')); block9.x = 1400; block9.y = 2150; blocks.push(block9); // Side tower blocks var block10 = game.addChild(new Block('wood')); block10.x = 1750; block10.y = 2300; blocks.push(block10); var block11 = game.addChild(new Block('ice')); block11.x = 1750; block11.y = 2250; blocks.push(block11); } // Initialize first bird function createNewBird() { if (birdsRemaining > 0) { if (level === 6 || level === 7 || level === 8 || level === 9) { currentBird = game.addChild(new BlueBird()); } else { currentBird = game.addChild(new Bird()); } currentBird.x = slingshotX; currentBird.y = slingshotY - 100; birds.push(currentBird); } } // Trajectory calculation function calculateTrajectory(startX, startY, velX, velY) { var dots = []; var x = startX; var y = startY; var vx = velX; var vy = velY; var gravity = 0.3; for (var i = 0; i < 50; i += 3) { dots.push({ x: x, y: y }); vx *= 0.99; vy += gravity; x += vx * 3; y += vy * 3; if (y > 2600 || x > 2048) break; } return dots; } // Clear trajectory dots function clearTrajectory() { for (var i = 0; i < trajectoryDots.length; i++) { trajectoryDots[i].destroy(); } trajectoryDots = []; } // Show trajectory dots function showTrajectory(dots) { clearTrajectory(); for (var i = 0; i < dots.length; i++) { var dot = game.addChild(LK.getAsset('trajectory', { anchorX: 0.5, anchorY: 0.5, x: dots[i].x, y: dots[i].y, alpha: 0.5 })); trajectoryDots.push(dot); } } // Check collisions function checkCollisions() { for (var i = 0; i < birds.length; i++) { var bird = birds[i]; if (!bird.launched) continue; // Check bird vs pigs for (var j = 0; j < pigs.length; j++) { var pig = pigs[j]; if (!pig.destroyed && bird.intersects(pig)) { var damage = Math.abs(bird.velocityX) + Math.abs(bird.velocityY); pig.takeDamage(damage * 2); } } // Check bird vs blocks for (var k = 0; k < blocks.length; k++) { var block = blocks[k]; if (!block.destroyed && bird.intersects(block)) { var damage = Math.abs(bird.velocityX) + Math.abs(bird.velocityY); block.takeDamage(damage); bird.velocityX *= 0.5; bird.velocityY *= 0.5; } } } } // Check win condition function checkWinCondition() { var allPigsDestroyed = true; for (var i = 0; i < pigs.length; i++) { if (!pigs[i].destroyed) { allPigsDestroyed = false; break; } } if (allPigsDestroyed) { if (level === 1) { // Progress to level 2 // Play level complete music LK.stopMusic(); LK.playMusic('levelCompleteMusic', { loop: false }); // Ensure music stops after 3 seconds LK.setTimeout(function () { LK.stopMusic(); }, 3000); LK.setTimeout(function () { level = 2; levelText.setText('Level: ' + level); birdsRemaining = 8; birdsText.setText('Birds: ' + birdsRemaining); // Clear existing objects for (var i = 0; i < blocks.length; i++) { blocks[i].destroy(); } blocks = []; for (var j = 0; j < pigs.length; j++) { pigs[j].destroy(); } pigs = []; for (var k = 0; k < birds.length; k++) { birds[k].destroy(); } birds = []; currentBird = null; // Initialize level 2 initializeLevel(); createNewBird(); }, 1000); } else if (level === 2) { // Progress to level 3 // Play level complete music LK.stopMusic(); LK.playMusic('levelCompleteMusic', { loop: false }); // Ensure music stops after 3 seconds LK.setTimeout(function () { LK.stopMusic(); }, 3000); LK.setTimeout(function () { level = 3; levelText.setText('Level: ' + level); birdsRemaining = 8; birdsText.setText('Birds: ' + birdsRemaining); // Clear existing objects for (var i = 0; i < blocks.length; i++) { blocks[i].destroy(); } blocks = []; for (var j = 0; j < pigs.length; j++) { pigs[j].destroy(); } pigs = []; for (var k = 0; k < birds.length; k++) { birds[k].destroy(); } birds = []; currentBird = null; // Initialize level 3 initializeLevel(); createNewBird(); }, 1000); } else if (level === 3) { // Progress to level 4 // Play level complete music LK.stopMusic(); LK.playMusic('levelCompleteMusic', { loop: false }); // Ensure music stops after 3 seconds LK.setTimeout(function () { LK.stopMusic(); }, 3000); LK.setTimeout(function () { level = 4; levelText.setText('Level: ' + level); birdsRemaining = 8; birdsText.setText('Birds: ' + birdsRemaining); // Clear existing objects for (var i = 0; i < blocks.length; i++) { blocks[i].destroy(); } blocks = []; for (var j = 0; j < pigs.length; j++) { pigs[j].destroy(); } pigs = []; for (var k = 0; k < birds.length; k++) { birds[k].destroy(); } birds = []; currentBird = null; // Initialize level 4 initializeLevel(); createNewBird(); }, 1000); } else if (level === 4) { // Progress to level 5 // Play level complete music LK.stopMusic(); LK.playMusic('levelCompleteMusic', { loop: false }); // Ensure music stops after 3 seconds LK.setTimeout(function () { LK.stopMusic(); }, 3000); LK.setTimeout(function () { level = 5; levelText.setText('Level: ' + level); birdsRemaining = 8; birdsText.setText('Birds: ' + birdsRemaining); // Clear existing objects for (var i = 0; i < blocks.length; i++) { blocks[i].destroy(); } blocks = []; for (var j = 0; j < pigs.length; j++) { pigs[j].destroy(); } pigs = []; for (var k = 0; k < birds.length; k++) { birds[k].destroy(); } birds = []; currentBird = null; // Initialize level 5 initializeLevel(); createNewBird(); }, 1000); } else if (level === 5) { // Progress to level 6 // Play level complete music LK.stopMusic(); LK.playMusic('levelCompleteMusic', { loop: false }); // Ensure music stops after 3 seconds LK.setTimeout(function () { LK.stopMusic(); }, 3000); LK.setTimeout(function () { level = 6; levelText.setText('Level: ' + level); birdsRemaining = 8; birdsText.setText('Birds: ' + birdsRemaining); // Clear existing objects for (var i = 0; i < blocks.length; i++) { blocks[i].destroy(); } blocks = []; for (var j = 0; j < pigs.length; j++) { pigs[j].destroy(); } pigs = []; for (var k = 0; k < birds.length; k++) { birds[k].destroy(); } birds = []; currentBird = null; // Initialize level 6 initializeLevel(); createNewBird(); }, 1000); } else if (level === 6) { // Progress to level 7 // Play level complete music LK.stopMusic(); LK.playMusic('levelCompleteMusic', { loop: false }); // Ensure music stops after 3 seconds LK.setTimeout(function () { LK.stopMusic(); }, 3000); LK.setTimeout(function () { level = 7; levelText.setText('Level: ' + level); birdsRemaining = 8; birdsText.setText('Birds: ' + birdsRemaining); // Clear existing objects for (var i = 0; i < blocks.length; i++) { blocks[i].destroy(); } blocks = []; for (var j = 0; j < pigs.length; j++) { pigs[j].destroy(); } pigs = []; for (var k = 0; k < birds.length; k++) { birds[k].destroy(); } birds = []; currentBird = null; // Initialize level 7 initializeLevel(); createNewBird(); }, 1000); } else if (level === 7) { // Progress to level 8 // Play level complete music LK.stopMusic(); LK.playMusic('levelCompleteMusic', { loop: false }); // Ensure music stops after 3 seconds LK.setTimeout(function () { LK.stopMusic(); }, 3000); LK.setTimeout(function () { level = 8; levelText.setText('Level: ' + level); birdsRemaining = 8; birdsText.setText('Birds: ' + birdsRemaining); // Clear existing objects for (var i = 0; i < blocks.length; i++) { blocks[i].destroy(); } blocks = []; for (var j = 0; j < pigs.length; j++) { pigs[j].destroy(); } pigs = []; for (var k = 0; k < birds.length; k++) { birds[k].destroy(); } birds = []; currentBird = null; // Initialize level 8 initializeLevel(); createNewBird(); }, 1000); } else if (level === 8) { // Progress to level 9 // Play level complete music LK.stopMusic(); LK.playMusic('levelCompleteMusic', { loop: false }); // Ensure music stops after 3 seconds LK.setTimeout(function () { LK.stopMusic(); }, 3000); LK.setTimeout(function () { level = 9; levelText.setText('Level: ' + level); birdsRemaining = 8; birdsText.setText('Birds: ' + birdsRemaining); // Clear existing objects for (var i = 0; i < blocks.length; i++) { blocks[i].destroy(); } blocks = []; for (var j = 0; j < pigs.length; j++) { pigs[j].destroy(); } pigs = []; for (var k = 0; k < birds.length; k++) { birds[k].destroy(); } birds = []; currentBird = null; // Initialize level 9 initializeLevel(); createNewBird(); }, 1000); } else if (level === 9) { // Progress to level 10 // Play level complete music LK.stopMusic(); LK.playMusic('levelCompleteMusic', { loop: false }); // Ensure music stops after 3 seconds LK.setTimeout(function () { LK.stopMusic(); }, 3000); LK.setTimeout(function () { level = 10; levelText.setText('Level: ' + level); birdsRemaining = 8; birdsText.setText('Birds: ' + birdsRemaining); // Clear existing objects for (var i = 0; i < blocks.length; i++) { blocks[i].destroy(); } blocks = []; for (var j = 0; j < pigs.length; j++) { pigs[j].destroy(); } pigs = []; for (var k = 0; k < birds.length; k++) { birds[k].destroy(); } birds = []; currentBird = null; // Initialize level 10 initializeLevel(); createNewBird(); }, 1000); } else if (level === 10) { // Game completed // Play level complete music LK.stopMusic(); LK.playMusic('levelCompleteMusic', { loop: false }); // Ensure music stops after 3 seconds LK.setTimeout(function () { LK.stopMusic(); }, 3000); LK.setTimeout(function () { LK.showYouWin(); }, 1000); } } else if (birdsRemaining <= 0 && (!currentBird || currentBird.launched && Math.abs(currentBird.velocityX) < 1 && Math.abs(currentBird.velocityY) < 1)) { LK.setTimeout(function () { LK.showGameOver(); }, 1000); } } // Game event handlers game.down = function (x, y, obj) { if (!gameStarted) return; if (currentBird && !currentBird.launched) { isDragging = true; } else { // Check if there's a launched blue bird that can split for (var i = 0; i < birds.length; i++) { var bird = birds[i]; if (bird.launched && bird.attachAsset && bird.hasSplit !== undefined && !bird.hasSplit) { // This is a BlueBird that can split bird.hasSplit = true; // Create two additional blue birds - one above and one below var blueBirdAbove = game.addChild(new BlueBird()); blueBirdAbove.x = bird.x; blueBirdAbove.y = bird.y - 50; blueBirdAbove.launched = true; blueBirdAbove.velocityX = bird.velocityX * 0.8; blueBirdAbove.velocityY = bird.velocityY - 3; blueBirdAbove.hasSplit = true; birds.push(blueBirdAbove); var blueBirdBelow = game.addChild(new BlueBird()); blueBirdBelow.x = bird.x; blueBirdBelow.y = bird.y + 50; blueBirdBelow.launched = true; blueBirdBelow.velocityX = bird.velocityX * 0.8; blueBirdBelow.velocityY = bird.velocityY + 3; blueBirdBelow.hasSplit = true; birds.push(blueBirdBelow); break; // Only split one blue bird per touch } } } }; game.move = function (x, y, obj) { if (!gameStarted) return; if (isDragging && currentBird && !currentBird.launched) { var maxDistance = 150; var deltaX = slingshotX - x; var deltaY = slingshotY - 100 - y; var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); if (distance > maxDistance) { deltaX = deltaX / distance * maxDistance; deltaY = deltaY / distance * maxDistance; } currentBird.x = slingshotX - deltaX; currentBird.y = slingshotY - 100 - deltaY; // Show trajectory var velX = deltaX * 0.2; var velY = deltaY * 0.2; var trajectoryPoints = calculateTrajectory(currentBird.x, currentBird.y, velX, velY); showTrajectory(trajectoryPoints); } }; game.up = function (x, y, obj) { if (!gameStarted) return; if (isDragging && currentBird && !currentBird.launched) { isDragging = false; clearTrajectory(); var deltaX = slingshotX - currentBird.x; var deltaY = slingshotY - 100 - currentBird.y; if (Math.abs(deltaX) > 5 || Math.abs(deltaY) > 5) { currentBird.launch(deltaX * 0.2, deltaY * 0.2); birdsRemaining--; birdsText.setText('Birds: ' + birdsRemaining); LK.setTimeout(function () { createNewBird(); }, 2000); } } }; // Main game update game.update = function () { if (!gameStarted) return; checkCollisions(); checkWinCondition(); // Remove destroyed objects for (var i = blocks.length - 1; i >= 0; i--) { if (blocks[i].destroyed) { blocks[i].destroy(); blocks.splice(i, 1); } } for (var j = pigs.length - 1; j >= 0; j--) { if (pigs[j].destroyed) { pigs[j].alpha = Math.max(0, pigs[j].alpha - 0.02); if (pigs[j].alpha <= 0) { pigs[j].destroy(); pigs.splice(j, 1); } } } }; // Create level 2 structures function createLevel2() { // Create more pigs for level 2 var pig1 = game.addChild(new Pig()); pig1.x = 1300; pig1.y = 2300; pigs.push(pig1); var pig2 = game.addChild(new Pig()); pig2.x = 1500; pig2.y = 2300; pigs.push(pig2); var pig3 = game.addChild(new Pig()); pig3.x = 1700; pig3.y = 2300; pigs.push(pig3); var pig4 = game.addChild(new Pig()); pig4.x = 1400; pig4.y = 2150; pigs.push(pig4); var pig5 = game.addChild(new Pig()); pig5.x = 1600; pig5.y = 2150; pigs.push(pig5); var pig6 = game.addChild(new Pig()); pig6.x = 1500; pig6.y = 2000; pigs.push(pig6); // Create more complex structure for level 2 // Base foundation var block1 = game.addChild(new Block('stone')); block1.x = 1250; block1.y = 2350; blocks.push(block1); var block2 = game.addChild(new Block('stone')); block2.x = 1350; block2.y = 2350; blocks.push(block2); var block3 = game.addChild(new Block('stone')); block3.x = 1450; block3.y = 2350; blocks.push(block3); var block4 = game.addChild(new Block('stone')); block4.x = 1550; block4.y = 2350; blocks.push(block4); var block5 = game.addChild(new Block('stone')); block5.x = 1650; block5.y = 2350; blocks.push(block5); var block6 = game.addChild(new Block('stone')); block6.x = 1750; block6.y = 2350; blocks.push(block6); // Second level var block7 = game.addChild(new Block('wood')); block7.x = 1300; block7.y = 2250; blocks.push(block7); var block8 = game.addChild(new Block('wood')); block8.x = 1400; block8.y = 2250; blocks.push(block8); var block9 = game.addChild(new Block('wood')); block9.x = 1500; block9.y = 2250; blocks.push(block9); var block10 = game.addChild(new Block('wood')); block10.x = 1600; block10.y = 2250; blocks.push(block10); var block11 = game.addChild(new Block('wood')); block11.x = 1700; block11.y = 2250; blocks.push(block11); // Third level var block12 = game.addChild(new Block('ice')); block12.x = 1350; block12.y = 2150; blocks.push(block12); var block13 = game.addChild(new Block('ice')); block13.x = 1450; block13.y = 2150; blocks.push(block13); var block14 = game.addChild(new Block('ice')); block14.x = 1550; block14.y = 2150; blocks.push(block14); var block15 = game.addChild(new Block('ice')); block15.x = 1650; block15.y = 2150; blocks.push(block15); // Top level var block16 = game.addChild(new Block('wood')); block16.x = 1400; block16.y = 2050; blocks.push(block16); var block17 = game.addChild(new Block('wood')); block17.x = 1500; block17.y = 2050; blocks.push(block17); var block18 = game.addChild(new Block('wood')); block18.x = 1600; block18.y = 2050; blocks.push(block18); } // Create level 3 structures function createLevel3() { // Create simple structure with fewer pigs for easier level var pig1 = game.addChild(new Pig()); pig1.x = 1400; pig1.y = 2300; pigs.push(pig1); var pig2 = game.addChild(new Pig()); pig2.x = 1600; pig2.y = 2300; pigs.push(pig2); var pig3 = game.addChild(new Pig()); pig3.x = 1500; pig3.y = 2150; pigs.push(pig3); // Simple structure for level 3 // Base blocks var block1 = game.addChild(new Block('wood')); block1.x = 1350; block1.y = 2350; blocks.push(block1); var block2 = game.addChild(new Block('wood')); block2.x = 1450; block2.y = 2350; blocks.push(block2); var block3 = game.addChild(new Block('wood')); block3.x = 1550; block3.y = 2350; blocks.push(block3); var block4 = game.addChild(new Block('wood')); block4.x = 1650; block4.y = 2350; blocks.push(block4); // Upper blocks var block5 = game.addChild(new Block('ice')); block5.x = 1400; block5.y = 2250; blocks.push(block5); var block6 = game.addChild(new Block('ice')); block6.x = 1500; block6.y = 2250; blocks.push(block6); var block7 = game.addChild(new Block('ice')); block7.x = 1600; block7.y = 2250; blocks.push(block7); // Top block var block8 = game.addChild(new Block('stone')); block8.x = 1500; block8.y = 2200; blocks.push(block8); } // Create level 4 structures function createLevel4() { // Create minimal structure with fewer blocks and pigs for easy final level var pig1 = game.addChild(new Pig()); pig1.x = 1500; pig1.y = 2300; pigs.push(pig1); var pig2 = game.addChild(new Pig()); pig2.x = 1500; pig2.y = 2200; pigs.push(pig2); // Minimal structure for level 4 - fewer blocks // Base blocks var block1 = game.addChild(new Block('ice')); block1.x = 1450; block1.y = 2350; blocks.push(block1); var block2 = game.addChild(new Block('ice')); block2.x = 1550; block2.y = 2350; blocks.push(block2); // Single upper block var block3 = game.addChild(new Block('wood')); block3.x = 1500; block3.y = 2250; blocks.push(block3); } // Create level 5 structures function createLevel5() { // Create easy structure with minimal blocks and pigs var pig1 = game.addChild(new Pig()); pig1.x = 1400; pig1.y = 2300; pigs.push(pig1); var pig2 = game.addChild(new Pig()); pig2.x = 1600; pig2.y = 2300; pigs.push(pig2); // Simple structure for level 5 - few blocks var block1 = game.addChild(new Block('wood')); block1.x = 1350; block1.y = 2350; blocks.push(block1); var block2 = game.addChild(new Block('wood')); block2.x = 1650; block2.y = 2350; blocks.push(block2); var block3 = game.addChild(new Block('ice')); block3.x = 1500; block3.y = 2250; blocks.push(block3); } // Create level 6 structures function createLevel6() { // Create easy structure with minimal blocks and pigs var pig1 = game.addChild(new Pig()); pig1.x = 1500; pig1.y = 2300; pigs.push(pig1); var pig2 = game.addChild(new Pig()); pig2.x = 1500; pig2.y = 2150; pigs.push(pig2); // Very simple structure for level 6 - minimal blocks var block1 = game.addChild(new Block('ice')); block1.x = 1450; block1.y = 2350; blocks.push(block1); var block2 = game.addChild(new Block('ice')); block2.x = 1550; block2.y = 2350; blocks.push(block2); var block3 = game.addChild(new Block('wood')); block3.x = 1500; block3.y = 2200; blocks.push(block3); } // Create level 7 structures function createLevel7() { // Create final easy level with minimal blocks and pigs var pig1 = game.addChild(new Pig()); pig1.x = 1500; pig1.y = 2300; pigs.push(pig1); // Minimal structure for final level var block1 = game.addChild(new Block('ice')); block1.x = 1500; block1.y = 2350; blocks.push(block1); } // Create level 8 structures function createLevel8() { // Create easy level with minimal blocks and pigs var pig1 = game.addChild(new Pig()); pig1.x = 1400; pig1.y = 2300; pigs.push(pig1); var pig2 = game.addChild(new Pig()); pig2.x = 1600; pig2.y = 2300; pigs.push(pig2); // Simple structure for level 8 - few blocks var block1 = game.addChild(new Block('wood')); block1.x = 1350; block1.y = 2350; blocks.push(block1); var block2 = game.addChild(new Block('wood')); block2.x = 1650; block2.y = 2350; blocks.push(block2); } // Create level 9 structures function createLevel9() { // Create easy level with minimal blocks and pigs var pig1 = game.addChild(new Pig()); pig1.x = 1500; pig1.y = 2300; pigs.push(pig1); var pig2 = game.addChild(new Pig()); pig2.x = 1500; pig2.y = 2200; pigs.push(pig2); // Simple structure for level 9 - few blocks var block1 = game.addChild(new Block('ice')); block1.x = 1450; block1.y = 2350; blocks.push(block1); var block2 = game.addChild(new Block('ice')); block2.x = 1550; block2.y = 2350; blocks.push(block2); var block3 = game.addChild(new Block('wood')); block3.x = 1500; block3.y = 2250; blocks.push(block3); } // Create level 10 structures function createLevel10() { // Create final level with no blocks and one King pig var kingPig1 = game.addChild(new KingPig()); kingPig1.x = 1500; kingPig1.y = 2300; pigs.push(kingPig1); // No blocks in level 10 - just the King pig standing on the ground } // Initialize level based on current level function initializeLevel() { if (level === 1) { createLevel1(); } else if (level === 2) { createLevel2(); } else if (level === 3) { createLevel3(); } else if (level === 4) { createLevel4(); } else if (level === 5) { createLevel5(); } else if (level === 6) { createLevel6(); } else if (level === 7) { createLevel7(); } else if (level === 8) { createLevel8(); } else if (level === 9) { createLevel9(); } else if (level === 10) { createLevel10(); } } // Initialize menu instead of game at start menu = game.addChild(new Menu());
===================================================================
--- original.js
+++ change.js
@@ -238,10 +238,8 @@
birdsRemaining = 8;
birdsText.setText('Birds: ' + birdsRemaining);
// Stop menu music when starting game
LK.stopMusic();
- // Start level music
- LK.playMusic('levelMusic');
self.destroy();
gameStarted = true;
initializeLevel();
createNewBird();
@@ -327,10 +325,8 @@
level = 1;
levelText.setText('Level: ' + level);
// Stop menu music when starting game
LK.stopMusic();
- // Start level music
- LK.playMusic('levelMusic');
self.destroy();
gameStarted = true;
initializeLevel();
createNewBird();
@@ -626,9 +622,13 @@
LK.stopMusic();
LK.playMusic('levelCompleteMusic', {
loop: false
});
+ // Ensure music stops after 3 seconds
LK.setTimeout(function () {
+ LK.stopMusic();
+ }, 3000);
+ LK.setTimeout(function () {
level = 2;
levelText.setText('Level: ' + level);
birdsRemaining = 8;
birdsText.setText('Birds: ' + birdsRemaining);
@@ -647,10 +647,8 @@
birds = [];
currentBird = null;
// Initialize level 2
initializeLevel();
- // Start level music
- LK.playMusic('levelMusic');
createNewBird();
}, 1000);
} else if (level === 2) {
// Progress to level 3
@@ -658,9 +656,13 @@
LK.stopMusic();
LK.playMusic('levelCompleteMusic', {
loop: false
});
+ // Ensure music stops after 3 seconds
LK.setTimeout(function () {
+ LK.stopMusic();
+ }, 3000);
+ LK.setTimeout(function () {
level = 3;
levelText.setText('Level: ' + level);
birdsRemaining = 8;
birdsText.setText('Birds: ' + birdsRemaining);
@@ -679,10 +681,8 @@
birds = [];
currentBird = null;
// Initialize level 3
initializeLevel();
- // Start level music
- LK.playMusic('levelMusic');
createNewBird();
}, 1000);
} else if (level === 3) {
// Progress to level 4
@@ -690,9 +690,13 @@
LK.stopMusic();
LK.playMusic('levelCompleteMusic', {
loop: false
});
+ // Ensure music stops after 3 seconds
LK.setTimeout(function () {
+ LK.stopMusic();
+ }, 3000);
+ LK.setTimeout(function () {
level = 4;
levelText.setText('Level: ' + level);
birdsRemaining = 8;
birdsText.setText('Birds: ' + birdsRemaining);
@@ -711,10 +715,8 @@
birds = [];
currentBird = null;
// Initialize level 4
initializeLevel();
- // Start level music
- LK.playMusic('levelMusic');
createNewBird();
}, 1000);
} else if (level === 4) {
// Progress to level 5
@@ -722,9 +724,13 @@
LK.stopMusic();
LK.playMusic('levelCompleteMusic', {
loop: false
});
+ // Ensure music stops after 3 seconds
LK.setTimeout(function () {
+ LK.stopMusic();
+ }, 3000);
+ LK.setTimeout(function () {
level = 5;
levelText.setText('Level: ' + level);
birdsRemaining = 8;
birdsText.setText('Birds: ' + birdsRemaining);
@@ -743,10 +749,8 @@
birds = [];
currentBird = null;
// Initialize level 5
initializeLevel();
- // Start level music
- LK.playMusic('levelMusic');
createNewBird();
}, 1000);
} else if (level === 5) {
// Progress to level 6
@@ -754,9 +758,13 @@
LK.stopMusic();
LK.playMusic('levelCompleteMusic', {
loop: false
});
+ // Ensure music stops after 3 seconds
LK.setTimeout(function () {
+ LK.stopMusic();
+ }, 3000);
+ LK.setTimeout(function () {
level = 6;
levelText.setText('Level: ' + level);
birdsRemaining = 8;
birdsText.setText('Birds: ' + birdsRemaining);
@@ -775,10 +783,8 @@
birds = [];
currentBird = null;
// Initialize level 6
initializeLevel();
- // Start level music
- LK.playMusic('levelMusic');
createNewBird();
}, 1000);
} else if (level === 6) {
// Progress to level 7
@@ -786,9 +792,13 @@
LK.stopMusic();
LK.playMusic('levelCompleteMusic', {
loop: false
});
+ // Ensure music stops after 3 seconds
LK.setTimeout(function () {
+ LK.stopMusic();
+ }, 3000);
+ LK.setTimeout(function () {
level = 7;
levelText.setText('Level: ' + level);
birdsRemaining = 8;
birdsText.setText('Birds: ' + birdsRemaining);
@@ -807,10 +817,8 @@
birds = [];
currentBird = null;
// Initialize level 7
initializeLevel();
- // Start level music
- LK.playMusic('levelMusic');
createNewBird();
}, 1000);
} else if (level === 7) {
// Progress to level 8
@@ -818,9 +826,13 @@
LK.stopMusic();
LK.playMusic('levelCompleteMusic', {
loop: false
});
+ // Ensure music stops after 3 seconds
LK.setTimeout(function () {
+ LK.stopMusic();
+ }, 3000);
+ LK.setTimeout(function () {
level = 8;
levelText.setText('Level: ' + level);
birdsRemaining = 8;
birdsText.setText('Birds: ' + birdsRemaining);
@@ -839,10 +851,8 @@
birds = [];
currentBird = null;
// Initialize level 8
initializeLevel();
- // Start level music
- LK.playMusic('levelMusic');
createNewBird();
}, 1000);
} else if (level === 8) {
// Progress to level 9
@@ -850,9 +860,13 @@
LK.stopMusic();
LK.playMusic('levelCompleteMusic', {
loop: false
});
+ // Ensure music stops after 3 seconds
LK.setTimeout(function () {
+ LK.stopMusic();
+ }, 3000);
+ LK.setTimeout(function () {
level = 9;
levelText.setText('Level: ' + level);
birdsRemaining = 8;
birdsText.setText('Birds: ' + birdsRemaining);
@@ -871,10 +885,8 @@
birds = [];
currentBird = null;
// Initialize level 9
initializeLevel();
- // Start level music
- LK.playMusic('levelMusic');
createNewBird();
}, 1000);
} else if (level === 9) {
// Progress to level 10
@@ -882,9 +894,13 @@
LK.stopMusic();
LK.playMusic('levelCompleteMusic', {
loop: false
});
+ // Ensure music stops after 3 seconds
LK.setTimeout(function () {
+ LK.stopMusic();
+ }, 3000);
+ LK.setTimeout(function () {
level = 10;
levelText.setText('Level: ' + level);
birdsRemaining = 8;
birdsText.setText('Birds: ' + birdsRemaining);
@@ -903,10 +919,8 @@
birds = [];
currentBird = null;
// Initialize level 10
initializeLevel();
- // Start level music
- LK.playMusic('levelMusic');
createNewBird();
}, 1000);
} else if (level === 10) {
// Game completed
@@ -914,9 +928,13 @@
LK.stopMusic();
LK.playMusic('levelCompleteMusic', {
loop: false
});
+ // Ensure music stops after 3 seconds
LK.setTimeout(function () {
+ LK.stopMusic();
+ }, 3000);
+ LK.setTimeout(function () {
LK.showYouWin();
}, 1000);
}
} else if (birdsRemaining <= 0 && (!currentBird || currentBird.launched && Math.abs(currentBird.velocityX) < 1 && Math.abs(currentBird.velocityY) < 1)) {
Green pig no angry. In-Game asset. 2d. High contrast. No shadows
Angry birds red. In-Game asset. 2d. High contrast. No shadows
Blue glass block. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Wood block. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Gray stone block. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Angry birds slingshot. In-Game asset. 2d. High contrast. No shadows
Cloud. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Angry birds 2 King pig. In-Game asset. 2d. High contrast. No shadows
Angry birds blue bird. In-Game asset. 2d. High contrast. No shadows
Angry birds vertical poster. In-Game asset. 2d. High contrast. No shadows
Angry birds logo. In-Game asset. 2d. High contrast. No shadows