/**** * Classes ****/ // Assets will be automatically created and loaded during gameplay // Balloon class var Balloon = Container.expand(function () { var self = Container.call(this); var balloonGraphics = self.attachAsset('balloon', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.update = function () { if (LK.getScore() >= 20) { self.speed = 4; } self.y += self.speed; if (self.y < self.height / 2) { self.y = self.height / 2; } if (self.x < self.width / 2) { self.x = self.width / 2; } if (self.x > 2048 - self.width / 2) { self.x = 2048 - self.width / 2; } if (self.y > 2732 - self.height / 2) { self.y = 2732 - self.height / 2; self.speed = 0; LK.setScore(LK.getScore() - 1); scoreTxt.setText(LK.getScore()); self.destroy(); if (miniFriend && miniFriend.intersects(self)) { // No score increment when mini friend intersects balloon } } // Check if balloon is close to any explosion and avoid it for (var i = 0; i < explosions.length; i++) { var explosion = explosions[i]; if (Math.abs(self.x - explosion.x) < 100 && Math.abs(self.y - explosion.y) < 100) { self.x += self.x - explosion.x > 0 ? 5 : -5; self.y += self.y - explosion.y > 0 ? 5 : -5; self.y -= 10; // Push balloon upwards if close to explosion } // Push balloon away from expanding explosion if (Math.abs(self.x - explosion.x) < 200 && Math.abs(self.y - explosion.y) < 200) { self.x += self.x - explosion.x > 0 ? 2 : -2; self.y += self.y - explosion.y > 0 ? 2 : -2; } } // Removed unnecessary destruction of balloons when they go off the screen }; self.down = function (x, y, obj) { self.pop(); }; self.pop = function () { LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); LK.getSound('rubbish').play(); for (var i = balloons.length - 1; i >= 0; i--) { if (balloons[i].y > 2732 - balloons[i].height / 2) { balloons.splice(i, 1); } } for (var i = balloons.length - 1; i >= 0; i--) { if (balloons[i].y > 2732 - balloons[i].height / 2) { balloons.splice(i, 1); } } // Create explosion effect var explosion = LK.getAsset('explosion', { anchorX: 0.5, anchorY: 0.5, x: self.x, y: self.y }); // Check if balloon is close enough to the explosion if (Math.abs(self.x - explosion.x) < 100 && Math.abs(self.y - explosion.y) < 100) { self.y -= 10; // Push balloon upwards if close to explosion // Create explosion effect var explosion = LK.getAsset('explosion', { anchorX: 0.5, anchorY: 0.5, x: self.x, y: self.y }); game.addChild(explosion); explosions.push(explosion); expandExplosion(explosion); LK.setTimeout(function () { explosion.destroy(); var index = explosions.indexOf(explosion); if (index > -1) { explosions.splice(index, 1); } }, 3000); LK.effects.flashObject(explosion, 0xff0000, 500); // Flash red for 500ms // Push all nearby balloons for (var i = 0; i < balloons.length; i++) { var balloon = balloons[i]; if (Math.abs(balloon.x - explosion.x) < 200 && Math.abs(balloon.y - explosion.y) < 200) { balloon.x += balloon.x - explosion.x > 0 ? 10 : -10; balloon.y += balloon.y - explosion.y > 0 ? 10 : -10; } } } LK.getSound('rubbish').play(); self.destroy(); if (LK.getScore() < 0) { LK.showGameOver(); } }; }); var Bot11 = Container.expand(function () { var self = Container.call(this); var botGraphics = self.attachAsset('bot11', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); var Bot88 = Container.expand(function () { var self = Container.call(this); var botGraphics = self.attachAsset('bot88', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.clickCount = 0; self.bot11Spawned = false; self.update = function () { // Move horizontally across the screen self.x += self.speed; if (self.x > 2048 - self.width / 2 || self.x < self.width / 2) { self.speed = -self.speed; // Reverse direction when hitting screen edges } }; self.down = function (x, y, obj) { LK.getSound('Z1').play(); self.clickCount++; if (self.clickCount >= 15) { self.createExplosion(); self.speed = 0; // Stop moving self.clickCount = 0; self.spawnBot11(); // Trigger task 2 } }; self.createExplosion = function () { var explosion = LK.getAsset('explosion', { anchorX: 0.5, anchorY: 0.5, x: self.x, y: self.y, scaleX: 5, scaleY: 5 }); game.addChild(explosion); LK.getSound('Z2').play(); // Play sound 'Z2' when Bot88 explosion effect is created LK.setTimeout(function () { explosion.destroy(); self.destroy(); // Destroy Bot88 after explosion // Drop attention effect var attentionDrop = LK.getAsset('attentionDrop', { anchorX: 0.5, anchorY: 0.5, x: self.x, y: self.y }); game.addChild(attentionDrop); LK.setTimeout(function () { attentionDrop.destroy(); }, 2000); // Destroy attention drop effect after 2 seconds }, 1000); self.clickCount = 0; // Reset click count self.speed = 5; // Reset speed }; self.spawnBot11 = function () { if (!self.bot11Spawned) { var bot11 = new Bot11(); bot11.x = self.x; bot11.y = self.y; game.addChild(bot11); self.bot11Spawned = true; LK.setTimeout(function () { self.bot11Spawned = false; }, 10000); } }; }); var Button0 = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('button0', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { LK.setScore(LK.getScore() + 55); scoreTxt.setText(LK.getScore()); }; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('miniFriend', { anchorX: 0.5, anchorY: 0.5, color: 0xff0000 // Set color to red }); self.lifetime = 15 * 60; // 15 seconds in ticks self.update = function () { self.lifetime--; if (self.lifetime <= 0) { self.destroy(); } // Move towards the nearest balloon if (balloons.length > 0) { var nearestBalloon = balloons[0]; var minDistance = Math.sqrt(Math.pow(self.x - nearestBalloon.x, 2) + Math.pow(self.y - nearestBalloon.y, 2)); for (var i = 1; i < balloons.length; i++) { var distance = Math.sqrt(Math.pow(self.x - balloons[i].x, 2) + Math.pow(self.y - balloons[i].y, 2)); if (distance < minDistance) { nearestBalloon = balloons[i]; minDistance = distance; } } var angle = Math.atan2(nearestBalloon.y - self.y, nearestBalloon.x - self.x); self.x += Math.cos(angle) * 3; self.y += Math.sin(angle) * 3; } for (var i = balloons.length - 1; i >= 0; i--) { if (self.intersects(balloons[i])) { LK.getSound('rubbish').play(); balloons[i].pop(); LK.getSound('rubbish').play(); LK.getSound('rubbish').play(); LK.getSound('rubbish').play(); LK.setScore(LK.getScore() - 1); scoreTxt.setText(LK.getScore()); self.destroy(); // Destroy enemy after popping a balloon break; // Exit loop after popping one balloon } } }; self.down = function (x, y, obj) { for (var i = balloons.length - 1; i >= 0; i--) { if (self.intersects(balloons[i])) { balloons[i].pop(); LK.setScore(LK.getScore() - 1); scoreTxt.setText(LK.getScore()); self.destroy(); // Destroy enemy after popping a balloon break; // Exit loop after popping one balloon } } }; }); var Enemy2 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('miniFriend', { anchorX: 0.5, anchorY: 0.5, color: 0xff0000 // Set color to red }); self.lifetime = 10 * 60; // 10 seconds in ticks self.update = function () { self.lifetime--; if (self.lifetime <= 0) { self.destroy(); } // Move towards the nearest balloon if (balloons.length > 0) { var nearestBalloon = balloons[0]; var minDistance = Math.sqrt(Math.pow(self.x - nearestBalloon.x, 2) + Math.pow(self.y - nearestBalloon.y, 2)); for (var i = 1; i < balloons.length; i++) { var distance = Math.sqrt(Math.pow(self.x - balloons[i].x, 2) + Math.pow(self.y - balloons[i].y, 2)); if (distance < minDistance) { nearestBalloon = balloons[i]; minDistance = distance; } } var angle = Math.atan2(nearestBalloon.y - self.y, nearestBalloon.x - self.x); self.x += Math.cos(angle) * 4; // Faster speed self.y += Math.sin(angle) * 4; // Faster speed } for (var i = balloons.length - 1; i >= 0; i--) { if (self.intersects(balloons[i])) { LK.getSound('rubbish').play(); balloons[i].pop(); LK.setScore(LK.getScore() - 1); scoreTxt.setText(LK.getScore()); self.destroy(); // Destroy enemy after popping a balloon break; // Exit loop after popping one balloon } } }; self.down = function (x, y, obj) { for (var i = balloons.length - 1; i >= 0; i--) { if (self.intersects(balloons[i])) { balloons[i].pop(); LK.setScore(LK.getScore() - 1); scoreTxt.setText(LK.getScore()); self.destroy(); // Destroy enemy after popping a balloon break; // Exit loop after popping one balloon } } }; }); var MiniFriend = Container.expand(function () { var self = Container.call(this); var miniFriendGraphics = self.attachAsset('miniFriend', { anchorX: 0.5, anchorY: 0.5 }); self.lifetime = 15 * 60; // 15 seconds in ticks self.update = function () { self.lifetime--; if (self.lifetime <= 0) { self.destroy(); } // Move towards the nearest balloon if (balloons.length > 0) { var nearestBalloon = balloons[0]; var minDistance = Math.sqrt(Math.pow(self.x - nearestBalloon.x, 2) + Math.pow(self.y - nearestBalloon.y, 2)); for (var i = 1; i < balloons.length; i++) { var distance = Math.sqrt(Math.pow(self.x - balloons[i].x, 2) + Math.pow(self.y - balloons[i].y, 2)); if (distance < minDistance) { nearestBalloon = balloons[i]; minDistance = distance; } } var angle = Math.atan2(nearestBalloon.y - self.y, nearestBalloon.x - self.x); self.x += Math.cos(angle) * 2; self.y += Math.sin(angle) * 2; } for (var i = balloons.length - 1; i >= 0; i--) { if (self.intersects(balloons[i])) { balloons[i].pop(); self.destroy(); // Destroy mini friend after popping a balloon break; // Exit loop after popping one balloon } } }; self.down = function (x, y, obj) { for (var i = balloons.length - 1; i >= 0; i--) { if (self.intersects(balloons[i])) { balloons[i].pop(); self.destroy(); // Destroy mini friend after popping a balloon break; // Exit loop after popping one balloon } } }; }); var MusicButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('musicButton', { anchorX: 0.5, anchorY: 0.5 }); self.isPlaying = true; self.down = function (x, y, obj) { if (self.isPlaying) { LK.stopMusic(); } else { LK.playMusic('223'); } self.isPlaying = !self.isPlaying; }; }); var NewEnemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('miniFriend', { anchorX: 0.5, anchorY: 0.5, color: 0xff0000 // Set color to red }); self.lifetime = 20 * 60; // 20 seconds in ticks self.update = function () { self.lifetime--; if (self.lifetime <= 0) { self.destroy(); } // Move towards the nearest balloon if (balloons.length > 0) { var nearestBalloon = balloons[0]; var minDistance = Math.sqrt(Math.pow(self.x - nearestBalloon.x, 2) + Math.pow(self.y - nearestBalloon.y, 2)); for (var i = 1; i < balloons.length; i++) { var distance = Math.sqrt(Math.pow(self.x - balloons[i].x, 2) + Math.pow(self.y - balloons[i].y, 2)); if (distance < minDistance) { nearestBalloon = balloons[i]; minDistance = distance; } } var angle = Math.atan2(nearestBalloon.y - self.y, nearestBalloon.x - self.x); self.x += Math.cos(angle) * 3; self.y += Math.sin(angle) * 3; } for (var i = balloons.length - 1; i >= 0; i--) { if (self.intersects(balloons[i])) { LK.getSound('rubbish').play(); balloons[i].pop(); LK.setScore(LK.getScore() - 1); scoreTxt.setText(LK.getScore()); self.destroy(); // Destroy enemy after popping a balloon break; // Exit loop after popping one balloon } } }; self.down = function (x, y, obj) { for (var i = balloons.length - 1; i >= 0; i--) { if (self.intersects(balloons[i])) { balloons[i].pop(); LK.setScore(LK.getScore() - 1); scoreTxt.setText(LK.getScore()); self.destroy(); // Destroy enemy after popping a balloon break; // Exit loop after popping one balloon } } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x66e4af7512d26d43857c57ab // Init game with landscape background }); /**** * Game Code ****/ var button0 = new Button0(); button0.x = 150; button0.y = 250; LK.gui.topLeft.addChild(button0); // Create and display 'minyu' at the start of the game var minyu = LK.getAsset('minyu', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, alpha: 1 }); game.addChild(minyu); // Fade out 'minyu' after 3 seconds LK.setTimeout(function () { var fadeOutInterval = LK.setInterval(function () { minyu.alpha -= 0.01; if (minyu.alpha <= 0) { LK.clearInterval(fadeOutInterval); minyu.destroy(); } }, 50); }, 3000); // Removed Bot11 asset initialization LK.playMusic('223'); var musicButton = new MusicButton(); musicButton.x = 100; musicButton.y = 100; LK.gui.topLeft.addChild(musicButton); var landscape = LK.getAsset('landscape', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 2048 / 2048, scaleY: 2732 / 2048, width: 2048, height: 2732 }); game.addChild(landscape); landscape.width = 2048; landscape.height = 2732; var scoreTxt = new Text2('0', { size: 150, fill: "#800080" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var shield = 3; // Initialize shield with 3 lives var balloons = []; var miniFriend = null; var enemySpawned = false; var miniFriendSpawned = false; var enemy2Spawned = false; var explosions = []; // Initialize explosions array to keep track of explosions var background2Created = false; // Initialize background2Created variable var newEnemySpawned = false; // Initialize newEnemySpawned variable // Function to expand explosion effect function expandExplosion(explosion) { var radius = 0; var interval = LK.setInterval(function () { radius += 20; // Increase radius quickly explosion.width = radius; explosion.height = radius; if (radius >= 200) { LK.clearInterval(interval); explosion.destroy(); var index = explosions.indexOf(explosion); if (index > -1) { explosions.splice(index, 1); } } }, 50); // Reduce interval time for faster expansion } var spawnBalloon = function spawnBalloon() { var newBalloon = new Balloon(); newBalloon.x = Math.random() * 2048; newBalloon.y = -100; balloons.push(newBalloon); game.addChild(newBalloon); }; game.update = function () { // Removed Bot11 spawning every 20 seconds for (var i = balloons.length - 1; i >= 0; i--) { if (LK.getScore() >= 20 && LK.getScore() < 30) { balloons[i].speed = 4; } else if (LK.getScore() >= 30 && LK.getScore() < 35) { balloons[i].speed = 6; } else if (LK.getScore() >= 35) { balloons[i].speed = 8; } // Removed unnecessary destruction of balloons when they go off the screen for (var i = balloons.length - 1; i >= 0; i--) { if (balloons[i].y > 2732 - balloons[i].height / 2) { balloons.splice(i, 1); } } for (var i = balloons.length - 1; i >= 0; i--) { if (balloons[i].y > 2732 - balloons[i].height / 2) { balloons.splice(i, 1); } } } if (LK.getScore() >= 70 && !background2Created) { background2Created = true; var background2 = LK.getAsset('background2', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 2048 / 2048, scaleY: 2732 / 2048, alpha: 0 }); background2.width = 2048; background2.height = 2732; game.addChild(background2); var fadeInInterval = LK.setInterval(function () { background2.alpha += 0.01; if (background2.alpha >= 1) { LK.clearInterval(fadeInInterval); } }, 50); } if (LK.getScore() >= 101) { LK.showVictory(); // Assuming LK.showVictory() is a method to show victory message } else if (LK.getScore() < 0) { LK.showGameOver(); } if (LK.ticks % 60 == 0) { spawnBalloon(); } if (LK.getScore() >= 10 && !miniFriendSpawned) { miniFriendSpawned = true; miniFriend = new MiniFriend(); miniFriend.x = Math.random() * 2048; miniFriend.y = 2732; // Spawn at the bottom of the screen game.addChild(miniFriend); LK.setTimeout(function () { miniFriend.destroy(); miniFriendSpawned = false; }, 20000); // 20 seconds } if (LK.getScore() >= 30 && !enemySpawned) { enemySpawned = true; var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = 2732; // Spawn at the bottom of the screen game.addChild(enemy); LK.setTimeout(function () { enemy.destroy(); enemySpawned = false; }, 20000); // 20 seconds } if (LK.getScore() >= 40 && !enemy2Spawned) { enemy2Spawned = true; for (var i = 0; i < 4; i++) { var enemy2 = new Enemy2(); enemy2.x = Math.random() * 2048; enemy2.y = 2732; // Spawn at the bottom of the screen game.addChild(enemy2); LK.setTimeout(function () { enemy2.destroy(); }, 20000); // 20 seconds } LK.setTimeout(function () { enemy2Spawned = false; }, 20000); // 20 seconds } if (LK.getScore() >= 50 && !newEnemySpawned) { newEnemySpawned = true; var bot88 = new Bot88(); bot88.x = 2048 / 2; bot88.y = 2732 / 2; // Start at the center of the screen bot88.speed = 5; // Set initial horizontal speed game.addChild(bot88); var bot11Interval = LK.setInterval(function () { bot88.spawnBot11(); }, 10000); // 10 seconds LK.setTimeout(function () { bot88.destroy(); LK.clearInterval(bot11Interval); newEnemySpawned = false; }, 20000); // 20 seconds } }; LK.showVictory = function () { // Display victory message var victoryTxt = new Text2('Victory!', { size: 200, fill: "#00FF00" }); victoryTxt.anchor.set(0.5, 0.5); victoryTxt.x = 2048 / 2; victoryTxt.y = 2732 / 2; LK.gui.center.addChild(victoryTxt); // Pause the game LK.showGameOver(); };
/****
* Classes
****/
// Assets will be automatically created and loaded during gameplay
// Balloon class
var Balloon = Container.expand(function () {
var self = Container.call(this);
var balloonGraphics = self.attachAsset('balloon', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.update = function () {
if (LK.getScore() >= 20) {
self.speed = 4;
}
self.y += self.speed;
if (self.y < self.height / 2) {
self.y = self.height / 2;
}
if (self.x < self.width / 2) {
self.x = self.width / 2;
}
if (self.x > 2048 - self.width / 2) {
self.x = 2048 - self.width / 2;
}
if (self.y > 2732 - self.height / 2) {
self.y = 2732 - self.height / 2;
self.speed = 0;
LK.setScore(LK.getScore() - 1);
scoreTxt.setText(LK.getScore());
self.destroy();
if (miniFriend && miniFriend.intersects(self)) {
// No score increment when mini friend intersects balloon
}
}
// Check if balloon is close to any explosion and avoid it
for (var i = 0; i < explosions.length; i++) {
var explosion = explosions[i];
if (Math.abs(self.x - explosion.x) < 100 && Math.abs(self.y - explosion.y) < 100) {
self.x += self.x - explosion.x > 0 ? 5 : -5;
self.y += self.y - explosion.y > 0 ? 5 : -5;
self.y -= 10; // Push balloon upwards if close to explosion
}
// Push balloon away from expanding explosion
if (Math.abs(self.x - explosion.x) < 200 && Math.abs(self.y - explosion.y) < 200) {
self.x += self.x - explosion.x > 0 ? 2 : -2;
self.y += self.y - explosion.y > 0 ? 2 : -2;
}
}
// Removed unnecessary destruction of balloons when they go off the screen
};
self.down = function (x, y, obj) {
self.pop();
};
self.pop = function () {
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
LK.getSound('rubbish').play();
for (var i = balloons.length - 1; i >= 0; i--) {
if (balloons[i].y > 2732 - balloons[i].height / 2) {
balloons.splice(i, 1);
}
}
for (var i = balloons.length - 1; i >= 0; i--) {
if (balloons[i].y > 2732 - balloons[i].height / 2) {
balloons.splice(i, 1);
}
}
// Create explosion effect
var explosion = LK.getAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y
});
// Check if balloon is close enough to the explosion
if (Math.abs(self.x - explosion.x) < 100 && Math.abs(self.y - explosion.y) < 100) {
self.y -= 10; // Push balloon upwards if close to explosion
// Create explosion effect
var explosion = LK.getAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y
});
game.addChild(explosion);
explosions.push(explosion);
expandExplosion(explosion);
LK.setTimeout(function () {
explosion.destroy();
var index = explosions.indexOf(explosion);
if (index > -1) {
explosions.splice(index, 1);
}
}, 3000);
LK.effects.flashObject(explosion, 0xff0000, 500); // Flash red for 500ms
// Push all nearby balloons
for (var i = 0; i < balloons.length; i++) {
var balloon = balloons[i];
if (Math.abs(balloon.x - explosion.x) < 200 && Math.abs(balloon.y - explosion.y) < 200) {
balloon.x += balloon.x - explosion.x > 0 ? 10 : -10;
balloon.y += balloon.y - explosion.y > 0 ? 10 : -10;
}
}
}
LK.getSound('rubbish').play();
self.destroy();
if (LK.getScore() < 0) {
LK.showGameOver();
}
};
});
var Bot11 = Container.expand(function () {
var self = Container.call(this);
var botGraphics = self.attachAsset('bot11', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
});
var Bot88 = Container.expand(function () {
var self = Container.call(this);
var botGraphics = self.attachAsset('bot88', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.clickCount = 0;
self.bot11Spawned = false;
self.update = function () {
// Move horizontally across the screen
self.x += self.speed;
if (self.x > 2048 - self.width / 2 || self.x < self.width / 2) {
self.speed = -self.speed; // Reverse direction when hitting screen edges
}
};
self.down = function (x, y, obj) {
LK.getSound('Z1').play();
self.clickCount++;
if (self.clickCount >= 15) {
self.createExplosion();
self.speed = 0; // Stop moving
self.clickCount = 0;
self.spawnBot11(); // Trigger task 2
}
};
self.createExplosion = function () {
var explosion = LK.getAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y,
scaleX: 5,
scaleY: 5
});
game.addChild(explosion);
LK.getSound('Z2').play(); // Play sound 'Z2' when Bot88 explosion effect is created
LK.setTimeout(function () {
explosion.destroy();
self.destroy(); // Destroy Bot88 after explosion
// Drop attention effect
var attentionDrop = LK.getAsset('attentionDrop', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y
});
game.addChild(attentionDrop);
LK.setTimeout(function () {
attentionDrop.destroy();
}, 2000); // Destroy attention drop effect after 2 seconds
}, 1000);
self.clickCount = 0; // Reset click count
self.speed = 5; // Reset speed
};
self.spawnBot11 = function () {
if (!self.bot11Spawned) {
var bot11 = new Bot11();
bot11.x = self.x;
bot11.y = self.y;
game.addChild(bot11);
self.bot11Spawned = true;
LK.setTimeout(function () {
self.bot11Spawned = false;
}, 10000);
}
};
});
var Button0 = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('button0', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
LK.setScore(LK.getScore() + 55);
scoreTxt.setText(LK.getScore());
};
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('miniFriend', {
anchorX: 0.5,
anchorY: 0.5,
color: 0xff0000 // Set color to red
});
self.lifetime = 15 * 60; // 15 seconds in ticks
self.update = function () {
self.lifetime--;
if (self.lifetime <= 0) {
self.destroy();
}
// Move towards the nearest balloon
if (balloons.length > 0) {
var nearestBalloon = balloons[0];
var minDistance = Math.sqrt(Math.pow(self.x - nearestBalloon.x, 2) + Math.pow(self.y - nearestBalloon.y, 2));
for (var i = 1; i < balloons.length; i++) {
var distance = Math.sqrt(Math.pow(self.x - balloons[i].x, 2) + Math.pow(self.y - balloons[i].y, 2));
if (distance < minDistance) {
nearestBalloon = balloons[i];
minDistance = distance;
}
}
var angle = Math.atan2(nearestBalloon.y - self.y, nearestBalloon.x - self.x);
self.x += Math.cos(angle) * 3;
self.y += Math.sin(angle) * 3;
}
for (var i = balloons.length - 1; i >= 0; i--) {
if (self.intersects(balloons[i])) {
LK.getSound('rubbish').play();
balloons[i].pop();
LK.getSound('rubbish').play();
LK.getSound('rubbish').play();
LK.getSound('rubbish').play();
LK.setScore(LK.getScore() - 1);
scoreTxt.setText(LK.getScore());
self.destroy(); // Destroy enemy after popping a balloon
break; // Exit loop after popping one balloon
}
}
};
self.down = function (x, y, obj) {
for (var i = balloons.length - 1; i >= 0; i--) {
if (self.intersects(balloons[i])) {
balloons[i].pop();
LK.setScore(LK.getScore() - 1);
scoreTxt.setText(LK.getScore());
self.destroy(); // Destroy enemy after popping a balloon
break; // Exit loop after popping one balloon
}
}
};
});
var Enemy2 = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('miniFriend', {
anchorX: 0.5,
anchorY: 0.5,
color: 0xff0000 // Set color to red
});
self.lifetime = 10 * 60; // 10 seconds in ticks
self.update = function () {
self.lifetime--;
if (self.lifetime <= 0) {
self.destroy();
}
// Move towards the nearest balloon
if (balloons.length > 0) {
var nearestBalloon = balloons[0];
var minDistance = Math.sqrt(Math.pow(self.x - nearestBalloon.x, 2) + Math.pow(self.y - nearestBalloon.y, 2));
for (var i = 1; i < balloons.length; i++) {
var distance = Math.sqrt(Math.pow(self.x - balloons[i].x, 2) + Math.pow(self.y - balloons[i].y, 2));
if (distance < minDistance) {
nearestBalloon = balloons[i];
minDistance = distance;
}
}
var angle = Math.atan2(nearestBalloon.y - self.y, nearestBalloon.x - self.x);
self.x += Math.cos(angle) * 4; // Faster speed
self.y += Math.sin(angle) * 4; // Faster speed
}
for (var i = balloons.length - 1; i >= 0; i--) {
if (self.intersects(balloons[i])) {
LK.getSound('rubbish').play();
balloons[i].pop();
LK.setScore(LK.getScore() - 1);
scoreTxt.setText(LK.getScore());
self.destroy(); // Destroy enemy after popping a balloon
break; // Exit loop after popping one balloon
}
}
};
self.down = function (x, y, obj) {
for (var i = balloons.length - 1; i >= 0; i--) {
if (self.intersects(balloons[i])) {
balloons[i].pop();
LK.setScore(LK.getScore() - 1);
scoreTxt.setText(LK.getScore());
self.destroy(); // Destroy enemy after popping a balloon
break; // Exit loop after popping one balloon
}
}
};
});
var MiniFriend = Container.expand(function () {
var self = Container.call(this);
var miniFriendGraphics = self.attachAsset('miniFriend', {
anchorX: 0.5,
anchorY: 0.5
});
self.lifetime = 15 * 60; // 15 seconds in ticks
self.update = function () {
self.lifetime--;
if (self.lifetime <= 0) {
self.destroy();
}
// Move towards the nearest balloon
if (balloons.length > 0) {
var nearestBalloon = balloons[0];
var minDistance = Math.sqrt(Math.pow(self.x - nearestBalloon.x, 2) + Math.pow(self.y - nearestBalloon.y, 2));
for (var i = 1; i < balloons.length; i++) {
var distance = Math.sqrt(Math.pow(self.x - balloons[i].x, 2) + Math.pow(self.y - balloons[i].y, 2));
if (distance < minDistance) {
nearestBalloon = balloons[i];
minDistance = distance;
}
}
var angle = Math.atan2(nearestBalloon.y - self.y, nearestBalloon.x - self.x);
self.x += Math.cos(angle) * 2;
self.y += Math.sin(angle) * 2;
}
for (var i = balloons.length - 1; i >= 0; i--) {
if (self.intersects(balloons[i])) {
balloons[i].pop();
self.destroy(); // Destroy mini friend after popping a balloon
break; // Exit loop after popping one balloon
}
}
};
self.down = function (x, y, obj) {
for (var i = balloons.length - 1; i >= 0; i--) {
if (self.intersects(balloons[i])) {
balloons[i].pop();
self.destroy(); // Destroy mini friend after popping a balloon
break; // Exit loop after popping one balloon
}
}
};
});
var MusicButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('musicButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.isPlaying = true;
self.down = function (x, y, obj) {
if (self.isPlaying) {
LK.stopMusic();
} else {
LK.playMusic('223');
}
self.isPlaying = !self.isPlaying;
};
});
var NewEnemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('miniFriend', {
anchorX: 0.5,
anchorY: 0.5,
color: 0xff0000 // Set color to red
});
self.lifetime = 20 * 60; // 20 seconds in ticks
self.update = function () {
self.lifetime--;
if (self.lifetime <= 0) {
self.destroy();
}
// Move towards the nearest balloon
if (balloons.length > 0) {
var nearestBalloon = balloons[0];
var minDistance = Math.sqrt(Math.pow(self.x - nearestBalloon.x, 2) + Math.pow(self.y - nearestBalloon.y, 2));
for (var i = 1; i < balloons.length; i++) {
var distance = Math.sqrt(Math.pow(self.x - balloons[i].x, 2) + Math.pow(self.y - balloons[i].y, 2));
if (distance < minDistance) {
nearestBalloon = balloons[i];
minDistance = distance;
}
}
var angle = Math.atan2(nearestBalloon.y - self.y, nearestBalloon.x - self.x);
self.x += Math.cos(angle) * 3;
self.y += Math.sin(angle) * 3;
}
for (var i = balloons.length - 1; i >= 0; i--) {
if (self.intersects(balloons[i])) {
LK.getSound('rubbish').play();
balloons[i].pop();
LK.setScore(LK.getScore() - 1);
scoreTxt.setText(LK.getScore());
self.destroy(); // Destroy enemy after popping a balloon
break; // Exit loop after popping one balloon
}
}
};
self.down = function (x, y, obj) {
for (var i = balloons.length - 1; i >= 0; i--) {
if (self.intersects(balloons[i])) {
balloons[i].pop();
LK.setScore(LK.getScore() - 1);
scoreTxt.setText(LK.getScore());
self.destroy(); // Destroy enemy after popping a balloon
break; // Exit loop after popping one balloon
}
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x66e4af7512d26d43857c57ab // Init game with landscape background
});
/****
* Game Code
****/
var button0 = new Button0();
button0.x = 150;
button0.y = 250;
LK.gui.topLeft.addChild(button0);
// Create and display 'minyu' at the start of the game
var minyu = LK.getAsset('minyu', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
alpha: 1
});
game.addChild(minyu);
// Fade out 'minyu' after 3 seconds
LK.setTimeout(function () {
var fadeOutInterval = LK.setInterval(function () {
minyu.alpha -= 0.01;
if (minyu.alpha <= 0) {
LK.clearInterval(fadeOutInterval);
minyu.destroy();
}
}, 50);
}, 3000);
// Removed Bot11 asset initialization
LK.playMusic('223');
var musicButton = new MusicButton();
musicButton.x = 100;
musicButton.y = 100;
LK.gui.topLeft.addChild(musicButton);
var landscape = LK.getAsset('landscape', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 2048 / 2048,
scaleY: 2732 / 2048,
width: 2048,
height: 2732
});
game.addChild(landscape);
landscape.width = 2048;
landscape.height = 2732;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#800080"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var shield = 3; // Initialize shield with 3 lives
var balloons = [];
var miniFriend = null;
var enemySpawned = false;
var miniFriendSpawned = false;
var enemy2Spawned = false;
var explosions = []; // Initialize explosions array to keep track of explosions
var background2Created = false; // Initialize background2Created variable
var newEnemySpawned = false; // Initialize newEnemySpawned variable
// Function to expand explosion effect
function expandExplosion(explosion) {
var radius = 0;
var interval = LK.setInterval(function () {
radius += 20; // Increase radius quickly
explosion.width = radius;
explosion.height = radius;
if (radius >= 200) {
LK.clearInterval(interval);
explosion.destroy();
var index = explosions.indexOf(explosion);
if (index > -1) {
explosions.splice(index, 1);
}
}
}, 50); // Reduce interval time for faster expansion
}
var spawnBalloon = function spawnBalloon() {
var newBalloon = new Balloon();
newBalloon.x = Math.random() * 2048;
newBalloon.y = -100;
balloons.push(newBalloon);
game.addChild(newBalloon);
};
game.update = function () {
// Removed Bot11 spawning every 20 seconds
for (var i = balloons.length - 1; i >= 0; i--) {
if (LK.getScore() >= 20 && LK.getScore() < 30) {
balloons[i].speed = 4;
} else if (LK.getScore() >= 30 && LK.getScore() < 35) {
balloons[i].speed = 6;
} else if (LK.getScore() >= 35) {
balloons[i].speed = 8;
}
// Removed unnecessary destruction of balloons when they go off the screen
for (var i = balloons.length - 1; i >= 0; i--) {
if (balloons[i].y > 2732 - balloons[i].height / 2) {
balloons.splice(i, 1);
}
}
for (var i = balloons.length - 1; i >= 0; i--) {
if (balloons[i].y > 2732 - balloons[i].height / 2) {
balloons.splice(i, 1);
}
}
}
if (LK.getScore() >= 70 && !background2Created) {
background2Created = true;
var background2 = LK.getAsset('background2', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 2048 / 2048,
scaleY: 2732 / 2048,
alpha: 0
});
background2.width = 2048;
background2.height = 2732;
game.addChild(background2);
var fadeInInterval = LK.setInterval(function () {
background2.alpha += 0.01;
if (background2.alpha >= 1) {
LK.clearInterval(fadeInInterval);
}
}, 50);
}
if (LK.getScore() >= 101) {
LK.showVictory(); // Assuming LK.showVictory() is a method to show victory message
} else if (LK.getScore() < 0) {
LK.showGameOver();
}
if (LK.ticks % 60 == 0) {
spawnBalloon();
}
if (LK.getScore() >= 10 && !miniFriendSpawned) {
miniFriendSpawned = true;
miniFriend = new MiniFriend();
miniFriend.x = Math.random() * 2048;
miniFriend.y = 2732; // Spawn at the bottom of the screen
game.addChild(miniFriend);
LK.setTimeout(function () {
miniFriend.destroy();
miniFriendSpawned = false;
}, 20000); // 20 seconds
}
if (LK.getScore() >= 30 && !enemySpawned) {
enemySpawned = true;
var enemy = new Enemy();
enemy.x = Math.random() * 2048;
enemy.y = 2732; // Spawn at the bottom of the screen
game.addChild(enemy);
LK.setTimeout(function () {
enemy.destroy();
enemySpawned = false;
}, 20000); // 20 seconds
}
if (LK.getScore() >= 40 && !enemy2Spawned) {
enemy2Spawned = true;
for (var i = 0; i < 4; i++) {
var enemy2 = new Enemy2();
enemy2.x = Math.random() * 2048;
enemy2.y = 2732; // Spawn at the bottom of the screen
game.addChild(enemy2);
LK.setTimeout(function () {
enemy2.destroy();
}, 20000); // 20 seconds
}
LK.setTimeout(function () {
enemy2Spawned = false;
}, 20000); // 20 seconds
}
if (LK.getScore() >= 50 && !newEnemySpawned) {
newEnemySpawned = true;
var bot88 = new Bot88();
bot88.x = 2048 / 2;
bot88.y = 2732 / 2; // Start at the center of the screen
bot88.speed = 5; // Set initial horizontal speed
game.addChild(bot88);
var bot11Interval = LK.setInterval(function () {
bot88.spawnBot11();
}, 10000); // 10 seconds
LK.setTimeout(function () {
bot88.destroy();
LK.clearInterval(bot11Interval);
newEnemySpawned = false;
}, 20000); // 20 seconds
}
};
LK.showVictory = function () {
// Display victory message
var victoryTxt = new Text2('Victory!', {
size: 200,
fill: "#00FF00"
});
victoryTxt.anchor.set(0.5, 0.5);
victoryTxt.x = 2048 / 2;
victoryTxt.y = 2732 / 2;
LK.gui.center.addChild(victoryTxt);
// Pause the game
LK.showGameOver();
};
Шарик воздушный на с галстуком Ярко жолтый цвет и синий галстук. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Пчела. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Круглая кнопка прозрачная внутри нота. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Поле, посередине Луна ночная версия. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.