/**** * Classes ****/ // Class for the Alarm display var AlarmDisplay = Container.expand(function () { var self = Container.call(this); self.attachAsset('Alarm', { anchorX: 1.0, // Anchor to the right anchorY: 0.0 // Anchor to the top }); self.x = 2048 - 400; // Position to the left by 400 self.y = 400; // Position down by 400 self.visible = false; // Initially not visible self.show = function () { self.visible = true; var blinkCount = 0; var flashInterval = LK.setInterval(function () { self.visible = !self.visible; if (self.visible) { blinkCount++; } if (blinkCount >= 3) { LK.clearInterval(flashInterval); self.hide(); } }, 1000); }; self.hide = function () { self.visible = false; }; }); // Class for the second Alarm display var AlarmDisplay2 = Container.expand(function () { var self = Container.call(this); self.attachAsset('Alarm2', { anchorX: 1.0, anchorY: 0.0 }); self.x = 2048 - 50; // Position to the right by 50 self.y = 350; // Position down by 350 self.visible = false; // Initially not visible self.show = function () { self.visible = true; var blinkCount = 0; var flashInterval = LK.setInterval(function () { self.visible = !self.visible; if (self.visible) { blinkCount++; } if (blinkCount >= 3) { LK.clearInterval(flashInterval); self.hide(); } }, 1000); }; self.hide = function () { self.visible = false; }; }); // Class for the background var Background = Container.expand(function () { var self = Container.call(this); self.attachAsset('background', { anchorX: 0.5, anchorY: 0.5 }); self.x = 2048 / 2; self.y = 2732 / 2; }); // Class for the second background var Background2 = Container.expand(function () { var self = Container.call(this); self.attachAsset('background2', { anchorX: 0.5, anchorY: 0.5 }); self.x = 2048 / 2; self.y = 2732 - self.height / 2; }); // Class for collapsing cubes with distinct behavior var CollapsingCube = Container.expand(function () { var self = Container.call(this); self.attachAsset('cube_collapse', { anchorX: 0.5, anchorY: 0.5 }); self.isFalling = false; self.velocityY = 0; // Initial vertical velocity for falling cubes self._update_migrated = function () { if (self.isFalling) { self.velocityY += 0.75; // Acceleration due to gravity self.y += self.velocityY; // Fall speed with acceleration } }; }); // Class for individual cubes that can fall var Cube = Container.expand(function () { var self = Container.call(this); self.attachAsset('cube', { anchorX: 0.5, anchorY: 0.5 }); self.isFalling = false; self.velocityY = 0; // Initial vertical velocity for falling cubes self._update_migrated = function () { if (self.isFalling) { self.velocityY += 0.75; // Acceleration due to gravity increased by 50% self.y += self.velocityY; // Fall speed with acceleration } }; }); // Class for fast cubes with distinct behavior var FastCube = Container.expand(function () { var self = Container.call(this); self.attachAsset('cube_fast', { anchorX: 0.5, anchorY: 0.5 }); self.isFalling = false; self.velocityY = 0; // Initial vertical velocity for falling cubes self._update_migrated = function () { if (self.isFalling) { self.velocityY += 0.75; // Acceleration due to gravity self.y += self.velocityY; // Fall speed with acceleration } }; }); // Class for the player's hero var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.isOnGround = false; self.velocityY = 0; self.jump = function () { if (self.isOnGround) { self.velocityY = -15; self.isOnGround = false; } }; self._update_migrated = function () { self.y += self.velocityY; self.velocityY += 0.5; // Gravity effect // Check for collision with cubes and display Alarm or Alarm2 if hit for (var i = 0; i < poles.length; i++) { var pole = poles[i]; for (var j = 0; j < pole.cubes.length; j++) { var cube = pole.cubes[j]; if (cube instanceof CollapsingCube && self.intersects(cube) && !cube.isFalling) { // Make all poles collapse poles.forEach(function (p) { p.makeCubesFall(); }); // Display the Alarm alarmDisplay.show(); break; } else if (cube instanceof FastCube && self.intersects(cube) && !cube.isFalling) { // Display the Alarm2 alarmDisplay2.show(); // Shift the position where cubes start to fall fallStartPositionShift += 250; break; } } } }; }); // Class for the poles consisting of cubes var Pole = Container.expand(function () { var self = Container.call(this); self.cubes = []; self.addCube = function (isCollapsing) { var cube; if (poleCounter >= 100) { if (isCollapsing) { cube = new CollapsingCube(); } else if (poleCounter % 12 === 0) { // Every twelfth pole has a fast cube in front of the player cube = new FastCube(); } else { cube = new Cube(); } } else { cube = new Cube(); } cube.y = -(self.cubes.length * 100) - (self.cubes.length - 1) * 2; self.addChild(cube); self.cubes.push(cube); }; self.makeCubesFall = function () { for (var i = self.cubes.length - 1; i >= 0; i--) { (function (index) { LK.setTimeout(function () { self.cubes[index].isFalling = true; }, index * 250); // Delay between each cube falling })(i); } }; self.isSliding = false; self.slideDownUp = function () { if (!self.isSliding) { self.isSliding = true; var initialY = self.y; var step = 1; var distance = 10; var duration = 200; var steps = duration / (1000 / 60); var stepSize = distance / steps; var currentStep = 0; var slideInterval = LK.setInterval(function () { if (currentStep < steps) { self.y += stepSize; currentStep++; } else { LK.clearInterval(slideInterval); self.y = initialY; self.isSliding = false; } }, 1000 / 60); } }; self.getHeight = function () { return self.cubes.length * 100 + (self.cubes.length - 1) * 2; }; }); // Class for the TimeCounter display var TimeCounter = Container.expand(function () { var self = Container.call(this); self.startTime = Date.now(); self.timeText = new Text2('0', { size: 100, fill: 0xFFFFFF }); self.addChild(self.timeText); self.timeText.anchor.set(1, 0); // Anchor to the top-right self.timeText.x = 2048; // Position to the right self.timeText.y = 0; // Position at the top self._update_migrated = function () { var currentTime = Date.now(); var timeElapsed = ((currentTime - self.startTime) / 1000).toFixed(2); // Time in seconds self.timeText.setText(timeElapsed + 's'); // Update the text display }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Instantiate AlarmDisplay var alarmDisplay = game.addChild(new AlarmDisplay()); // Set the zIndex to ensure it's on top alarmDisplay.zIndex = 1; // Instantiate TimeCounter var timeCounter = game.addChild(new TimeCounter()); // Set the zIndex to ensure it's on top of all layers timeCounter.zIndex = 2; // Instantiate AlarmDisplay2 var alarmDisplay2 = game.addChild(new AlarmDisplay2()); // Set the zIndex to ensure it's on top alarmDisplay2.zIndex = 1; // Create the second background var background2 = game.addChild(new Background2()); background2.zIndex = -1; // Create the background var background = game.addChild(new Background()); background.zIndex = 0; // Initialize assets used in the game. // Initialize important asset arrays var poles = []; var poleCounter = 0; var hero; var fallStartPositionShift = 0; var resetFallPositionTimeoutSet = false; // Create the hero hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 150; // Start above the bottom of the screen // Create initial poles function createInitialPoles() { var poleSpacing = 2; var poleWidth = 100 + poleSpacing; var numPoles = Math.ceil(2048 / poleWidth); for (var i = 0; i < numPoles; i++) { var pole = game.addChild(new Pole()); pole.x = i * poleWidth; pole.y = 2732 - 50; // Align base of pole with bottom of the screen and raise by 50 pixels for (var j = 0; j < 10; j++) { // Add 9 cubes to each pole and one collapsing cube every 50 poles var isCollapsing = poleCounter % 17 === 0 && j === 9; // Make the top cube a collapsing cube every 50 poles pole.addCube(isCollapsing); } poleCounter++; poles.push(pole); } } createInitialPoles(); // Event listener for jump action game.on('down', function (x, y, obj) { hero.jump(); }); // Game tick update LK.on('tick', function () { timeCounter._update_migrated(); hero._update_migrated(); // Collision detection with poles for (var i = 0; i < poles.length; i++) { var pole = poles[i]; if (hero.intersects(pole) && hero.velocityY > 0 && hero.y + hero.height / 2 < pole.y) { hero.y = pole.y - pole.getHeight() - hero.height / 2; hero.isOnGround = true; hero.velocityY = 0; pole.slideDownUp(); } } // Remove off-screen poles and create new ones var poleSpacing = 2; var poleWidth = 100 + poleSpacing; if (poles.length > 0 && poles[0].x + poleWidth / 2 < 0) { poles[0].destroy(); poles.shift(); var newPole = game.addChild(new Pole()); newPole.x = poles[poles.length - 1].x + poleWidth; newPole.y = 2732 - 50; var isCollapsingCube = poleCounter % 50 === 0; // Determine if the new pole should have a collapsing cube poleCounter++; var prevPoleHeight = poles[poles.length - 1].cubes.length; var minCubes = Math.max(6, prevPoleHeight - 1); var maxCubes = Math.min(14, prevPoleHeight + 1); var cubesCount = Math.floor(Math.random() * (maxCubes - minCubes + 1)) + minCubes; for (var j = 0; j < cubesCount; j++) { // Add collapsing cube every 50 poles on the top var isCollapsing = isCollapsingCube && j === cubesCount - 1; newPole.addCube(isCollapsing); } poles.push(newPole); } // Move poles to the left to simulate hero running and make cubes fall after passing the middle for (var i = 0; i < poles.length; i++) { poles[i].x -= 5; if (poles[i].x < 2048 / 2 + fallStartPositionShift && !poles[i].hasMadeCubesFall) { poles[i].makeCubesFall(); poles[i].hasMadeCubesFall = true; } // Update each cube in the pole for (var j = 0; j < poles[i].cubes.length; j++) { poles[i].cubes[j]._update_migrated(); } } // Reset fallStartPositionShift after 20 seconds if (!resetFallPositionTimeoutSet) { resetFallPositionTimeoutSet = true; LK.setTimeout(function () { fallStartPositionShift = 0; resetFallPositionTimeoutSet = false; }, 20000); } // End the game if the hero falls off the bottom of the screen if (hero.y > 2732) { LK.showGameOver(); } });
/****
* Classes
****/
// Class for the Alarm display
var AlarmDisplay = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('Alarm', {
anchorX: 1.0,
// Anchor to the right
anchorY: 0.0 // Anchor to the top
});
self.x = 2048 - 400; // Position to the left by 400
self.y = 400; // Position down by 400
self.visible = false; // Initially not visible
self.show = function () {
self.visible = true;
var blinkCount = 0;
var flashInterval = LK.setInterval(function () {
self.visible = !self.visible;
if (self.visible) {
blinkCount++;
}
if (blinkCount >= 3) {
LK.clearInterval(flashInterval);
self.hide();
}
}, 1000);
};
self.hide = function () {
self.visible = false;
};
});
// Class for the second Alarm display
var AlarmDisplay2 = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('Alarm2', {
anchorX: 1.0,
anchorY: 0.0
});
self.x = 2048 - 50; // Position to the right by 50
self.y = 350; // Position down by 350
self.visible = false; // Initially not visible
self.show = function () {
self.visible = true;
var blinkCount = 0;
var flashInterval = LK.setInterval(function () {
self.visible = !self.visible;
if (self.visible) {
blinkCount++;
}
if (blinkCount >= 3) {
LK.clearInterval(flashInterval);
self.hide();
}
}, 1000);
};
self.hide = function () {
self.visible = false;
};
});
// Class for the background
var Background = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2;
self.y = 2732 / 2;
});
// Class for the second background
var Background2 = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('background2', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2;
self.y = 2732 - self.height / 2;
});
// Class for collapsing cubes with distinct behavior
var CollapsingCube = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('cube_collapse', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFalling = false;
self.velocityY = 0; // Initial vertical velocity for falling cubes
self._update_migrated = function () {
if (self.isFalling) {
self.velocityY += 0.75; // Acceleration due to gravity
self.y += self.velocityY; // Fall speed with acceleration
}
};
});
// Class for individual cubes that can fall
var Cube = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('cube', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFalling = false;
self.velocityY = 0; // Initial vertical velocity for falling cubes
self._update_migrated = function () {
if (self.isFalling) {
self.velocityY += 0.75; // Acceleration due to gravity increased by 50%
self.y += self.velocityY; // Fall speed with acceleration
}
};
});
// Class for fast cubes with distinct behavior
var FastCube = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('cube_fast', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFalling = false;
self.velocityY = 0; // Initial vertical velocity for falling cubes
self._update_migrated = function () {
if (self.isFalling) {
self.velocityY += 0.75; // Acceleration due to gravity
self.y += self.velocityY; // Fall speed with acceleration
}
};
});
// Class for the player's hero
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.isOnGround = false;
self.velocityY = 0;
self.jump = function () {
if (self.isOnGround) {
self.velocityY = -15;
self.isOnGround = false;
}
};
self._update_migrated = function () {
self.y += self.velocityY;
self.velocityY += 0.5; // Gravity effect
// Check for collision with cubes and display Alarm or Alarm2 if hit
for (var i = 0; i < poles.length; i++) {
var pole = poles[i];
for (var j = 0; j < pole.cubes.length; j++) {
var cube = pole.cubes[j];
if (cube instanceof CollapsingCube && self.intersects(cube) && !cube.isFalling) {
// Make all poles collapse
poles.forEach(function (p) {
p.makeCubesFall();
});
// Display the Alarm
alarmDisplay.show();
break;
} else if (cube instanceof FastCube && self.intersects(cube) && !cube.isFalling) {
// Display the Alarm2
alarmDisplay2.show();
// Shift the position where cubes start to fall
fallStartPositionShift += 250;
break;
}
}
}
};
});
// Class for the poles consisting of cubes
var Pole = Container.expand(function () {
var self = Container.call(this);
self.cubes = [];
self.addCube = function (isCollapsing) {
var cube;
if (poleCounter >= 100) {
if (isCollapsing) {
cube = new CollapsingCube();
} else if (poleCounter % 12 === 0) {
// Every twelfth pole has a fast cube in front of the player
cube = new FastCube();
} else {
cube = new Cube();
}
} else {
cube = new Cube();
}
cube.y = -(self.cubes.length * 100) - (self.cubes.length - 1) * 2;
self.addChild(cube);
self.cubes.push(cube);
};
self.makeCubesFall = function () {
for (var i = self.cubes.length - 1; i >= 0; i--) {
(function (index) {
LK.setTimeout(function () {
self.cubes[index].isFalling = true;
}, index * 250); // Delay between each cube falling
})(i);
}
};
self.isSliding = false;
self.slideDownUp = function () {
if (!self.isSliding) {
self.isSliding = true;
var initialY = self.y;
var step = 1;
var distance = 10;
var duration = 200;
var steps = duration / (1000 / 60);
var stepSize = distance / steps;
var currentStep = 0;
var slideInterval = LK.setInterval(function () {
if (currentStep < steps) {
self.y += stepSize;
currentStep++;
} else {
LK.clearInterval(slideInterval);
self.y = initialY;
self.isSliding = false;
}
}, 1000 / 60);
}
};
self.getHeight = function () {
return self.cubes.length * 100 + (self.cubes.length - 1) * 2;
};
});
// Class for the TimeCounter display
var TimeCounter = Container.expand(function () {
var self = Container.call(this);
self.startTime = Date.now();
self.timeText = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
self.addChild(self.timeText);
self.timeText.anchor.set(1, 0); // Anchor to the top-right
self.timeText.x = 2048; // Position to the right
self.timeText.y = 0; // Position at the top
self._update_migrated = function () {
var currentTime = Date.now();
var timeElapsed = ((currentTime - self.startTime) / 1000).toFixed(2); // Time in seconds
self.timeText.setText(timeElapsed + 's'); // Update the text display
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Instantiate AlarmDisplay
var alarmDisplay = game.addChild(new AlarmDisplay());
// Set the zIndex to ensure it's on top
alarmDisplay.zIndex = 1;
// Instantiate TimeCounter
var timeCounter = game.addChild(new TimeCounter());
// Set the zIndex to ensure it's on top of all layers
timeCounter.zIndex = 2;
// Instantiate AlarmDisplay2
var alarmDisplay2 = game.addChild(new AlarmDisplay2());
// Set the zIndex to ensure it's on top
alarmDisplay2.zIndex = 1;
// Create the second background
var background2 = game.addChild(new Background2());
background2.zIndex = -1;
// Create the background
var background = game.addChild(new Background());
background.zIndex = 0;
// Initialize assets used in the game.
// Initialize important asset arrays
var poles = [];
var poleCounter = 0;
var hero;
var fallStartPositionShift = 0;
var resetFallPositionTimeoutSet = false;
// Create the hero
hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 150; // Start above the bottom of the screen
// Create initial poles
function createInitialPoles() {
var poleSpacing = 2;
var poleWidth = 100 + poleSpacing;
var numPoles = Math.ceil(2048 / poleWidth);
for (var i = 0; i < numPoles; i++) {
var pole = game.addChild(new Pole());
pole.x = i * poleWidth;
pole.y = 2732 - 50; // Align base of pole with bottom of the screen and raise by 50 pixels
for (var j = 0; j < 10; j++) {
// Add 9 cubes to each pole and one collapsing cube every 50 poles
var isCollapsing = poleCounter % 17 === 0 && j === 9; // Make the top cube a collapsing cube every 50 poles
pole.addCube(isCollapsing);
}
poleCounter++;
poles.push(pole);
}
}
createInitialPoles();
// Event listener for jump action
game.on('down', function (x, y, obj) {
hero.jump();
});
// Game tick update
LK.on('tick', function () {
timeCounter._update_migrated();
hero._update_migrated();
// Collision detection with poles
for (var i = 0; i < poles.length; i++) {
var pole = poles[i];
if (hero.intersects(pole) && hero.velocityY > 0 && hero.y + hero.height / 2 < pole.y) {
hero.y = pole.y - pole.getHeight() - hero.height / 2;
hero.isOnGround = true;
hero.velocityY = 0;
pole.slideDownUp();
}
}
// Remove off-screen poles and create new ones
var poleSpacing = 2;
var poleWidth = 100 + poleSpacing;
if (poles.length > 0 && poles[0].x + poleWidth / 2 < 0) {
poles[0].destroy();
poles.shift();
var newPole = game.addChild(new Pole());
newPole.x = poles[poles.length - 1].x + poleWidth;
newPole.y = 2732 - 50;
var isCollapsingCube = poleCounter % 50 === 0; // Determine if the new pole should have a collapsing cube
poleCounter++;
var prevPoleHeight = poles[poles.length - 1].cubes.length;
var minCubes = Math.max(6, prevPoleHeight - 1);
var maxCubes = Math.min(14, prevPoleHeight + 1);
var cubesCount = Math.floor(Math.random() * (maxCubes - minCubes + 1)) + minCubes;
for (var j = 0; j < cubesCount; j++) {
// Add collapsing cube every 50 poles on the top
var isCollapsing = isCollapsingCube && j === cubesCount - 1;
newPole.addCube(isCollapsing);
}
poles.push(newPole);
}
// Move poles to the left to simulate hero running and make cubes fall after passing the middle
for (var i = 0; i < poles.length; i++) {
poles[i].x -= 5;
if (poles[i].x < 2048 / 2 + fallStartPositionShift && !poles[i].hasMadeCubesFall) {
poles[i].makeCubesFall();
poles[i].hasMadeCubesFall = true;
}
// Update each cube in the pole
for (var j = 0; j < poles[i].cubes.length; j++) {
poles[i].cubes[j]._update_migrated();
}
}
// Reset fallStartPositionShift after 20 seconds
if (!resetFallPositionTimeoutSet) {
resetFallPositionTimeoutSet = true;
LK.setTimeout(function () {
fallStartPositionShift = 0;
resetFallPositionTimeoutSet = false;
}, 20000);
}
// End the game if the hero falls off the bottom of the screen
if (hero.y > 2732) {
LK.showGameOver();
}
});
"ALARM" text bubble, comic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
"ALARM" text bubble yellow, comic book style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cinematic sci-fi background set in deep space, featuring the iconic Death Star looming in the distance with dramatic lighting. The foreground includes distant Rebel or Imperial starfighters flying across the stars, with a nebula glowing behind them in shades of blue, purple, and black. The Death Star is partially in shadow, with visible surface details like trenches and superlaser dish glowing faintly. Stars and cosmic dust fill the background, adding depth and realism. The mood is epic and mysterious, perfect for a Star Wars-themed environment. 4K resolution, widescreen layout, concept art style, high detail, suitable as a desktop or game background.. In-Game asset. 2d. High contrast. No shadows
A stylized app or game icon featuring the head of a compact, dome-shaped sci-fi droid. The droid has a shiny metallic silver and blue color scheme, a round central photoreceptor "eye," and various small lights, sensors, and panels. The design is friendly and futuristic, with clean mechanical details and a slightly worn metallic finish. The background is dark or softly glowing with blue tones, highlighting the droidโs silhouette. Square or circular layout, 1024x1024 resolution, high detail, concept art style. Inspired by classic sci-fi utility robots, fully original and suitable for use without copyright concerns.. In-Game asset. 2d. High contrast. No shadows
A stylized icon featuring the head of a spherical sci-fi droid. The droid has a sleek, white dome-shaped head with orange and silver accents, a central black photoreceptor eye, and a few small antennae. Its design is clean, compact, and friendly, with a glossy, slightly weathered finish that suggests it's a field robot. The background is minimal, with soft glows or circuit-inspired patterns in warm tones to contrast the droid's colors. Designed to be clear and recognizable at small sizes. Circular or square layout, 1024x1024 resolution, high detail, sci-fi concept art style. Inspired by modern robotic companions, fully original and copyright-safe.. In-Game asset. 2d. High contrast. No shadows
A bold and stylized game or app icon featuring the iconic helmet of a Stormtrooper from Star Wars. The white armor helmet is centered in the frame, with clean black details and glossy reflections, capturing the symmetrical and intimidating look. The background is dark or slightly textured with subtle sci-fi elements like grid lines or stars, to enhance contrast and focus on the helmet. Designed for clarity at small sizes, with strong outlines and a balanced composition. Square or circular layout, 1024x1024 resolution, high detail, sci-fi concept art style, minimal and recognizable.. In-Game asset. 2d. High contrast. No shadows
add yellow frame and star details
death star. In-Game asset. 2d. High contrast. No shadows