/****
* 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
};
});
// 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 () {
self.y += 5; // Move coin downwards
if (self.y > 2732) {
self.destroy();
}
};
});
// Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += 7; // Move obstacle downwards
self.x += Math.sin(LK.ticks / 30) * 5; // Move obstacle slightly left and right
if (self.y > 2732) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
var balloon = game.addChild(new Balloon());
balloon.x = 1024; // Center horizontally
balloon.y = 2000; // Initial vertical position
var coins = [];
var obstacles = [];
var score = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(scoreTxt);
function spawnCoin() {
var coin = new Coin();
coin.x = Math.random() * 2048;
coin.y = -50;
coins.push(coin);
game.addChild(coin);
}
function spawnObstacle() {
var obstacle = new Obstacle();
obstacle.x = Math.random() * 2048;
obstacle.y = -50;
obstacles.push(obstacle);
game.addChild(obstacle);
}
game.down = function (x, y, obj) {
balloon.x = x;
balloon.y = y;
};
game.move = function (x, y, obj) {
balloon.x = x;
balloon.y = y;
};
game.update = function () {
for (var i = coins.length - 1; i >= 0; i--) {
if (balloon.intersects(coins[i])) {
score += 1;
scoreTxt.setText(score);
coins[i].destroy();
coins.splice(i, 1);
}
}
for (var j = obstacles.length - 1; j >= 0; j--) {
if (balloon.intersects(obstacles[j])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
if (LK.ticks % 60 == 0) {
spawnCoin();
}
if (LK.ticks % 90 == 0) {
spawnObstacle();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -35,8 +35,9 @@
anchorY: 0.5
});
self.update = function () {
self.y += 7; // Move obstacle downwards
+ self.x += Math.sin(LK.ticks / 30) * 5; // Move obstacle slightly left and right
if (self.y > 2732) {
self.destroy();
}
};
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.