var enemies = []; var MiniMap = Container.expand(function () { var self = Container.call(this); var mapGraphics = self.createAsset('miniMap', 'Mini Map Graphics', 0, 0); self.updateMap = function (playerPosition, enemyPositions) {}; }); var WeaponIcon = Container.expand(function (iconAssetId) { var self = Container.call(this); var icon = self.createAsset(iconAssetId, 'Weapon Icon', 0.5, 0.5); self.changeWeapon = function (newIconAssetId) { self.removeChild(icon); icon = self.createAsset(newIconAssetId, 'Weapon Icon', 0.5, 0.5); }; }); var AmmoCounter = Container.expand(function () { var self = Container.call(this); var ammoText = new Text2('Ammo: 0', { size: 50, fill: '#ffffff' }); self.addChild(ammoText); self.updateAmmo = function (ammo) { ammoText.setText('Ammo: ' + ammo); }; }); var HealthBar = Container.expand(function (maxHealth) { var self = Container.call(this); self.maxHealth = maxHealth; self.currentHealth = maxHealth; var background = self.createAsset('healthBarBg', 'Health Bar Background', 0, 0.5); var foreground = self.createAsset('healthBarFg', 'Health Bar Foreground', 0, 0.5); self.updateHealth = function (health) { self.currentHealth = health; foreground.scale.x = health / self.maxHealth; if (self.currentHealth < self.maxHealth * 0.3) { foreground.tint = 0xFF0000; } else if (self.currentHealth < self.maxHealth * 0.6) { foreground.tint = 0xFFFF00; } else { foreground.tint = 0x00FF00; } }; self.reset = function () { self.updateHealth(self.maxHealth); }; }); var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('heroBullet', 'Hero Bullet Graphics', .5, .5); self.initialX = self.x; self.initialY = self.y; self.speed = 100; self.move = function () { var closestEnemy = null; var closestDistance = Number.MAX_VALUE; self.parent.children.forEach(function (obj) { if (obj instanceof Enemy) { var distance = Math.sqrt(Math.pow(self.x - obj.x, 2) + Math.pow(self.y - obj.y, 2)); if (distance < closestDistance) { closestDistance = distance; closestEnemy = obj; } } }); if (closestEnemy) {} else { self.destroy(); if (self.parent && self.parent.heroBullets) { self.parent.heroBullets.splice(self.parent.heroBullets.indexOf(self), 1); } } }; self.checkCollision = function () { var allObjects = self.parent ? self.parent.children : []; for (var i = 0; i < allObjects.length; i++) { var obj = allObjects[i]; if (obj !== self && !(obj instanceof HeroBullet) && !(obj instanceof EnemyBullet) && self.intersects(obj)) { if (obj instanceof Enemy) { obj.takeDamage(1); if (obj.health <= 0) { enemies.splice(enemies.indexOf(obj), 1); } self.destroy(); if (self.parent && self.parent.heroBullets) { self.parent.heroBullets.splice(self.parent.heroBullets.indexOf(self), 1); } return; } } } }; }); var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('enemyBullet', 'Enemy Bullet Graphics', .5, .5); self.speed = 5; self.move = function () { self.y += self.speed; if (self.parent && self.parent.hero && self.intersects(self.parent.hero)) { self.parent.hero.takeDamage(1); self.destroy(); } }; }); var Enemy = Container.expand(function () { var self = Container.call(this); self.takeDamage = function () { self.health -= 1; if (self.health <= 0) { enemies.splice(enemies.indexOf(self), 1); self.destroy(); } }; self.health = 3; self.shootCooldown = 180 / 60 * 3; var enemyGraphics = self.createAsset('stormTrooper', 'Stormtrooper Graphics', .5, .5); self.speed = 2; self.move = function () { self.x += self.speed * Math.cos(self.angle); self.y += self.speed * Math.sin(self.angle); }; self.shoot = function (enemyBullets, gameContainer, hero) { if (!self.bullet && self.shootCooldown <= 0) { var bullet = new EnemyBullet(); bullet.x = self.x; bullet.y = self.y + self.height / 2; bullet.angle = Math.atan2(hero.y - bullet.y, hero.x - bullet.x); bullet.move = function () { bullet.x += bullet.speed * Math.cos(bullet.angle); bullet.y += bullet.speed * Math.sin(bullet.angle); }; enemyBullets.push(bullet); gameContainer.addChild(bullet); self.bullet = bullet; self.shootCooldown = 180 / 60 * 3; } }; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero Graphics', .5, .5); self.shootCooldown = 180 / 60 * 3; self.health = 10; self.targetX = self.x; self.targetY = self.y; self.moveSpeed = 6.75; self.updatePosition = function () { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > self.moveSpeed) { self.x += dx / distance * self.moveSpeed; self.y += dy / distance * self.moveSpeed; } else { self.x = self.targetX; self.y = self.targetY; } self.rotation = 0; }; self.shoot = function (heroBullets, gameContainer, allObjects) { if (self.shootCooldown <= 0) { var bullet = new HeroBullet(); bullet.x = self.x; bullet.y = self.y - self.height / 2; bullet.angle = Math.atan2(self.targetY - self.y, self.targetX - self.x); bullet.move = function () { bullet.x += bullet.speed * Math.cos(bullet.angle); bullet.y += bullet.speed * Math.sin(bullet.angle); }; self.shootCooldown = 180 / 60 * 3; self.parent.heroBullets.push(bullet); self.parent.addChild(bullet); } }; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0) { self.health = 0; LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }; self.update = function (heroBullets, gameContainer) { if (self.shootCooldown > 0) { self.shootCooldown--; } self.updatePosition(); if (self.targetX !== self.x || self.targetY !== self.y) { self.shoot(heroBullets, gameContainer); } }; }); var Game = Container.expand(function () { var self = Container.call(this); var hero = new Hero(); self.addChild(hero); hero.x = 2048 / 2; hero.y = 2732 - 200; var enemies = []; var enemySpawnTicker = 0; var enemySpawnRate = 120; self.heroBullets = []; var enemyBullets = []; var healthBar = new HealthBar(100); healthBar.x = 100; healthBar.y = 50; self.addChild(healthBar); var ammoCounter = new AmmoCounter(); ammoCounter.x = 2048 - 200; ammoCounter.y = 50; LK.gui.topRight.addChild(ammoCounter); var weaponIcon = new WeaponIcon('defaultWeapon'); weaponIcon.x = 2048 - 400; weaponIcon.y = 50; LK.gui.topRight.addChild(weaponIcon); var miniMap = new MiniMap(); miniMap.x = 2048 - 200; miniMap.y = 2732 - 200; LK.gui.bottomRight.addChild(miniMap); var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(.5, 0); self.addChild(scoreTxt); var dragNode = null; hero.on('down', function (obj) { dragNode = hero; }); function handleMove(obj) { var event = obj.event; var pos = event.getLocalPosition(self); hero.targetX = pos.x; hero.targetY = pos.y; } stage.on('move', handleMove); stage.on('up', function (obj) { dragNode = null; }); LK.on('tick', function () { for (var a = self.heroBullets.length - 1; a >= 0; a--) { self.heroBullets[a].move(); self.heroBullets[a].checkCollision(); if (self.heroBullets[a].y < -50 || self.heroBullets[a].y > 2732 + 50 || self.heroBullets[a].x < -50 || self.heroBullets[a].x > 2048 + 50) { self.heroBullets[a].destroy(); self.heroBullets.splice(a, 1); } } for (var a = enemyBullets.length - 1; a >= 0; a--) { enemyBullets[a].move(); if (enemyBullets[a].y > 2732 + 50) { enemyBullets[a].destroy(); enemyBullets.splice(a, 1); enemies.forEach(function (enemy) { if (enemy.bullet === enemyBullets[a]) { enemy.bullet = null; } }); } else if (hero.intersects(enemyBullets[a])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); enemyBullets[a].destroy(); enemyBullets.splice(a, 1); enemies.forEach(function (enemy) { if (enemy.bullet === enemyBullets[a]) { enemy.bullet = null; } }); } } hero.update(); if (enemySpawnTicker++ % enemySpawnRate === 0) { var newEnemy = new Enemy(); var spawnEdge = Math.floor(Math.random() * 4); switch (spawnEdge) { case 0: newEnemy.x = Math.random() * 2048; newEnemy.y = -newEnemy.height / 2; break; case 1: newEnemy.x = 2048 + newEnemy.width / 2; newEnemy.y = Math.random() * 2732; break; case 2: newEnemy.x = Math.random() * 2048; newEnemy.y = 2732 + newEnemy.height / 2; break; case 3: newEnemy.x = -newEnemy.width / 2; newEnemy.y = Math.random() * 2732; break; } newEnemy.angle = Math.atan2(hero.y - newEnemy.y, hero.x - newEnemy.x); enemies.push(newEnemy); self.addChild(newEnemy); } for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].move(); if (enemies[i].shootCooldown > 0) { enemies[i].shootCooldown--; } if (enemies[i].y > 2732 + 50) { enemies[i].destroy(); enemies.splice(i, 1); } else if (Math.random() < 0.01) { enemies[i].shoot(enemyBullets, self, hero); } } }); });
var enemies = [];
var MiniMap = Container.expand(function () {
var self = Container.call(this);
var mapGraphics = self.createAsset('miniMap', 'Mini Map Graphics', 0, 0);
self.updateMap = function (playerPosition, enemyPositions) {};
});
var WeaponIcon = Container.expand(function (iconAssetId) {
var self = Container.call(this);
var icon = self.createAsset(iconAssetId, 'Weapon Icon', 0.5, 0.5);
self.changeWeapon = function (newIconAssetId) {
self.removeChild(icon);
icon = self.createAsset(newIconAssetId, 'Weapon Icon', 0.5, 0.5);
};
});
var AmmoCounter = Container.expand(function () {
var self = Container.call(this);
var ammoText = new Text2('Ammo: 0', {
size: 50,
fill: '#ffffff'
});
self.addChild(ammoText);
self.updateAmmo = function (ammo) {
ammoText.setText('Ammo: ' + ammo);
};
});
var HealthBar = Container.expand(function (maxHealth) {
var self = Container.call(this);
self.maxHealth = maxHealth;
self.currentHealth = maxHealth;
var background = self.createAsset('healthBarBg', 'Health Bar Background', 0, 0.5);
var foreground = self.createAsset('healthBarFg', 'Health Bar Foreground', 0, 0.5);
self.updateHealth = function (health) {
self.currentHealth = health;
foreground.scale.x = health / self.maxHealth;
if (self.currentHealth < self.maxHealth * 0.3) {
foreground.tint = 0xFF0000;
} else if (self.currentHealth < self.maxHealth * 0.6) {
foreground.tint = 0xFFFF00;
} else {
foreground.tint = 0x00FF00;
}
};
self.reset = function () {
self.updateHealth(self.maxHealth);
};
});
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('heroBullet', 'Hero Bullet Graphics', .5, .5);
self.initialX = self.x;
self.initialY = self.y;
self.speed = 100;
self.move = function () {
var closestEnemy = null;
var closestDistance = Number.MAX_VALUE;
self.parent.children.forEach(function (obj) {
if (obj instanceof Enemy) {
var distance = Math.sqrt(Math.pow(self.x - obj.x, 2) + Math.pow(self.y - obj.y, 2));
if (distance < closestDistance) {
closestDistance = distance;
closestEnemy = obj;
}
}
});
if (closestEnemy) {} else {
self.destroy();
if (self.parent && self.parent.heroBullets) {
self.parent.heroBullets.splice(self.parent.heroBullets.indexOf(self), 1);
}
}
};
self.checkCollision = function () {
var allObjects = self.parent ? self.parent.children : [];
for (var i = 0; i < allObjects.length; i++) {
var obj = allObjects[i];
if (obj !== self && !(obj instanceof HeroBullet) && !(obj instanceof EnemyBullet) && self.intersects(obj)) {
if (obj instanceof Enemy) {
obj.takeDamage(1);
if (obj.health <= 0) {
enemies.splice(enemies.indexOf(obj), 1);
}
self.destroy();
if (self.parent && self.parent.heroBullets) {
self.parent.heroBullets.splice(self.parent.heroBullets.indexOf(self), 1);
}
return;
}
}
}
};
});
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('enemyBullet', 'Enemy Bullet Graphics', .5, .5);
self.speed = 5;
self.move = function () {
self.y += self.speed;
if (self.parent && self.parent.hero && self.intersects(self.parent.hero)) {
self.parent.hero.takeDamage(1);
self.destroy();
}
};
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
self.takeDamage = function () {
self.health -= 1;
if (self.health <= 0) {
enemies.splice(enemies.indexOf(self), 1);
self.destroy();
}
};
self.health = 3;
self.shootCooldown = 180 / 60 * 3;
var enemyGraphics = self.createAsset('stormTrooper', 'Stormtrooper Graphics', .5, .5);
self.speed = 2;
self.move = function () {
self.x += self.speed * Math.cos(self.angle);
self.y += self.speed * Math.sin(self.angle);
};
self.shoot = function (enemyBullets, gameContainer, hero) {
if (!self.bullet && self.shootCooldown <= 0) {
var bullet = new EnemyBullet();
bullet.x = self.x;
bullet.y = self.y + self.height / 2;
bullet.angle = Math.atan2(hero.y - bullet.y, hero.x - bullet.x);
bullet.move = function () {
bullet.x += bullet.speed * Math.cos(bullet.angle);
bullet.y += bullet.speed * Math.sin(bullet.angle);
};
enemyBullets.push(bullet);
gameContainer.addChild(bullet);
self.bullet = bullet;
self.shootCooldown = 180 / 60 * 3;
}
};
});
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero Graphics', .5, .5);
self.shootCooldown = 180 / 60 * 3;
self.health = 10;
self.targetX = self.x;
self.targetY = self.y;
self.moveSpeed = 6.75;
self.updatePosition = function () {
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > self.moveSpeed) {
self.x += dx / distance * self.moveSpeed;
self.y += dy / distance * self.moveSpeed;
} else {
self.x = self.targetX;
self.y = self.targetY;
}
self.rotation = 0;
};
self.shoot = function (heroBullets, gameContainer, allObjects) {
if (self.shootCooldown <= 0) {
var bullet = new HeroBullet();
bullet.x = self.x;
bullet.y = self.y - self.height / 2;
bullet.angle = Math.atan2(self.targetY - self.y, self.targetX - self.x);
bullet.move = function () {
bullet.x += bullet.speed * Math.cos(bullet.angle);
bullet.y += bullet.speed * Math.sin(bullet.angle);
};
self.shootCooldown = 180 / 60 * 3;
self.parent.heroBullets.push(bullet);
self.parent.addChild(bullet);
}
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
self.health = 0;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
};
self.update = function (heroBullets, gameContainer) {
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
self.updatePosition();
if (self.targetX !== self.x || self.targetY !== self.y) {
self.shoot(heroBullets, gameContainer);
}
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var hero = new Hero();
self.addChild(hero);
hero.x = 2048 / 2;
hero.y = 2732 - 200;
var enemies = [];
var enemySpawnTicker = 0;
var enemySpawnRate = 120;
self.heroBullets = [];
var enemyBullets = [];
var healthBar = new HealthBar(100);
healthBar.x = 100;
healthBar.y = 50;
self.addChild(healthBar);
var ammoCounter = new AmmoCounter();
ammoCounter.x = 2048 - 200;
ammoCounter.y = 50;
LK.gui.topRight.addChild(ammoCounter);
var weaponIcon = new WeaponIcon('defaultWeapon');
weaponIcon.x = 2048 - 400;
weaponIcon.y = 50;
LK.gui.topRight.addChild(weaponIcon);
var miniMap = new MiniMap();
miniMap.x = 2048 - 200;
miniMap.y = 2732 - 200;
LK.gui.bottomRight.addChild(miniMap);
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(.5, 0);
self.addChild(scoreTxt);
var dragNode = null;
hero.on('down', function (obj) {
dragNode = hero;
});
function handleMove(obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
hero.targetX = pos.x;
hero.targetY = pos.y;
}
stage.on('move', handleMove);
stage.on('up', function (obj) {
dragNode = null;
});
LK.on('tick', function () {
for (var a = self.heroBullets.length - 1; a >= 0; a--) {
self.heroBullets[a].move();
self.heroBullets[a].checkCollision();
if (self.heroBullets[a].y < -50 || self.heroBullets[a].y > 2732 + 50 || self.heroBullets[a].x < -50 || self.heroBullets[a].x > 2048 + 50) {
self.heroBullets[a].destroy();
self.heroBullets.splice(a, 1);
}
}
for (var a = enemyBullets.length - 1; a >= 0; a--) {
enemyBullets[a].move();
if (enemyBullets[a].y > 2732 + 50) {
enemyBullets[a].destroy();
enemyBullets.splice(a, 1);
enemies.forEach(function (enemy) {
if (enemy.bullet === enemyBullets[a]) {
enemy.bullet = null;
}
});
} else if (hero.intersects(enemyBullets[a])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
enemyBullets[a].destroy();
enemyBullets.splice(a, 1);
enemies.forEach(function (enemy) {
if (enemy.bullet === enemyBullets[a]) {
enemy.bullet = null;
}
});
}
}
hero.update();
if (enemySpawnTicker++ % enemySpawnRate === 0) {
var newEnemy = new Enemy();
var spawnEdge = Math.floor(Math.random() * 4);
switch (spawnEdge) {
case 0:
newEnemy.x = Math.random() * 2048;
newEnemy.y = -newEnemy.height / 2;
break;
case 1:
newEnemy.x = 2048 + newEnemy.width / 2;
newEnemy.y = Math.random() * 2732;
break;
case 2:
newEnemy.x = Math.random() * 2048;
newEnemy.y = 2732 + newEnemy.height / 2;
break;
case 3:
newEnemy.x = -newEnemy.width / 2;
newEnemy.y = Math.random() * 2732;
break;
}
newEnemy.angle = Math.atan2(hero.y - newEnemy.y, hero.x - newEnemy.x);
enemies.push(newEnemy);
self.addChild(newEnemy);
}
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].move();
if (enemies[i].shootCooldown > 0) {
enemies[i].shootCooldown--;
}
if (enemies[i].y > 2732 + 50) {
enemies[i].destroy();
enemies.splice(i, 1);
} else if (Math.random() < 0.01) {
enemies[i].shoot(enemyBullets, self, hero);
}
}
});
});
pixel art image of a stormtrooper from the Star Wars universe. The stormtrooper should be standing in a defensive pose, with their blaster raised. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a series of pixel art images depicting a blaster shot. The blaster shot should be represented by a small, glowing projectile with a trail of smoke or sparks. The animation should consist of eight frames and loop continuously. Use a limited color palette of 16 colors or less, simple shapes and lines, and transparency for a seamless background. Employ standard pixel art techniques like dithering and anti-aliasing. Bright flash, sizzling sound, swift arc, fading glow.
Create a pixel art sprite of the Mandalorian from the Star Wars universe. The Mandalorian should be standing in a determined pose, with his beskar armor and blaster raised. The sprite should be detailed and recognizable, but also stylized to fit within the pixel art aesthetic. The Mandalorian is a skilled bounty hunter known for his unwavering determination and formidable combat skills. Clad in his signature beskar armor, he wields an array of deadly weapons, including his trusty blaster and a jetpack that allows him to maneuver with incredible agility. Despite his gruff exterior, the Mandalorian possesses a strong sense of honor and a deep-seated loyalty to those he protects.
• Position: The health bar should be positioned at the top of the screen, centered or slightly to the left side, to ensure it remains visible throughout gameplay. • Appearance: The health bar should be a simple horizontal bar with a clear color gradient, typically from green to red, indicating the player's remaining health. The bar should be easily distinguishable from the background and should have a smooth and consistent shape. • Size: The health bar should be large enough to be easily visible without taking up too much screen space. A height of 5-10 pixels is generally sufficient. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.