/****
* Classes
****/
var BadPowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('badPowerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
var temp = balls;
balls = bombs;
bombs = temp;
LK.getSound('Powerdown').play();
hearts[hearts.length - 1].destroy();
hearts.pop();
if (hearts.length === 0) {
LK.showGameOver();
var leaderboardScreen = new LeaderboardScreen();
game.addChild(leaderboardScreen);
}
self.destroy();
};
});
var Ball = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
LK.getSound('Pop').play();
self.destroy();
};
});
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
LK.getSound('Bomb').play();
LK.effects.flashScreen(0xff0000, 1000);
hearts[hearts.length - 1].destroy();
hearts.pop();
if (hearts.length === 0) {
LK.showGameOver();
var leaderboardScreen = new LeaderboardScreen();
game.addChild(leaderboardScreen);
}
};
});
var GoodPowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('goodPowerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
LK.setScore(LK.getScore() + 10);
LK.getSound('Goodpower').play();
self.destroy();
};
});
var Heart = Container.expand(function () {
var self = Container.call(this);
var heartGraphics = self.attachAsset('heart', {
anchorX: 0.5,
anchorY: 0.5,
fontWeight: 'bold'
});
});
//<Write imports for supported plugins here>
//<Write entity 'classes' with empty functions for important behavior here>
var HomeScreen = Container.expand(function () {
var self = Container.call(this);
var playButton = self.attachAsset('playButton', {
anchorX: 0.5,
anchorY: 0,
width: 2048,
height: 2732,
fontWeight: 'bold'
});
playButton.x = 2048 / 2;
playButton.y = 0;
playButton.filters = [];
self.down = function (x, y, obj) {
self.destroy();
startGame();
};
});
var LeaderboardScreen = Container.expand(function () {
var self = Container.call(this);
var leaderboardText = new Text2('Leaderboard', {
size: 150,
fill: 0x000000,
fontWeight: 'bold'
});
leaderboardText.anchor.set(0.5, 0);
self.addChild(leaderboardText);
leaderboardText.x = 2048 / 2;
leaderboardText.y = 200;
// LK.getLeaderboard is not a function, so we can't use it here.
// We need to replace it with a valid function or remove it if it's not necessary.
// For now, let's just comment it out.
});
var RainbowBall = Container.expand(function () {
var self = Container.call(this);
var rainbowBallGraphics = self.attachAsset('rainbowBall', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
LK.setScore(LK.getScore() + 5);
scoreTxt.setText(LK.getScore());
LK.getSound('Pop').play();
self.destroy();
};
});
var ScorePowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('goodPowerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
LK.setScore(LK.getScore() + 15);
scoreTxt.setText(LK.getScore());
LK.getSound('Goodpower').play();
self.destroy();
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x9400D3
});
/****
* Game Code
****/
var scoreTxt;
var hearts = [];
var balls = [];
var bombs = [];
var homeScreen = new HomeScreen();
game.addChild(homeScreen);
//<Assets used in the game will automatically appear here>
//<Write game logic code here, including initializing arrays and variables>
function startGame() {
scoreTxt = new Text2('0', {
size: 150,
fill: 0x000000,
fontWeight: 'bold'
});
hearts = [];
for (var i = 0; i < 3; i++) {
var heart = new Heart();
heart.x = 2048 - (50 + i * 120) - 150; // 150px = 0.75cm on a 12.9" iPad Pro
heart.y = 50;
hearts.push(heart);
game.addChild(heart);
}
scoreTxt.anchor.set(0.5, 0);
LK.playMusic('Song', {
loop: true
});
LK.gui.top.addChild(scoreTxt);
var balls = [];
var bombs = [];
function spawnBall() {
var newBall = new Ball();
newBall.x = 100 + Math.random() * (2048 - 200); // 100px = 1cm on a 12.9" iPad Pro
newBall.y = 0;
// Check if the new ball overlaps with any existing balls
for (var i = 0; i < balls.length; i++) {
if (newBall.intersects(balls[i])) {
return; // If it overlaps, don't add the new ball
}
}
// Check if the new ball overlaps with any existing balls
for (var i = 0; i < balls.length; i++) {
if (newBall.intersects(balls[i])) {
return; // If it overlaps, don't add the new ball
}
}
balls.push(newBall);
game.addChild(newBall);
}
function spawnBomb() {
var newBomb = new Bomb();
newBomb.x = 100 + Math.random() * (2048 - 200); // 100px = 1cm on a 12.9" iPad Pro
newBomb.y = 0;
// Check if the new bomb overlaps with any existing bombs
for (var i = 0; i < bombs.length; i++) {
if (newBomb.intersects(bombs[i])) {
return; // If it overlaps, don't add the new bomb
}
}
bombs.push(newBomb);
game.addChild(newBomb);
}
function spawnRainbowBall() {
var newRainbowBall = new RainbowBall();
newRainbowBall.x = 100 + Math.random() * (2048 - 200); // 100px = 1cm on a 12.9" iPad Pro
newRainbowBall.y = 0;
// Check if the new rainbow ball overlaps with any existing rainbow balls
for (var i = 0; i < game.children.length; i++) {
if (game.children[i] instanceof RainbowBall && newRainbowBall.intersects(game.children[i])) {
return; // If it overlaps, don't add the new rainbow ball
}
}
game.addChild(newRainbowBall);
}
var ballInterval = LK.setInterval(spawnBall, 1000 - LK.getScore() * 20);
var bombInterval = LK.setInterval(spawnBomb, 10000 - LK.getScore() * 200);
function spawnPowerUp() {
var powerUp;
var randomValue = Math.random();
if (randomValue < 0.25) {
powerUp = new GoodPowerUp();
} else if (randomValue < 0.5) {
powerUp = new BadPowerUp();
} else if (randomValue < 0.75) {
powerUp = new ScorePowerUp();
} else {
powerUp = new BadPowerUp();
}
powerUp.x = 100 + Math.random() * (2048 - 200);
powerUp.y = 0;
// Check if the new power-up overlaps with any existing power-ups
for (var i = 0; i < game.children.length; i++) {
if ((game.children[i] instanceof GoodPowerUp || game.children[i] instanceof BadPowerUp || game.children[i] instanceof ScorePowerUp) && powerUp.intersects(game.children[i])) {
return; // If it overlaps, don't add the new power-up
}
}
game.addChild(powerUp);
}
var powerUpInterval = LK.setInterval(spawnPowerUp, 10000);
var rainbowBallInterval = LK.setInterval(spawnRainbowBall, 30000 - LK.getScore() * 600);
var badPowerUpInterval = LK.setInterval(function () {
var badPowerUp = new BadPowerUp();
badPowerUp.x = 100 + Math.random() * (2048 - 200);
badPowerUp.y = 0;
game.addChild(badPowerUp);
}, 60000);
game.update = function () {
if (LK.getScore() % 10 == 0) {
LK.clearInterval(ballInterval);
LK.clearInterval(bombInterval);
LK.clearInterval(rainbowBallInterval);
ballInterval = LK.setInterval(spawnBall, 500 - LK.getScore() * 20);
bombInterval = LK.setInterval(spawnBomb, 5000 - LK.getScore() * 200);
rainbowBallInterval = LK.setInterval(spawnRainbowBall, 15000 - LK.getScore() * 600);
}
for (var i = balls.length - 1; i >= 0; i--) {
balls[i].update();
if (balls[i].y > 2732) {
balls[i].destroy();
balls.splice(i, 1);
if (hearts.length > 2) {
hearts[hearts.length - 1].destroy();
hearts.pop();
}
}
if (hearts.length === 0) {
LK.showGameOver();
var leaderboardScreen = new LeaderboardScreen();
game.addChild(leaderboardScreen);
}
}
for (var j = bombs.length - 1; j >= 0; j--) {
bombs[j].update();
if (bombs[j].y > 2732) {
bombs[j].destroy();
bombs.splice(j, 1);
}
}
};
game.update = function () {
for (var i = balls.length - 1; i >= 0; i--) {
balls[i].update();
if (balls[i].y > 2732) {
balls[i].destroy();
balls.splice(i, 1);
}
}
for (var j = bombs.length - 1; j >= 0; j--) {
bombs[j].update();
if (bombs[j].y > 2732) {
bombs[j].destroy();
bombs.splice(j, 1);
}
}
for (var k = game.children.length - 1; k >= 0; k--) {
if (game.children[k] instanceof RainbowBall || game.children[k] instanceof GoodPowerUp || game.children[k] instanceof BadPowerUp) {
game.children[k].update();
if (game.children[k].y > 2732) {
game.children[k].destroy();
}
}
}
};
game.down = function (x, y, obj) {
// Handle global down events if needed
};
game.up = function (x, y, obj) {
// Handle global up events if needed
};
} /****
* Classes
****/
var BadPowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('badPowerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
var temp = balls;
balls = bombs;
bombs = temp;
LK.getSound('Powerdown').play();
hearts[hearts.length - 1].destroy();
hearts.pop();
if (hearts.length === 0) {
LK.showGameOver();
var leaderboardScreen = new LeaderboardScreen();
game.addChild(leaderboardScreen);
}
self.destroy();
};
});
var Ball = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
LK.getSound('Pop').play();
self.destroy();
};
});
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
LK.getSound('Bomb').play();
LK.effects.flashScreen(0xff0000, 1000);
hearts[hearts.length - 1].destroy();
hearts.pop();
if (hearts.length === 0) {
LK.showGameOver();
var leaderboardScreen = new LeaderboardScreen();
game.addChild(leaderboardScreen);
}
};
});
var GoodPowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('goodPowerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
LK.setScore(LK.getScore() + 10);
LK.getSound('Goodpower').play();
self.destroy();
};
});
var Heart = Container.expand(function () {
var self = Container.call(this);
var heartGraphics = self.attachAsset('heart', {
anchorX: 0.5,
anchorY: 0.5,
fontWeight: 'bold'
});
});
//<Write imports for supported plugins here>
//<Write entity 'classes' with empty functions for important behavior here>
var HomeScreen = Container.expand(function () {
var self = Container.call(this);
var playButton = self.attachAsset('playButton', {
anchorX: 0.5,
anchorY: 0,
width: 2048,
height: 2732,
fontWeight: 'bold'
});
playButton.x = 2048 / 2;
playButton.y = 0;
playButton.filters = [];
self.down = function (x, y, obj) {
self.destroy();
startGame();
};
});
var LeaderboardScreen = Container.expand(function () {
var self = Container.call(this);
var leaderboardText = new Text2('Leaderboard', {
size: 150,
fill: 0x000000,
fontWeight: 'bold'
});
leaderboardText.anchor.set(0.5, 0);
self.addChild(leaderboardText);
leaderboardText.x = 2048 / 2;
leaderboardText.y = 200;
// LK.getLeaderboard is not a function, so we can't use it here.
// We need to replace it with a valid function or remove it if it's not necessary.
// For now, let's just comment it out.
});
var RainbowBall = Container.expand(function () {
var self = Container.call(this);
var rainbowBallGraphics = self.attachAsset('rainbowBall', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
LK.setScore(LK.getScore() + 5);
scoreTxt.setText(LK.getScore());
LK.getSound('Pop').play();
self.destroy();
};
});
var ScorePowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('goodPowerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15 + Math.floor(LK.getScore() / 5);
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.down = function (x, y, obj) {
LK.setScore(LK.getScore() + 15);
scoreTxt.setText(LK.getScore());
LK.getSound('Goodpower').play();
self.destroy();
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x9400D3
});
/****
* Game Code
****/
var scoreTxt;
var hearts = [];
var balls = [];
var bombs = [];
var homeScreen = new HomeScreen();
game.addChild(homeScreen);
//<Assets used in the game will automatically appear here>
//<Write game logic code here, including initializing arrays and variables>
function startGame() {
scoreTxt = new Text2('0', {
size: 150,
fill: 0x000000,
fontWeight: 'bold'
});
hearts = [];
for (var i = 0; i < 3; i++) {
var heart = new Heart();
heart.x = 2048 - (50 + i * 120) - 150; // 150px = 0.75cm on a 12.9" iPad Pro
heart.y = 50;
hearts.push(heart);
game.addChild(heart);
}
scoreTxt.anchor.set(0.5, 0);
LK.playMusic('Song', {
loop: true
});
LK.gui.top.addChild(scoreTxt);
var balls = [];
var bombs = [];
function spawnBall() {
var newBall = new Ball();
newBall.x = 100 + Math.random() * (2048 - 200); // 100px = 1cm on a 12.9" iPad Pro
newBall.y = 0;
// Check if the new ball overlaps with any existing balls
for (var i = 0; i < balls.length; i++) {
if (newBall.intersects(balls[i])) {
return; // If it overlaps, don't add the new ball
}
}
// Check if the new ball overlaps with any existing balls
for (var i = 0; i < balls.length; i++) {
if (newBall.intersects(balls[i])) {
return; // If it overlaps, don't add the new ball
}
}
balls.push(newBall);
game.addChild(newBall);
}
function spawnBomb() {
var newBomb = new Bomb();
newBomb.x = 100 + Math.random() * (2048 - 200); // 100px = 1cm on a 12.9" iPad Pro
newBomb.y = 0;
// Check if the new bomb overlaps with any existing bombs
for (var i = 0; i < bombs.length; i++) {
if (newBomb.intersects(bombs[i])) {
return; // If it overlaps, don't add the new bomb
}
}
bombs.push(newBomb);
game.addChild(newBomb);
}
function spawnRainbowBall() {
var newRainbowBall = new RainbowBall();
newRainbowBall.x = 100 + Math.random() * (2048 - 200); // 100px = 1cm on a 12.9" iPad Pro
newRainbowBall.y = 0;
// Check if the new rainbow ball overlaps with any existing rainbow balls
for (var i = 0; i < game.children.length; i++) {
if (game.children[i] instanceof RainbowBall && newRainbowBall.intersects(game.children[i])) {
return; // If it overlaps, don't add the new rainbow ball
}
}
game.addChild(newRainbowBall);
}
var ballInterval = LK.setInterval(spawnBall, 1000 - LK.getScore() * 20);
var bombInterval = LK.setInterval(spawnBomb, 10000 - LK.getScore() * 200);
function spawnPowerUp() {
var powerUp;
var randomValue = Math.random();
if (randomValue < 0.25) {
powerUp = new GoodPowerUp();
} else if (randomValue < 0.5) {
powerUp = new BadPowerUp();
} else if (randomValue < 0.75) {
powerUp = new ScorePowerUp();
} else {
powerUp = new BadPowerUp();
}
powerUp.x = 100 + Math.random() * (2048 - 200);
powerUp.y = 0;
// Check if the new power-up overlaps with any existing power-ups
for (var i = 0; i < game.children.length; i++) {
if ((game.children[i] instanceof GoodPowerUp || game.children[i] instanceof BadPowerUp || game.children[i] instanceof ScorePowerUp) && powerUp.intersects(game.children[i])) {
return; // If it overlaps, don't add the new power-up
}
}
game.addChild(powerUp);
}
var powerUpInterval = LK.setInterval(spawnPowerUp, 10000);
var rainbowBallInterval = LK.setInterval(spawnRainbowBall, 30000 - LK.getScore() * 600);
var badPowerUpInterval = LK.setInterval(function () {
var badPowerUp = new BadPowerUp();
badPowerUp.x = 100 + Math.random() * (2048 - 200);
badPowerUp.y = 0;
game.addChild(badPowerUp);
}, 60000);
game.update = function () {
if (LK.getScore() % 10 == 0) {
LK.clearInterval(ballInterval);
LK.clearInterval(bombInterval);
LK.clearInterval(rainbowBallInterval);
ballInterval = LK.setInterval(spawnBall, 500 - LK.getScore() * 20);
bombInterval = LK.setInterval(spawnBomb, 5000 - LK.getScore() * 200);
rainbowBallInterval = LK.setInterval(spawnRainbowBall, 15000 - LK.getScore() * 600);
}
for (var i = balls.length - 1; i >= 0; i--) {
balls[i].update();
if (balls[i].y > 2732) {
balls[i].destroy();
balls.splice(i, 1);
if (hearts.length > 2) {
hearts[hearts.length - 1].destroy();
hearts.pop();
}
}
if (hearts.length === 0) {
LK.showGameOver();
var leaderboardScreen = new LeaderboardScreen();
game.addChild(leaderboardScreen);
}
}
for (var j = bombs.length - 1; j >= 0; j--) {
bombs[j].update();
if (bombs[j].y > 2732) {
bombs[j].destroy();
bombs.splice(j, 1);
}
}
};
game.update = function () {
for (var i = balls.length - 1; i >= 0; i--) {
balls[i].update();
if (balls[i].y > 2732) {
balls[i].destroy();
balls.splice(i, 1);
}
}
for (var j = bombs.length - 1; j >= 0; j--) {
bombs[j].update();
if (bombs[j].y > 2732) {
bombs[j].destroy();
bombs.splice(j, 1);
}
}
for (var k = game.children.length - 1; k >= 0; k--) {
if (game.children[k] instanceof RainbowBall || game.children[k] instanceof GoodPowerUp || game.children[k] instanceof BadPowerUp) {
game.children[k].update();
if (game.children[k].y > 2732) {
game.children[k].destroy();
}
}
}
};
game.down = function (x, y, obj) {
// Handle global down events if needed
};
game.up = function (x, y, obj) {
// Handle global up events if needed
};
}
Red minecraft heart. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Black background with word start in middle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Rainbow ball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cool scenic view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadowcs.
Ball for pop game plain green. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Bomb for pop game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Upgrade sign. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.