/****
* Classes
****/
// 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 () {
if (self.y <= 2732) {
// Obstacles move down at a constant speed
self.y += 5;
} else {
// If obstacle goes off the bottom of the screen, wrap around to the top
self.y = 0;
}
};
});
// The game engine will automatically load the necessary assets
// Player character class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('shuttle', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
if (self.y >= 0) {
// Player moves up at a constant speed
self.y -= 5;
} else {
// If player goes off the top of the screen, wrap around to the bottom
self.y = 2732;
}
};
});
// Power-up class
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
if (self.y <= 2732) {
// Power-ups move down at a constant speed
self.y += 3;
} else {
// If power-up goes off the bottom of the screen, wrap around to the top
self.y = 0;
}
};
});
// Shield class
var Shield = Container.expand(function () {
var self = Container.call(this);
// Removed the yellow box by eliminating the centerCircle asset
self.update = function () {
// Shield logic can be added here if needed
};
});
// SlowDown Obstacle class
var SlowDown = Container.expand(function () {
var self = Container.call(this);
var slowDownGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
if (self.y <= 2732) {
// SlowDowns move down at a constant speed
self.y += 2;
} else {
// If SlowDown goes off the bottom of the screen, wrap around to the top
self.y = 0;
}
};
});
// SpeedBoost Power-up class
var SpeedBoost = Container.expand(function () {
var self = Container.call(this);
var speedBoostGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
if (self.y <= 2732) {
// SpeedBoosts move down at a constant speed
self.y += 4;
} else {
// If SpeedBoost goes off the bottom of the screen, wrap around to the top
self.y = 0;
}
};
});
// SupplyBox class
var SupplyBox = Container.expand(function () {
var self = Container.call(this);
var supplyBoxGraphics = self.attachAsset('boost', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
if (self.y <= 2732) {
// SupplyBoxes move down at a constant speed
self.y += 3;
} else {
// If SupplyBox goes off the bottom of the screen, wrap around to the top
self.y = 0;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000,
// Init game with black background
preloadAssets: true // Preload assets for optimized performance
});
/****
* Game Code
****/
// Set bkg-2 as the background image
var earthBackground = LK.getAsset('bkg-2', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2048 / 410,
scaleY: 2732 / 410
});
earthBackground.x = 2048 / 2;
earthBackground.y = 2732 / 2;
game.addChild(earthBackground);
// Initialize score text
var scoreBackground = new Container();
var scoreBgGraphics = scoreBackground.attachAsset('scoreBg', {
anchorX: 0.5,
anchorY: 0.5
});
scoreBgGraphics.width = 300;
scoreBgGraphics.height = 100;
scoreBgGraphics.tint = 0x000000;
scoreBgGraphics.alpha = 0.5;
scoreBackground.x = 2048 / 2;
scoreBackground.y = 50;
LK.gui.top.addChild(scoreBackground);
var scoreTxt = new Text2('0', {
size: 100,
fill: "#ffffff",
stroke: "#000000",
strokeThickness: 5
});
scoreTxt.anchor.set(0.5, 0.5);
scoreTxt.x = 2048 / 2;
scoreTxt.y = 25;
LK.gui.top.addChild(scoreTxt);
// Initialize score text to display the current score
scoreTxt.setText(LK.getScore());
// Removed redundant style property setting for score text
// Initialize player, obstacles, and power-ups
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 / 2;
// Tutorial overlay
var tutorialOverlay = new Container();
var tutorialText = new Text2('Drag the player to avoid obstacles and collect power-ups!', {
size: 100,
fill: "#ffffff"
});
tutorialText.anchor.set(0.5, 0.5);
tutorialText.x = 2048 / 2;
tutorialText.y = 2732 / 2;
tutorialOverlay.addChild(tutorialText);
game.addChild(tutorialOverlay);
// Remove tutorial after 5 seconds
LK.setTimeout(function () {
if (tutorialOverlay) {
tutorialOverlay.destroy();
tutorialOverlay = null;
}
}, 5000);
var obstacles = [];
var powerUps = [];
var level = 1;
var maxObstacles = 10;
var maxPowerUps = 5;
function initializeLevel() {
// Clear existing obstacles and power-ups
obstacles.forEach(function (obstacle) {
return obstacle.destroy();
});
powerUps.forEach(function (powerUp) {
return powerUp.destroy();
});
obstacles = [];
powerUps = [];
// Increase difficulty by adding more obstacles and power-ups
for (var i = 0; i < maxPowerUps; i++) {
var powerUp = game.addChild(new PowerUp());
powerUp.x = Math.random() * 2048;
powerUp.y = Math.random() * 2732;
powerUps.push(powerUp);
if (i % 2 === 0) {
var speedBoost = game.addChild(new SpeedBoost());
speedBoost.x = Math.random() * 2048;
speedBoost.y = Math.random() * 2732;
powerUps.push(speedBoost);
}
if (i % 3 === 0) {
var supplyBox = game.addChild(new SupplyBox());
supplyBox.x = Math.random() * 2048;
supplyBox.y = Math.random() * 2732;
powerUps.push(supplyBox);
}
}
for (var i = 0; i < maxObstacles; i++) {
var obstacle = game.addChild(new Obstacle());
obstacle.x = Math.random() * 2048;
obstacle.y = Math.random() * 2732;
obstacles.push(obstacle);
if (i % 3 === 0) {
var slowDown = game.addChild(new SlowDown());
slowDown.x = Math.random() * 2048;
slowDown.y = Math.random() * 2732;
obstacles.push(slowDown);
}
}
}
initializeLevel();
// Game update function
game.update = function () {
// Remove tutorial if player moves
if (tutorialOverlay && (player.x !== 2048 / 2 || player.y !== 2732 / 2)) {
if (tutorialOverlay) {
tutorialOverlay.destroy();
tutorialOverlay = null;
}
}
// Check for collisions between player and obstacles
for (var i = 0; i < obstacles.length; i++) {
if (player.intersects(obstacles[i])) {
if (!player.shieldActive) {
// Add animation effect for dodging
LK.effects.flashObject(player, 0x00ff00, 300);
// Add a brief scale animation to indicate successful dodge
player.scaleX = 1.2;
player.scaleY = 1.2;
LK.setTimeout(function () {
player.scaleX = 1.0;
player.scaleY = 1.0;
}, 300);
// Flash screen red for 1 second to indicate collision
LK.effects.flashScreen(0xff0000, 1000);
// Game over
LK.showGameOver();
break;
}
}
}
// Increase level and difficulty after reaching a certain score
if (LK.getScore() >= level * 50) {
level++;
maxObstacles += 5;
maxPowerUps += 2;
initializeLevel();
}
// Check for collisions between player and power-ups
for (var i = 0; i < powerUps.length; i++) {
if (player.intersects(powerUps[i])) {
if (powerUps[i] instanceof SpeedBoost) {
// Increase player speed temporarily
player.speed += 2;
LK.setTimeout(function () {
player.speed -= 2;
}, 5000);
} else if (powerUps[i] instanceof SupplyBox) {
// Declare shield in the global scope
var shield;
// Add shield when supply box is collected
shield = game.addChild(new Shield());
shield.x = player.x;
shield.y = player.y;
player.shieldActive = true;
// Remove shield after 6 seconds
LK.setTimeout(function () {
shield.destroy();
player.shieldActive = false;
}, 6000);
} else {
// Increase score when power-up is collected
LK.setScore(LK.getScore() + 5);
scoreTxt.setText(LK.getScore());
// Flash player green for 500ms to indicate power-up collection
LK.effects.flashObject(player, 0x00ff00, 500);
}
powerUps[i].destroy();
powerUps.splice(i, 1);
}
}
// Check for collisions between player and SlowDown obstacles
for (var i = 0; i < obstacles.length; i++) {
if (player.intersects(obstacles[i]) && obstacles[i] instanceof SlowDown) {
// Decrease player speed temporarily
player.speed -= 2;
LK.setTimeout(function () {
player.speed += 2;
}, 5000);
obstacles[i].destroy();
obstacles.splice(i, 1);
}
}
for (var i = 0; i < obstacles.length; i++) {
if (obstacles[i].y > 2732) {
obstacles[i].passed = true;
LK.setScore(LK.getScore() + 1);
// Add animation effect for score increase
LK.effects.flashObject(scoreTxt, 0xffff00, 300);
// Add a brief scale animation to indicate score increase
scoreTxt.scaleX = 1.2;
scoreTxt.scaleY = 1.2;
LK.setTimeout(function () {
scoreTxt.scaleX = 1.0;
scoreTxt.scaleY = 1.0;
}, 300);
// Update score text and flash to indicate score update
scoreTxt.setText(LK.getScore());
LK.effects.flashObject(scoreTxt, 0xffffff, 500);
}
}
};
// Player movement
game.down = function (x, y, obj) {
player.x = x;
player.y = y;
if (player.shieldActive && typeof shield !== 'undefined') {
shield.x = player.x;
shield.y = player.y;
}
// Play movement sound effect
LK.getSound('move').play();
// Play movement sound effect
LK.getSound('move').play();
};
game.move = function (x, y, obj) {
player.x = x;
player.y = y;
if (player.shieldActive && typeof shield !== 'undefined') {
shield.x = player.x;
shield.y = player.y;
}
};
A small airplane. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
mountain rocks. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gasoline barel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
suggest a bkg for the score. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
the space with stars and planets make it darker. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a booster for plain. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A looping animated GIF of a cosmic scene in deep space, showcasing a vibrant blue and purple galaxy with stars, planets, and comets. The background has swirling nebulae with bright, glowing areas, giving a mystical and expansive feel. Comets move across the scene, leaving trails as they pass, adding a dynamic element to the vast, star-studded universe. The GIF format captures the continuous, endless motion of the comets and stars, evoking a sense of wonder and infinity.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a highly detailed image of a space shuttle top view with no angel soaring through deep space. The shuttle should have a sleek, aerodynamic design with visible engines emitting a faint blue glow. It should feature realistic textures, metallic surfaces, and visible symbols. Make the shuttle color Yellowish. Make it straight going forward. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.