/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Artifact = Container.expand(function () {
var self = Container.call(this);
var artifactGraphics = self.attachAsset('artifact', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
self.lifeTime = 0;
self.collect = function () {
if (!self.collected) {
self.collected = true;
LK.getSound('powerUp').play();
LK.setScore(LK.getScore() + 100);
// Heal hero
hero.health = Math.min(hero.maxHealth, hero.health + 20);
// Remove from artifacts array
for (var i = artifacts.length - 1; i >= 0; i--) {
if (artifacts[i] === self) {
artifacts.splice(i, 1);
break;
}
}
tween(self, {
scaleX: 0,
scaleY: 0
}, {
duration: 200,
onFinish: function onFinish() {
self.destroy();
}
});
}
};
self.update = function () {
self.lifeTime++;
self.rotation += 0.1;
// Pulse effect
var pulse = Math.sin(self.lifeTime * 0.2) * 0.2 + 1;
self.scaleX = pulse;
self.scaleY = pulse;
// Despawn after 10 seconds
if (self.lifeTime > 600) {
for (var i = artifacts.length - 1; i >= 0; i--) {
if (artifacts[i] === self) {
artifacts.splice(i, 1);
break;
}
}
self.destroy();
}
};
return self;
});
var Enemy = Container.expand(function (enemyType) {
var self = Container.call(this);
self.enemyType = enemyType || 'minotaur';
self.health = 1;
self.damage = 10;
self.speed = 2;
self.points = 10;
var enemyGraphics;
if (self.enemyType === 'minotaur') {
enemyGraphics = self.attachAsset('minotaur', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 2;
self.speed = 1.5;
self.points = 15;
} else if (self.enemyType === 'harpy') {
enemyGraphics = self.attachAsset('harpy', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 1;
self.speed = 3;
self.points = 20;
} else if (self.enemyType === 'cyclops') {
enemyGraphics = self.attachAsset('cyclops', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 4;
self.speed = 1;
self.damage = 20;
self.points = 50;
}
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xFFFFFF, 200);
if (self.health <= 0) {
self.die();
}
};
self.die = function () {
LK.getSound('enemyHit').play();
LK.setScore(LK.getScore() + self.points);
// Chance to drop artifact
if (Math.random() < 0.15) {
var artifact = new Artifact();
artifact.x = self.x;
artifact.y = self.y;
artifacts.push(artifact);
game.addChild(artifact);
}
// Remove from enemies array
for (var i = enemies.length - 1; i >= 0; i--) {
if (enemies[i] === self) {
enemies.splice(i, 1);
break;
}
}
self.destroy();
};
self.update = function () {
// Move towards hero
var dx = hero.x - self.x;
var dy = hero.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
};
return self;
});
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.maxHealth = 100;
self.shootCooldown = 0;
self.speed = 8;
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xFF0000, 300);
if (self.health <= 0) {
gameOver = true;
}
};
self.shoot = function () {
if (self.shootCooldown <= 0) {
var bullet = new HeroBullet();
bullet.x = self.x;
bullet.y = self.y - 40;
heroBullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
self.shootCooldown = 10;
}
};
self.update = function () {
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
};
return self;
});
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('heroBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 12;
self.damage = 1;
self.update = function () {
self.y -= self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
// Game variables
var hero;
var heroBullets = [];
var enemies = [];
var artifacts = [];
var enemySpawnTimer = 0;
var gameOver = false;
var dragActive = false;
var waveLevel = 1;
// UI
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
scoreTxt.x = 120;
scoreTxt.y = 50;
LK.gui.topLeft.addChild(scoreTxt);
var healthTxt = new Text2('Health: 100', {
size: 60,
fill: 0xFF4444
});
healthTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(healthTxt);
var waveTxt = new Text2('Wave: 1', {
size: 50,
fill: 0x44FF44
});
waveTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(waveTxt);
// Initialize hero
hero = new Hero();
hero.x = 1024;
hero.y = 2000;
game.addChild(hero);
// Spawn enemy function
function spawnEnemy() {
var enemyTypes = ['minotaur', 'harpy', 'cyclops'];
var type = enemyTypes[Math.floor(Math.random() * enemyTypes.length)];
// Cyclops only spawn in later waves
if (type === 'cyclops' && waveLevel < 3) {
type = 'minotaur';
}
var enemy = new Enemy(type);
// Spawn from random edge
var side = Math.floor(Math.random() * 4);
if (side === 0) {
// Top
enemy.x = Math.random() * 2048;
enemy.y = -100;
} else if (side === 1) {
// Right
enemy.x = 2148;
enemy.y = Math.random() * 2732;
} else if (side === 2) {
// Bottom
enemy.x = Math.random() * 2048;
enemy.y = 2832;
} else {
// Left
enemy.x = -100;
enemy.y = Math.random() * 2732;
}
enemies.push(enemy);
game.addChild(enemy);
}
// Touch controls
game.down = function (x, y, obj) {
dragActive = true;
hero.x = x;
hero.y = y;
hero.shoot();
};
game.move = function (x, y, obj) {
if (dragActive) {
hero.x = x;
hero.y = y;
}
};
game.up = function (x, y, obj) {
dragActive = false;
};
// Main game loop
game.update = function () {
if (gameOver) {
LK.showGameOver();
return;
}
// Update hero
hero.update();
// Keep hero in bounds
hero.x = Math.max(40, Math.min(2008, hero.x));
hero.y = Math.max(40, Math.min(2692, hero.y));
// Auto-shoot
if (LK.ticks % 15 === 0) {
hero.shoot();
}
// Spawn enemies
enemySpawnTimer++;
var spawnRate = Math.max(30, 120 - waveLevel * 10);
if (enemySpawnTimer >= spawnRate) {
spawnEnemy();
enemySpawnTimer = 0;
}
// Update bullets
for (var i = heroBullets.length - 1; i >= 0; i--) {
var bullet = heroBullets[i];
bullet.update();
// Remove bullets that are off-screen
if (bullet.y < -50) {
bullet.destroy();
heroBullets.splice(i, 1);
continue;
}
// Check bullet vs enemy collisions
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
enemy.takeDamage(bullet.damage);
bullet.destroy();
heroBullets.splice(i, 1);
break;
}
}
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
enemy.update();
// Check hero vs enemy collision
if (enemy.intersects(hero)) {
hero.takeDamage(enemy.damage);
enemy.die();
}
// Remove enemies that are too far off-screen
if (enemy.x < -200 || enemy.x > 2248 || enemy.y < -200 || enemy.y > 2932) {
enemies.splice(i, 1);
enemy.destroy();
}
}
// Update artifacts
for (var i = artifacts.length - 1; i >= 0; i--) {
var artifact = artifacts[i];
artifact.update();
// Check hero vs artifact collision
if (artifact.intersects(hero)) {
artifact.collect();
}
}
// Update wave level based on score
var newWaveLevel = Math.floor(LK.getScore() / 500) + 1;
if (newWaveLevel > waveLevel) {
waveLevel = newWaveLevel;
LK.effects.flashScreen(0x00FF00, 500);
}
// Update UI
scoreTxt.setText('Score: ' + LK.getScore());
healthTxt.setText('Health: ' + hero.health);
waveTxt.setText('Wave: ' + waveLevel);
};
// Start background music
LK.playMusic('dungeonMusic'); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,355 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Artifact = Container.expand(function () {
+ var self = Container.call(this);
+ var artifactGraphics = self.attachAsset('artifact', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.collected = false;
+ self.lifeTime = 0;
+ self.collect = function () {
+ if (!self.collected) {
+ self.collected = true;
+ LK.getSound('powerUp').play();
+ LK.setScore(LK.getScore() + 100);
+ // Heal hero
+ hero.health = Math.min(hero.maxHealth, hero.health + 20);
+ // Remove from artifacts array
+ for (var i = artifacts.length - 1; i >= 0; i--) {
+ if (artifacts[i] === self) {
+ artifacts.splice(i, 1);
+ break;
+ }
+ }
+ tween(self, {
+ scaleX: 0,
+ scaleY: 0
+ }, {
+ duration: 200,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ }
+ };
+ self.update = function () {
+ self.lifeTime++;
+ self.rotation += 0.1;
+ // Pulse effect
+ var pulse = Math.sin(self.lifeTime * 0.2) * 0.2 + 1;
+ self.scaleX = pulse;
+ self.scaleY = pulse;
+ // Despawn after 10 seconds
+ if (self.lifeTime > 600) {
+ for (var i = artifacts.length - 1; i >= 0; i--) {
+ if (artifacts[i] === self) {
+ artifacts.splice(i, 1);
+ break;
+ }
+ }
+ self.destroy();
+ }
+ };
+ return self;
+});
+var Enemy = Container.expand(function (enemyType) {
+ var self = Container.call(this);
+ self.enemyType = enemyType || 'minotaur';
+ self.health = 1;
+ self.damage = 10;
+ self.speed = 2;
+ self.points = 10;
+ var enemyGraphics;
+ if (self.enemyType === 'minotaur') {
+ enemyGraphics = self.attachAsset('minotaur', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 2;
+ self.speed = 1.5;
+ self.points = 15;
+ } else if (self.enemyType === 'harpy') {
+ enemyGraphics = self.attachAsset('harpy', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 1;
+ self.speed = 3;
+ self.points = 20;
+ } else if (self.enemyType === 'cyclops') {
+ enemyGraphics = self.attachAsset('cyclops', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 4;
+ self.speed = 1;
+ self.damage = 20;
+ self.points = 50;
+ }
+ self.takeDamage = function (damage) {
+ self.health -= damage;
+ LK.effects.flashObject(self, 0xFFFFFF, 200);
+ if (self.health <= 0) {
+ self.die();
+ }
+ };
+ self.die = function () {
+ LK.getSound('enemyHit').play();
+ LK.setScore(LK.getScore() + self.points);
+ // Chance to drop artifact
+ if (Math.random() < 0.15) {
+ var artifact = new Artifact();
+ artifact.x = self.x;
+ artifact.y = self.y;
+ artifacts.push(artifact);
+ game.addChild(artifact);
+ }
+ // Remove from enemies array
+ for (var i = enemies.length - 1; i >= 0; i--) {
+ if (enemies[i] === self) {
+ enemies.splice(i, 1);
+ break;
+ }
+ }
+ self.destroy();
+ };
+ self.update = function () {
+ // Move towards hero
+ var dx = hero.x - self.x;
+ var dy = hero.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 0) {
+ self.x += dx / distance * self.speed;
+ self.y += dy / distance * self.speed;
+ }
+ };
+ return self;
+});
+var Hero = Container.expand(function () {
+ var self = Container.call(this);
+ var heroGraphics = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 100;
+ self.maxHealth = 100;
+ self.shootCooldown = 0;
+ self.speed = 8;
+ self.takeDamage = function (damage) {
+ self.health -= damage;
+ LK.effects.flashObject(self, 0xFF0000, 300);
+ if (self.health <= 0) {
+ gameOver = true;
+ }
+ };
+ self.shoot = function () {
+ if (self.shootCooldown <= 0) {
+ var bullet = new HeroBullet();
+ bullet.x = self.x;
+ bullet.y = self.y - 40;
+ heroBullets.push(bullet);
+ game.addChild(bullet);
+ LK.getSound('shoot').play();
+ self.shootCooldown = 10;
+ }
+ };
+ self.update = function () {
+ if (self.shootCooldown > 0) {
+ self.shootCooldown--;
+ }
+ };
+ return self;
+});
+var HeroBullet = Container.expand(function () {
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('heroBullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 12;
+ self.damage = 1;
+ self.update = function () {
+ self.y -= self.speed;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a1a2e
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var hero;
+var heroBullets = [];
+var enemies = [];
+var artifacts = [];
+var enemySpawnTimer = 0;
+var gameOver = false;
+var dragActive = false;
+var waveLevel = 1;
+// UI
+var scoreTxt = new Text2('Score: 0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0, 0);
+scoreTxt.x = 120;
+scoreTxt.y = 50;
+LK.gui.topLeft.addChild(scoreTxt);
+var healthTxt = new Text2('Health: 100', {
+ size: 60,
+ fill: 0xFF4444
+});
+healthTxt.anchor.set(1, 0);
+LK.gui.topRight.addChild(healthTxt);
+var waveTxt = new Text2('Wave: 1', {
+ size: 50,
+ fill: 0x44FF44
+});
+waveTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(waveTxt);
+// Initialize hero
+hero = new Hero();
+hero.x = 1024;
+hero.y = 2000;
+game.addChild(hero);
+// Spawn enemy function
+function spawnEnemy() {
+ var enemyTypes = ['minotaur', 'harpy', 'cyclops'];
+ var type = enemyTypes[Math.floor(Math.random() * enemyTypes.length)];
+ // Cyclops only spawn in later waves
+ if (type === 'cyclops' && waveLevel < 3) {
+ type = 'minotaur';
+ }
+ var enemy = new Enemy(type);
+ // Spawn from random edge
+ var side = Math.floor(Math.random() * 4);
+ if (side === 0) {
+ // Top
+ enemy.x = Math.random() * 2048;
+ enemy.y = -100;
+ } else if (side === 1) {
+ // Right
+ enemy.x = 2148;
+ enemy.y = Math.random() * 2732;
+ } else if (side === 2) {
+ // Bottom
+ enemy.x = Math.random() * 2048;
+ enemy.y = 2832;
+ } else {
+ // Left
+ enemy.x = -100;
+ enemy.y = Math.random() * 2732;
+ }
+ enemies.push(enemy);
+ game.addChild(enemy);
+}
+// Touch controls
+game.down = function (x, y, obj) {
+ dragActive = true;
+ hero.x = x;
+ hero.y = y;
+ hero.shoot();
+};
+game.move = function (x, y, obj) {
+ if (dragActive) {
+ hero.x = x;
+ hero.y = y;
+ }
+};
+game.up = function (x, y, obj) {
+ dragActive = false;
+};
+// Main game loop
+game.update = function () {
+ if (gameOver) {
+ LK.showGameOver();
+ return;
+ }
+ // Update hero
+ hero.update();
+ // Keep hero in bounds
+ hero.x = Math.max(40, Math.min(2008, hero.x));
+ hero.y = Math.max(40, Math.min(2692, hero.y));
+ // Auto-shoot
+ if (LK.ticks % 15 === 0) {
+ hero.shoot();
+ }
+ // Spawn enemies
+ enemySpawnTimer++;
+ var spawnRate = Math.max(30, 120 - waveLevel * 10);
+ if (enemySpawnTimer >= spawnRate) {
+ spawnEnemy();
+ enemySpawnTimer = 0;
+ }
+ // Update bullets
+ for (var i = heroBullets.length - 1; i >= 0; i--) {
+ var bullet = heroBullets[i];
+ bullet.update();
+ // Remove bullets that are off-screen
+ if (bullet.y < -50) {
+ bullet.destroy();
+ heroBullets.splice(i, 1);
+ continue;
+ }
+ // Check bullet vs enemy collisions
+ for (var j = enemies.length - 1; j >= 0; j--) {
+ var enemy = enemies[j];
+ if (bullet.intersects(enemy)) {
+ enemy.takeDamage(bullet.damage);
+ bullet.destroy();
+ heroBullets.splice(i, 1);
+ break;
+ }
+ }
+ }
+ // Update enemies
+ for (var i = enemies.length - 1; i >= 0; i--) {
+ var enemy = enemies[i];
+ enemy.update();
+ // Check hero vs enemy collision
+ if (enemy.intersects(hero)) {
+ hero.takeDamage(enemy.damage);
+ enemy.die();
+ }
+ // Remove enemies that are too far off-screen
+ if (enemy.x < -200 || enemy.x > 2248 || enemy.y < -200 || enemy.y > 2932) {
+ enemies.splice(i, 1);
+ enemy.destroy();
+ }
+ }
+ // Update artifacts
+ for (var i = artifacts.length - 1; i >= 0; i--) {
+ var artifact = artifacts[i];
+ artifact.update();
+ // Check hero vs artifact collision
+ if (artifact.intersects(hero)) {
+ artifact.collect();
+ }
+ }
+ // Update wave level based on score
+ var newWaveLevel = Math.floor(LK.getScore() / 500) + 1;
+ if (newWaveLevel > waveLevel) {
+ waveLevel = newWaveLevel;
+ LK.effects.flashScreen(0x00FF00, 500);
+ }
+ // Update UI
+ scoreTxt.setText('Score: ' + LK.getScore());
+ healthTxt.setText('Health: ' + hero.health);
+ waveTxt.setText('Wave: ' + waveLevel);
+};
+// Start background music
+LK.playMusic('dungeonMusic');
\ No newline at end of file
a realistic cyclops face. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
a woman who has wings instead of arms and talons instead of legs. realistic
a realistic angry bull head. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
a realistic gold chalice. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
a realistic face of a spartan warrior. In-Game asset. 2d. High contrast. No shadows
make this photo up to down
a darker green
a medieval chest. In-Game asset. 2d. High contrast. No shadows
a mediaval sword. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
a classic health potion, a bottle of translucent red liquid. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat