/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.direction = Math.random() < 0.5 ? -1 : 1;
self.horizontalSpeed = Math.random() * 2 + 1;
self.update = function () {
self.y += self.speed;
self.x += self.direction * self.horizontalSpeed;
// Bounce off screen edges
if (self.x < 30 || self.x > 2018) {
self.direction *= -1;
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var shipGraphics = self.attachAsset('playerShip', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var PlayerBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('playerBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -12;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starType = Math.random() < 0.8 ? 'star' : 'bigStar';
var starGraphics = self.attachAsset(starType, {
anchorX: 0.5,
anchorY: 0.5
});
starGraphics.alpha = Math.random() * 0.8 + 0.2;
self.speed = Math.random() * 2 + 1;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000033
});
/****
* Game Code
****/
// Create thumbnail starfield background with more stars for visual appeal
var stars = [];
var starSpawnRate = 5; // Stars per frame
// Initialize dense starfield for thumbnail
for (var s = 0; s < 200; s++) {
var newStar = new Star();
newStar.x = Math.random() * 2048;
newStar.y = Math.random() * 2732;
newStar.lastY = newStar.y;
// Make stars more visible for thumbnail
var starGraphics = newStar.children[0];
if (starGraphics) {
starGraphics.alpha = Math.random() * 0.6 + 0.4; // Brighter stars
}
stars.push(newStar);
game.addChild(newStar);
}
var player = game.addChild(new Player());
player.x = 1024;
player.y = 2200; // Position higher for better thumbnail visibility
// Scale up player ship for thumbnail prominence
player.scaleX = 1.5;
player.scaleY = 1.5;
var bullets = [];
var enemies = [];
var gameSpeed = 1;
var enemySpawnRate = 120;
var lastEnemySpawn = 0;
// Add thumbnail enemies for dramatic effect
for (var e = 0; e < 6; e++) {
var thumbnailEnemy = new Enemy();
thumbnailEnemy.x = 200 + e * 300;
thumbnailEnemy.y = 400 + e % 2 * 200;
thumbnailEnemy.scaleX = 1.2;
thumbnailEnemy.scaleY = 1.2;
enemies.push(thumbnailEnemy);
game.addChild(thumbnailEnemy);
}
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 50;
// Add thumbnail bullets for action effect
for (var b = 0; b < 8; b++) {
var thumbnailBullet = new PlayerBullet();
thumbnailBullet.x = player.x + (b - 4) * 30;
thumbnailBullet.y = player.y - 100 - b * 80;
thumbnailBullet.scaleX = 1.3;
thumbnailBullet.scaleY = 1.3;
bullets.push(thumbnailBullet);
game.addChild(thumbnailBullet);
}
// Auto-fire bullets
var bulletTimer = LK.setInterval(function () {
var newBullet = new PlayerBullet();
newBullet.x = player.x;
newBullet.y = player.y - 40;
newBullet.lastY = newBullet.y;
bullets.push(newBullet);
game.addChild(newBullet);
LK.getSound('shoot').play();
}, 150);
function handleMove(x, y, obj) {
player.x = x;
// Keep player within screen bounds
if (player.x < 40) player.x = 40;
if (player.x > 2008) player.x = 2008;
}
game.move = handleMove;
game.down = function (x, y, obj) {
handleMove(x, y, obj);
};
// Start retro space music
LK.playMusic('retroSpaceMusic');
game.update = function () {
// Update and spawn stars
for (var s = stars.length - 1; s >= 0; s--) {
var star = stars[s];
if (star.lastY === undefined) star.lastY = star.y;
// Remove stars that go off screen
if (star.lastY <= 2732 && star.y > 2732) {
star.destroy();
stars.splice(s, 1);
continue;
}
star.lastY = star.y;
}
// Spawn new stars at top
if (LK.ticks % starSpawnRate === 0) {
var newStar = new Star();
newStar.x = Math.random() * 2048;
newStar.y = -10;
newStar.lastY = newStar.y;
stars.push(newStar);
game.addChild(newStar);
}
// Spawn enemies
if (LK.ticks - lastEnemySpawn > enemySpawnRate) {
var newEnemy = new Enemy();
newEnemy.x = Math.random() * (2048 - 120) + 60;
newEnemy.y = -30;
newEnemy.lastY = newEnemy.y;
newEnemy.lastIntersecting = false;
enemies.push(newEnemy);
game.addChild(newEnemy);
lastEnemySpawn = LK.ticks;
// Increase difficulty over time
if (enemySpawnRate > 40) {
enemySpawnRate -= 0.5;
}
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (bullet.lastY === undefined) bullet.lastY = bullet.y;
// Remove bullets that go off screen
if (bullet.lastY >= -10 && bullet.y < -10) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check bullet-enemy collisions
var bulletHit = false;
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
// Destroy both bullet and enemy
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
bullet.destroy();
bullets.splice(i, 1);
enemy.destroy();
enemies.splice(j, 1);
LK.getSound('enemyDestroy').play();
bulletHit = true;
break;
}
}
if (!bulletHit) {
bullet.lastY = bullet.y;
}
}
// Update enemies
for (var k = enemies.length - 1; k >= 0; k--) {
var enemy = enemies[k];
if (enemy.lastY === undefined) enemy.lastY = enemy.y;
if (enemy.lastIntersecting === undefined) enemy.lastIntersecting = false;
// Remove enemies that go off screen
if (enemy.lastY <= 2732 && enemy.y > 2732) {
enemy.destroy();
enemies.splice(k, 1);
continue;
}
// Check player-enemy collision
var currentIntersecting = enemy.intersects(player);
if (!enemy.lastIntersecting && currentIntersecting) {
LK.getSound('playerHit').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
enemy.lastY = enemy.y;
enemy.lastIntersecting = currentIntersecting;
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.direction = Math.random() < 0.5 ? -1 : 1;
self.horizontalSpeed = Math.random() * 2 + 1;
self.update = function () {
self.y += self.speed;
self.x += self.direction * self.horizontalSpeed;
// Bounce off screen edges
if (self.x < 30 || self.x > 2018) {
self.direction *= -1;
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var shipGraphics = self.attachAsset('playerShip', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var PlayerBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('playerBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -12;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starType = Math.random() < 0.8 ? 'star' : 'bigStar';
var starGraphics = self.attachAsset(starType, {
anchorX: 0.5,
anchorY: 0.5
});
starGraphics.alpha = Math.random() * 0.8 + 0.2;
self.speed = Math.random() * 2 + 1;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000033
});
/****
* Game Code
****/
// Create thumbnail starfield background with more stars for visual appeal
var stars = [];
var starSpawnRate = 5; // Stars per frame
// Initialize dense starfield for thumbnail
for (var s = 0; s < 200; s++) {
var newStar = new Star();
newStar.x = Math.random() * 2048;
newStar.y = Math.random() * 2732;
newStar.lastY = newStar.y;
// Make stars more visible for thumbnail
var starGraphics = newStar.children[0];
if (starGraphics) {
starGraphics.alpha = Math.random() * 0.6 + 0.4; // Brighter stars
}
stars.push(newStar);
game.addChild(newStar);
}
var player = game.addChild(new Player());
player.x = 1024;
player.y = 2200; // Position higher for better thumbnail visibility
// Scale up player ship for thumbnail prominence
player.scaleX = 1.5;
player.scaleY = 1.5;
var bullets = [];
var enemies = [];
var gameSpeed = 1;
var enemySpawnRate = 120;
var lastEnemySpawn = 0;
// Add thumbnail enemies for dramatic effect
for (var e = 0; e < 6; e++) {
var thumbnailEnemy = new Enemy();
thumbnailEnemy.x = 200 + e * 300;
thumbnailEnemy.y = 400 + e % 2 * 200;
thumbnailEnemy.scaleX = 1.2;
thumbnailEnemy.scaleY = 1.2;
enemies.push(thumbnailEnemy);
game.addChild(thumbnailEnemy);
}
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 50;
// Add thumbnail bullets for action effect
for (var b = 0; b < 8; b++) {
var thumbnailBullet = new PlayerBullet();
thumbnailBullet.x = player.x + (b - 4) * 30;
thumbnailBullet.y = player.y - 100 - b * 80;
thumbnailBullet.scaleX = 1.3;
thumbnailBullet.scaleY = 1.3;
bullets.push(thumbnailBullet);
game.addChild(thumbnailBullet);
}
// Auto-fire bullets
var bulletTimer = LK.setInterval(function () {
var newBullet = new PlayerBullet();
newBullet.x = player.x;
newBullet.y = player.y - 40;
newBullet.lastY = newBullet.y;
bullets.push(newBullet);
game.addChild(newBullet);
LK.getSound('shoot').play();
}, 150);
function handleMove(x, y, obj) {
player.x = x;
// Keep player within screen bounds
if (player.x < 40) player.x = 40;
if (player.x > 2008) player.x = 2008;
}
game.move = handleMove;
game.down = function (x, y, obj) {
handleMove(x, y, obj);
};
// Start retro space music
LK.playMusic('retroSpaceMusic');
game.update = function () {
// Update and spawn stars
for (var s = stars.length - 1; s >= 0; s--) {
var star = stars[s];
if (star.lastY === undefined) star.lastY = star.y;
// Remove stars that go off screen
if (star.lastY <= 2732 && star.y > 2732) {
star.destroy();
stars.splice(s, 1);
continue;
}
star.lastY = star.y;
}
// Spawn new stars at top
if (LK.ticks % starSpawnRate === 0) {
var newStar = new Star();
newStar.x = Math.random() * 2048;
newStar.y = -10;
newStar.lastY = newStar.y;
stars.push(newStar);
game.addChild(newStar);
}
// Spawn enemies
if (LK.ticks - lastEnemySpawn > enemySpawnRate) {
var newEnemy = new Enemy();
newEnemy.x = Math.random() * (2048 - 120) + 60;
newEnemy.y = -30;
newEnemy.lastY = newEnemy.y;
newEnemy.lastIntersecting = false;
enemies.push(newEnemy);
game.addChild(newEnemy);
lastEnemySpawn = LK.ticks;
// Increase difficulty over time
if (enemySpawnRate > 40) {
enemySpawnRate -= 0.5;
}
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (bullet.lastY === undefined) bullet.lastY = bullet.y;
// Remove bullets that go off screen
if (bullet.lastY >= -10 && bullet.y < -10) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check bullet-enemy collisions
var bulletHit = false;
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
// Destroy both bullet and enemy
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
bullet.destroy();
bullets.splice(i, 1);
enemy.destroy();
enemies.splice(j, 1);
LK.getSound('enemyDestroy').play();
bulletHit = true;
break;
}
}
if (!bulletHit) {
bullet.lastY = bullet.y;
}
}
// Update enemies
for (var k = enemies.length - 1; k >= 0; k--) {
var enemy = enemies[k];
if (enemy.lastY === undefined) enemy.lastY = enemy.y;
if (enemy.lastIntersecting === undefined) enemy.lastIntersecting = false;
// Remove enemies that go off screen
if (enemy.lastY <= 2732 && enemy.y > 2732) {
enemy.destroy();
enemies.splice(k, 1);
continue;
}
// Check player-enemy collision
var currentIntersecting = enemy.intersects(player);
if (!enemy.lastIntersecting && currentIntersecting) {
LK.getSound('playerHit').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
enemy.lastY = enemy.y;
enemy.lastIntersecting = currentIntersecting;
}
};
A ufo that’s triangle shape. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
a triangle. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
A evil robot. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat