/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Balloon class var Balloon = Container.expand(function () { var self = Container.call(this); var balloonGraphics = self.attachAsset('balloon', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Balloon update logic }; }); // Cloud class var Cloud = Container.expand(function () { var self = Container.call(this); var cloudGraphics = self.attachAsset('cloud', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Clouds remain stationary }; }); // Coin class var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Coins remain stationary }; }); // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * 4 - 2; // Random horizontal speed between -2 and 2 self.update = function () { self.x += self.speed; if (self.x < 0 || self.x > 2048) { self.speed *= -1; // Reverse direction if it hits the screen edge } }; }); // RareCoin class var RareCoin = Container.expand(function () { var self = Container.call(this); var rareCoinGraphics = self.attachAsset('rare', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Rare coins remain stationary }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ // Mute background music 'cozy' LK.playMusic('cozy', { loop: true, volume: 0 }); var balloon = game.addChild(new Balloon()); var clouds = []; for (var i = 0; i < 3; i++) { var cloud = new Cloud(); cloud.x = Math.random() * 2048; cloud.y = Math.random() * 2732; clouds.push(cloud); game.addChild(cloud); } balloon.x = 1024; // Center horizontally balloon.y = 2000; // Initial vertical position var coins = []; var obstacles = []; var score = 0; var highestScore = 0; var highestScoreTxt = new Text2('Highest Score: 0', { size: 100, fill: "#ffffff" }); highestScoreTxt.anchor.set(0, 1); LK.gui.bottomLeft.addChild(highestScoreTxt); function spawnCoin() { if (Math.random() < 0.1) { // 10% chance to spawn a rare coin var rareCoin = new RareCoin(); rareCoin.x = Math.random() * 2048; rareCoin.y = balloon.y - 2732; coins.push(rareCoin); game.addChild(rareCoin); } else { var coin = new Coin(); coin.x = Math.random() * 2048; coin.y = balloon.y - 2732; coins.push(coin); game.addChild(coin); } } function spawnObstacle() { var obstacle = new Obstacle(); obstacle.x = Math.random() * 2048; obstacle.speed = Math.random() * 4 - 2; // Random horizontal speed between -2 and 2 obstacle.y = balloon.y - 2732; obstacles.push(obstacle); game.addChild(obstacle); } game.down = function (x, y, obj) { balloon.x = x; // Allow horizontal movement only }; game.move = function (x, y, obj) { balloon.x = x; // Allow horizontal movement only }; // Removed arrow key event listener game.update = function () { balloon.y -= 5; // Move balloon upwards game.y += 5; // Move background upwards with the balloon // Ensure balloon stays within screen bounds if (balloon.x < 0) { balloon.x = 0; } else if (balloon.x > 2048) { balloon.x = 2048; } // Clouds remain stationary, no need to update for (var i = coins.length - 1; i >= 0; i--) { if (balloon.intersects(coins[i])) { if (coins[i] instanceof RareCoin) { score += 5; // Rare coins give more points } else { score += 1; } if (score > highestScore) { highestScore = score; highestScoreTxt.setText('Highest Score: ' + highestScore); } LK.getSound('coinCollect').play(); LK.getSound('coinCollect').play(); coins[i].destroy(); coins.splice(i, 1); } } for (var j = obstacles.length - 1; j >= 0; j--) { obstacles[j].update(); if (balloon.intersects(obstacles[j])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } if (balloon.y % 300 === 0) { var cloud = new Cloud(); cloud.x = Math.random() * 2048; cloud.y = Math.random() * 2732; clouds.push(cloud); game.addChild(cloud); } if (balloon.y % 200 === 0) { spawnCoin(); } if (balloon.y % 300 === 0) { spawnObstacle(); } };
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
// Balloon class
var Balloon = Container.expand(function () {
var self = Container.call(this);
var balloonGraphics = self.attachAsset('balloon', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Balloon update logic
};
});
// Cloud class
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Clouds remain stationary
};
});
// Coin class
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Coins remain stationary
};
});
// Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 4 - 2; // Random horizontal speed between -2 and 2
self.update = function () {
self.x += self.speed;
if (self.x < 0 || self.x > 2048) {
self.speed *= -1; // Reverse direction if it hits the screen edge
}
};
});
// RareCoin class
var RareCoin = Container.expand(function () {
var self = Container.call(this);
var rareCoinGraphics = self.attachAsset('rare', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Rare coins remain stationary
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
// Mute background music 'cozy'
LK.playMusic('cozy', {
loop: true,
volume: 0
});
var balloon = game.addChild(new Balloon());
var clouds = [];
for (var i = 0; i < 3; i++) {
var cloud = new Cloud();
cloud.x = Math.random() * 2048;
cloud.y = Math.random() * 2732;
clouds.push(cloud);
game.addChild(cloud);
}
balloon.x = 1024; // Center horizontally
balloon.y = 2000; // Initial vertical position
var coins = [];
var obstacles = [];
var score = 0;
var highestScore = 0;
var highestScoreTxt = new Text2('Highest Score: 0', {
size: 100,
fill: "#ffffff"
});
highestScoreTxt.anchor.set(0, 1);
LK.gui.bottomLeft.addChild(highestScoreTxt);
function spawnCoin() {
if (Math.random() < 0.1) {
// 10% chance to spawn a rare coin
var rareCoin = new RareCoin();
rareCoin.x = Math.random() * 2048;
rareCoin.y = balloon.y - 2732;
coins.push(rareCoin);
game.addChild(rareCoin);
} else {
var coin = new Coin();
coin.x = Math.random() * 2048;
coin.y = balloon.y - 2732;
coins.push(coin);
game.addChild(coin);
}
}
function spawnObstacle() {
var obstacle = new Obstacle();
obstacle.x = Math.random() * 2048;
obstacle.speed = Math.random() * 4 - 2; // Random horizontal speed between -2 and 2
obstacle.y = balloon.y - 2732;
obstacles.push(obstacle);
game.addChild(obstacle);
}
game.down = function (x, y, obj) {
balloon.x = x; // Allow horizontal movement only
};
game.move = function (x, y, obj) {
balloon.x = x; // Allow horizontal movement only
};
// Removed arrow key event listener
game.update = function () {
balloon.y -= 5; // Move balloon upwards
game.y += 5; // Move background upwards with the balloon
// Ensure balloon stays within screen bounds
if (balloon.x < 0) {
balloon.x = 0;
} else if (balloon.x > 2048) {
balloon.x = 2048;
}
// Clouds remain stationary, no need to update
for (var i = coins.length - 1; i >= 0; i--) {
if (balloon.intersects(coins[i])) {
if (coins[i] instanceof RareCoin) {
score += 5; // Rare coins give more points
} else {
score += 1;
}
if (score > highestScore) {
highestScore = score;
highestScoreTxt.setText('Highest Score: ' + highestScore);
}
LK.getSound('coinCollect').play();
LK.getSound('coinCollect').play();
coins[i].destroy();
coins.splice(i, 1);
}
}
for (var j = obstacles.length - 1; j >= 0; j--) {
obstacles[j].update();
if (balloon.intersects(obstacles[j])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
if (balloon.y % 300 === 0) {
var cloud = new Cloud();
cloud.x = Math.random() * 2048;
cloud.y = Math.random() * 2732;
clouds.push(cloud);
game.addChild(cloud);
}
if (balloon.y % 200 === 0) {
spawnCoin();
}
if (balloon.y % 300 === 0) {
spawnObstacle();
}
};
hot air balloon with simple pixel art. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
simple pixel art coin and yellow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
remove the pixel i select
pixel art coin with red color. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.