/**** * Classes ****/ var Enemy1 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy1', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self._move_migrated = function () { self.y += self.speed; }; }); var Enemy2 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy2', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self._move_migrated = function () { self.y += self.speed; }; }); var Enemy3 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy3', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self._move_migrated = function () { self.y += self.speed; }; }); var Enemy4 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy4', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self._move_migrated = function () { self.y += self.speed; }; }); var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self._move_migrated = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); var HealthDisplay = Container.expand(function () { var self = Container.call(this); self.healthCircles = []; for (var i = 0; i < 3; i++) { var healthCircle = self.attachAsset('healthCircle', {}); healthCircle.x = i * 100; self.healthCircles.push(healthCircle); self.addChild(healthCircle); } self.updateHealth = function (health) { for (var i = 0; i < self.healthCircles.length; i++) { self.healthCircles[i].alpha = i < health ? 1 : 0.5; } }; }); var Hero = Container.expand(function () { var self = Container.call(this); self.health = 3; var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.bulletSpeed = 10; self.lastBulletTime = 0; self._move_migrated = function () {}; self.fire = function () { var bullet = new HeroBullet(); bullet.x = self.x; bullet.y = self.y; bullet.speed = self.bulletSpeed; heroBullets.push(bullet); self.parent.addChild(bullet); }; }); var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('heroBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 20; // Increase the speed to 20 self._move_migrated = function () { self.y -= self.speed; // Update movement logic to move upwards }; }); var SpecialItem = Container.expand(function () { var self = Container.call(this); var itemGraphics = self.attachAsset('specialItem', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -2; self._move_migrated = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var bg = game.attachAsset('background', {}); bg.width = 2048; bg.height = 2732; bg.alpha = 0.5; var bg2 = game.attachAsset('background', {}); bg2.width = 2048; bg2.height = 2732; bg2.y = -2732; bg2.alpha = 0.5; var hero = game.addChild(new Hero()); var healthDisplay = new HealthDisplay(); healthDisplay.y += 50; LK.gui.topLeft.addChild(healthDisplay); var enemies = []; var heroBullets = []; var enemyBullets = []; var specialItems = []; hero.x = 2048 / 2; hero.y = 2732 - 200; var spawnEnemy = function spawnEnemy() { var enemyType = Math.floor(Math.random() * 3); var enemy; switch (enemyType) { case 0: enemy = new Enemy1(); break; case 1: enemy = new Enemy2(); break; case 2: enemy = new Enemy3(); break; } enemy.x = Math.random() * 2048; enemy.y = 0; enemies.push(enemy); game.addChild(enemy); }; var spawnHeroBullet = function spawnHeroBullet() { // Left bullet var leftBullet = new HeroBullet(); leftBullet.x = hero.x - 100; // Increase the offset to the left (100 pixels) leftBullet.y = hero.y; leftBullet._move_migrated = function () { leftBullet.y -= leftBullet.speed; }; heroBullets.push(leftBullet); LK.getSound('Herobullet').play(); game.addChild(leftBullet); // Right bullet var rightBullet = new HeroBullet(); rightBullet.x = hero.x + 100; // Increase the offset to the right (100 pixels) rightBullet.y = hero.y; rightBullet._move_migrated = function () { rightBullet.y -= rightBullet.speed; }; heroBullets.push(rightBullet); LK.getSound('Herobullet').play(); game.addChild(rightBullet); }; var spawnSpecialItem = function spawnSpecialItem() { var item = new SpecialItem(); item.x = Math.random() * 2048; item.y = 0; specialItems.push(item); game.addChild(item); item.on('down', function () { enemyBullets.forEach(function (bullet, index) { bullet.destroy(); enemyBullets.splice(index, 1); }); }); }; var spawnEnemyBullet = function spawnEnemyBullet(enemy) { var bullet = new EnemyBullet(); bullet.x = enemy.x; bullet.y = enemy.y; bullet._move_migrated = function () { bullet.y += bullet.speed; }; enemyBullets.push(bullet); game.addChild(bullet); }; var checkCollision = function checkCollision() { specialItems.forEach(function (item, index) { if (hero.intersects(item)) { item.destroy(); specialItems.splice(index, 1); hero.bulletSpeed = 15; LK.setTimeout(function () { hero.bulletSpeed = 10; }, 4000); } }); }; var gameOver = function gameOver() {}; LK.on('tick', function () { bg.y += 2; bg2.y += 2; if (bg.y >= 2732) { bg.y = -2732; } if (bg2.y >= 2732) { bg2.y = -2732; } hero._move_migrated(); healthDisplay.updateHealth(hero.health); enemies.forEach(function (enemy, index) { enemy._move_migrated(); if (LK.ticks % 120 === 0 && enemy.y > 0) { spawnEnemyBullet(enemy); } if (enemy.y > 2732) { enemy.destroy(); enemies.splice(index, 1); } }); heroBullets.forEach(function (bullet, index) { bullet._move_migrated(); if (bullet.y < 0) { bullet.destroy(); heroBullets.splice(index, 1); } }); enemyBullets.forEach(function (bullet, index) { bullet._move_migrated(); if (bullet.y > 2732) { bullet.destroy(); enemyBullets.splice(index, 1); } }); specialItems.forEach(function (item, index) { item._move_migrated(); if (item.y > 2732) { item.destroy(); specialItems.splice(index, 1); } }); checkCollision(); heroBullets.forEach(function (bullet, bIndex) { enemies.forEach(function (enemy, eIndex) { if (bullet.intersects(enemy)) { bullet.destroy(); heroBullets.splice(bIndex, 1); LK.getSound('Exploding').play(); var explosion = game.attachAsset('explosion', { anchorX: 0.5, anchorY: 0.5 }); explosion.x = enemy.x; explosion.y = enemy.y; game.addChild(explosion); LK.setTimeout(function () { explosion.destroy(); }, 500); enemy.destroy(); enemies.splice(eIndex, 1); } }); }); enemyBullets.forEach(function (bullet, index) { if (hero.intersects(bullet)) { bullet.destroy(); enemyBullets.splice(index, 1); hero.health--; healthDisplay.updateHealth(hero.health); if (hero.health <= 0) { LK.showGameOver(); } } }); }); LK.on('tick', function () { if (LK.ticks % 600 === 0) { spawnSpecialItem(); } if (LK.ticks % 384 === 0) { spawnEnemy(); } }); var dragHero = null; game.on('down', function (x, y, obj) { dragHero = hero; if (LK.ticks - hero.lastBulletTime >= 60) { hero.lastBulletTime = LK.ticks; spawnHeroBullet(); spawnHeroBullet(); spawnHeroBullet(); } }); game.on('move', function (x, y, obj) { if (dragHero) { var pos = game.toLocal(obj.global); var oldX = dragHero.x; dragHero.x = pos.x; dragHero.y = pos.y; var tilt = (dragHero.x - oldX) * 0.05; tilt = Math.max(-0.5, Math.min(0.5, tilt)); hero.rotation = tilt; if (LK.ticks - hero.lastBulletTime >= 60) { hero.lastBulletTime = LK.ticks; spawnHeroBullet(); spawnHeroBullet(); spawnHeroBullet(); } } }); game.on('up', function (x, y, obj) { dragHero = null; });
/****
* Classes
****/
var Enemy1 = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy1', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self._move_migrated = function () {
self.y += self.speed;
};
});
var Enemy2 = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy2', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self._move_migrated = function () {
self.y += self.speed;
};
});
var Enemy3 = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy3', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self._move_migrated = function () {
self.y += self.speed;
};
});
var Enemy4 = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy4', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self._move_migrated = function () {
self.y += self.speed;
};
});
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('enemyBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self._move_migrated = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
});
var HealthDisplay = Container.expand(function () {
var self = Container.call(this);
self.healthCircles = [];
for (var i = 0; i < 3; i++) {
var healthCircle = self.attachAsset('healthCircle', {});
healthCircle.x = i * 100;
self.healthCircles.push(healthCircle);
self.addChild(healthCircle);
}
self.updateHealth = function (health) {
for (var i = 0; i < self.healthCircles.length; i++) {
self.healthCircles[i].alpha = i < health ? 1 : 0.5;
}
};
});
var Hero = Container.expand(function () {
var self = Container.call(this);
self.health = 3;
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.bulletSpeed = 10;
self.lastBulletTime = 0;
self._move_migrated = function () {};
self.fire = function () {
var bullet = new HeroBullet();
bullet.x = self.x;
bullet.y = self.y;
bullet.speed = self.bulletSpeed;
heroBullets.push(bullet);
self.parent.addChild(bullet);
};
});
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('heroBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 20; // Increase the speed to 20
self._move_migrated = function () {
self.y -= self.speed; // Update movement logic to move upwards
};
});
var SpecialItem = Container.expand(function () {
var self = Container.call(this);
var itemGraphics = self.attachAsset('specialItem', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -2;
self._move_migrated = function () {
self.y += self.speed;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
var bg = game.attachAsset('background', {});
bg.width = 2048;
bg.height = 2732;
bg.alpha = 0.5;
var bg2 = game.attachAsset('background', {});
bg2.width = 2048;
bg2.height = 2732;
bg2.y = -2732;
bg2.alpha = 0.5;
var hero = game.addChild(new Hero());
var healthDisplay = new HealthDisplay();
healthDisplay.y += 50;
LK.gui.topLeft.addChild(healthDisplay);
var enemies = [];
var heroBullets = [];
var enemyBullets = [];
var specialItems = [];
hero.x = 2048 / 2;
hero.y = 2732 - 200;
var spawnEnemy = function spawnEnemy() {
var enemyType = Math.floor(Math.random() * 3);
var enemy;
switch (enemyType) {
case 0:
enemy = new Enemy1();
break;
case 1:
enemy = new Enemy2();
break;
case 2:
enemy = new Enemy3();
break;
}
enemy.x = Math.random() * 2048;
enemy.y = 0;
enemies.push(enemy);
game.addChild(enemy);
};
var spawnHeroBullet = function spawnHeroBullet() {
// Left bullet
var leftBullet = new HeroBullet();
leftBullet.x = hero.x - 100; // Increase the offset to the left (100 pixels)
leftBullet.y = hero.y;
leftBullet._move_migrated = function () {
leftBullet.y -= leftBullet.speed;
};
heroBullets.push(leftBullet);
LK.getSound('Herobullet').play();
game.addChild(leftBullet);
// Right bullet
var rightBullet = new HeroBullet();
rightBullet.x = hero.x + 100; // Increase the offset to the right (100 pixels)
rightBullet.y = hero.y;
rightBullet._move_migrated = function () {
rightBullet.y -= rightBullet.speed;
};
heroBullets.push(rightBullet);
LK.getSound('Herobullet').play();
game.addChild(rightBullet);
};
var spawnSpecialItem = function spawnSpecialItem() {
var item = new SpecialItem();
item.x = Math.random() * 2048;
item.y = 0;
specialItems.push(item);
game.addChild(item);
item.on('down', function () {
enemyBullets.forEach(function (bullet, index) {
bullet.destroy();
enemyBullets.splice(index, 1);
});
});
};
var spawnEnemyBullet = function spawnEnemyBullet(enemy) {
var bullet = new EnemyBullet();
bullet.x = enemy.x;
bullet.y = enemy.y;
bullet._move_migrated = function () {
bullet.y += bullet.speed;
};
enemyBullets.push(bullet);
game.addChild(bullet);
};
var checkCollision = function checkCollision() {
specialItems.forEach(function (item, index) {
if (hero.intersects(item)) {
item.destroy();
specialItems.splice(index, 1);
hero.bulletSpeed = 15;
LK.setTimeout(function () {
hero.bulletSpeed = 10;
}, 4000);
}
});
};
var gameOver = function gameOver() {};
LK.on('tick', function () {
bg.y += 2;
bg2.y += 2;
if (bg.y >= 2732) {
bg.y = -2732;
}
if (bg2.y >= 2732) {
bg2.y = -2732;
}
hero._move_migrated();
healthDisplay.updateHealth(hero.health);
enemies.forEach(function (enemy, index) {
enemy._move_migrated();
if (LK.ticks % 120 === 0 && enemy.y > 0) {
spawnEnemyBullet(enemy);
}
if (enemy.y > 2732) {
enemy.destroy();
enemies.splice(index, 1);
}
});
heroBullets.forEach(function (bullet, index) {
bullet._move_migrated();
if (bullet.y < 0) {
bullet.destroy();
heroBullets.splice(index, 1);
}
});
enemyBullets.forEach(function (bullet, index) {
bullet._move_migrated();
if (bullet.y > 2732) {
bullet.destroy();
enemyBullets.splice(index, 1);
}
});
specialItems.forEach(function (item, index) {
item._move_migrated();
if (item.y > 2732) {
item.destroy();
specialItems.splice(index, 1);
}
});
checkCollision();
heroBullets.forEach(function (bullet, bIndex) {
enemies.forEach(function (enemy, eIndex) {
if (bullet.intersects(enemy)) {
bullet.destroy();
heroBullets.splice(bIndex, 1);
LK.getSound('Exploding').play();
var explosion = game.attachAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5
});
explosion.x = enemy.x;
explosion.y = enemy.y;
game.addChild(explosion);
LK.setTimeout(function () {
explosion.destroy();
}, 500);
enemy.destroy();
enemies.splice(eIndex, 1);
}
});
});
enemyBullets.forEach(function (bullet, index) {
if (hero.intersects(bullet)) {
bullet.destroy();
enemyBullets.splice(index, 1);
hero.health--;
healthDisplay.updateHealth(hero.health);
if (hero.health <= 0) {
LK.showGameOver();
}
}
});
});
LK.on('tick', function () {
if (LK.ticks % 600 === 0) {
spawnSpecialItem();
}
if (LK.ticks % 384 === 0) {
spawnEnemy();
}
});
var dragHero = null;
game.on('down', function (x, y, obj) {
dragHero = hero;
if (LK.ticks - hero.lastBulletTime >= 60) {
hero.lastBulletTime = LK.ticks;
spawnHeroBullet();
spawnHeroBullet();
spawnHeroBullet();
}
});
game.on('move', function (x, y, obj) {
if (dragHero) {
var pos = game.toLocal(obj.global);
var oldX = dragHero.x;
dragHero.x = pos.x;
dragHero.y = pos.y;
var tilt = (dragHero.x - oldX) * 0.05;
tilt = Math.max(-0.5, Math.min(0.5, tilt));
hero.rotation = tilt;
if (LK.ticks - hero.lastBulletTime >= 60) {
hero.lastBulletTime = LK.ticks;
spawnHeroBullet();
spawnHeroBullet();
spawnHeroBullet();
}
}
});
game.on('up', function (x, y, obj) {
dragHero = null;
});
Futuristic fighter plane, chrono trigger, top down view, behind Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Special item shooting game pixel art, shiny Single Game Texture. In-Game asset. 2d. Blank background.
Top down shooter, alien space enemy craft, retro pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Bright yellow blast pixel art shooter game Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
65604d9e9017209915d71b35: Top down shooter, alien space enemy craft, retro pixel art, red flying space alien, giant eye ball Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
hit point heart pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art explosion, retro Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art fireball,. Single Game Texture. No shadows